Psth multiple nwbs#70
Conversation
| """ | ||
| if not hasattr(nwb, "df_fip"): | ||
| # Check if nwb is a list, and if so, check only the first element for attributes and channel | ||
| nwb_to_check = nwb[0] if isinstance(nwb, list) else nwb |
There was a problem hiding this comment.
why check only the first NWB? Checks are fast, so we should just check all of them
There was a problem hiding this comment.
agreed. done. am testing and wll send PR back to you once I do that.
| censor_times.append(align_dict[key]) | ||
| if isinstance(nwb, list): | ||
| align_dict_flat[key] = np.concatenate(align_dict[key]) | ||
| censor_times.append(align_dict_flat[key]) |
There was a problem hiding this comment.
I'm not sure what you are doing here with align_dict_flat
There was a problem hiding this comment.
This feels wrong, because the censor times from one NWB shouldn't impact the censor times of another NWB
There was a problem hiding this comment.
you're right-- fixed.
| # Check if nwb is a list, and if so, check only the first element for attributes and channel | ||
| nwb_to_check = nwb[0] if isinstance(nwb, list) else nwb | ||
|
|
||
| if not hasattr(nwb_to_check, "df_fip"): |
There was a problem hiding this comment.
Again, I would check all NWBs
|
Thank you for the feedback. i have:
i have tested the functions with:
|
| return | ||
| else: | ||
| align_vals = nwb_i.df_events.query("event == @a")["timestamps"].values | ||
| align_list = align_dict.get(a, []) |
There was a problem hiding this comment.
Why save things to align_vals, then use .get()? You already checked above if a is in df_events
There was a problem hiding this comment.
to not repeat it for the if/else logic below.
.get is checking align_dict, not checking nwb_i.df_events.
| align_vals = nwb_i.df_events.query("event == @a")["timestamps"].values | ||
| align_list = align_dict.get(a, []) | ||
| if len(nwb_to_check) > 1: | ||
| align_list.append(align_vals) |
There was a problem hiding this comment.
there are two cases:
one single nwb coming into plot_fip_psth_compare_alignments, in which case the align_dict should have a string key and a list of the align_vals.
multiple nwb's coming into 'plot_fip_psth_compare_alignments', in which case the align_dict should have a string key and a list of lists (each list an align_val for each NWB)
If I don't separate out the two cases when looking at alignments given as a column, the align_dict for a single NWB will have a string key and a nested list (list of a single list). This will cause a problem in line 95, because np.concatenate will fail.
PSTH for mulitple NWBs