Skip to content

Commit 7be868c

Browse files
making drop_borderline consistent.
1 parent 8bc7e33 commit 7be868c

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/rachel_analysis_utils/nwb_utils.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ def _map_event_to_intended_measurement(event_str, session_map, correct_map):
7575
areas.append(area)
7676
return ":".join(areas) if areas else np.nan
7777

78-
def _apply_channel_drops_to_nwb(nwb, entry, correct_map, include_borderline=False):
78+
def _apply_channel_drops_to_nwb(nwb, entry, correct_map, drop_borderline=False):
7979
"""
8080
Return a deepcopy of nwb with channels/sessions removed per entry.
8181
82+
drop_borderline: also drop the borderline sessions.
83+
8284
Drops whole session if drop_all or date in drop_sessions.
8385
Removes rows from n.df_fip where the 'intended_measurement' matches any region
8486
listed in the subject/session drop lists. If intended_measurement is not present
@@ -123,7 +125,7 @@ def _apply_channel_drops_to_nwb(nwb, entry, correct_map, include_borderline=Fals
123125

124126
# optional borderline drops (support both naming variants) if requested
125127
borderline_map = entry.get("borderline_drop_sessions_channels", {}) or entry.get("borderline_drop_channels", {}) or {}
126-
borderline_specific_chs = _channels_for_date(borderline_map, date) if include_borderline else []
128+
borderline_specific_chs = _channels_for_date(borderline_map, date) if drop_borderline else []
127129
for ch in borderline_specific_chs:
128130
region = correct_map.get(ch)
129131
if region:
@@ -155,10 +157,14 @@ def _apply_channel_drops_to_nwb(nwb, entry, correct_map, include_borderline=Fals
155157
n.df_fip = df_fip
156158

157159
return n
158-
def apply_curation_nwb_list(nwb_list, curation, drop_border = False):
160+
def apply_curation_nwb_list(nwb_list, curation, drop_borderline = False):
159161
"""
160162
Apply curation rules to a list (or list-of-lists) of nwb objects.
161163
164+
nwb_list: list of nwbs
165+
curation: dataframe of curation notes from json.
166+
drop_borderline: determines if we should drop borderline sessions as well
167+
162168
Returns two lists:
163169
- curated: nwb objects with drop_channels removed and drop_sessions omitted
164170
- curated_with_borderline: same as above but also applying 'borderline_drop' variants
@@ -198,12 +204,12 @@ def apply_curation_nwb_list(nwb_list, curation, drop_border = False):
198204
nwb_annot.df_fip = df_fip.reset_index(drop=True)
199205

200206
# now apply drops (these return deepcopy-modified objects)
201-
n_cur = _apply_channel_drops_to_nwb(nwb_annot, entry, correct_map, include_borderline=False)
207+
n_cur = _apply_channel_drops_to_nwb(nwb_annot, entry, correct_map, drop_borderline=False)
202208
if n_cur is not None:
203209
curated.append(n_cur)
204210

205-
if not drop_border:
206-
n_cur_b = _apply_channel_drops_to_nwb(nwb_annot, entry, correct_map, include_borderline=True)
211+
if drop_borderline:
212+
n_cur_b = _apply_channel_drops_to_nwb(nwb_annot, entry, correct_map, drop_borderline=True)
207213
if n_cur_b is not None:
208214
curated_with_borderline.append(n_cur_b)
209215

0 commit comments

Comments
 (0)