Skip to content

Commit

Permalink
fix curation - empty units
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Feb 20, 2024
1 parent f19a4eb commit 1569843
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/expipe_plugin_cinpla/scripts/curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ def load_main_units(self):
return nwbfile.units

def construct_curated_units(self):
if len(self.curated_we.unit_ids) == 0:
print("No units left after curation.")
return
self.io = NWBHDF5IO(self.nwb_path_main, "r")
nwbfile = self.io.read()
add_units_from_waveform_extractor(
Expand Down
15 changes: 9 additions & 6 deletions src/expipe_plugin_cinpla/widgets/curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,9 @@ def on_curated_link(change):
print(f"Applying curation from {sv_curated_link.value}")
self.sorting_curator.apply_sortingview_curation(sorter_list.value[0], sv_curated_link.value)
units = self.sorting_curator.construct_curated_units()
w = nwb2widget(units, custom_curated_unit_vis)
units_viewers["curated"] = w
if units:
w = nwb2widget(units, custom_curated_unit_vis)
units_viewers["curated"] = w

def on_add_metric(change):
action = project.actions[actions_list.value]
Expand Down Expand Up @@ -296,8 +297,9 @@ def on_load_phy(change):
else:
self.sorting_curator.load_from_phy(sorter_list.value[0])
units = self.sorting_curator.construct_curated_units()
w = nwb2widget(units, custom_curated_unit_vis)
units_viewers["curated"] = w
if units:
w = nwb2widget(units, custom_curated_unit_vis)
units_viewers["curated"] = w

@self.output.capture()
def on_restore_phy(change):
Expand All @@ -317,8 +319,9 @@ def on_apply_qm_curation(change):
query = " and ".join([qm.get_query() for qm in qc_metrics.children])
self.sorting_curator.apply_qc_curator(sorter_list.value[0], query)
units = self.sorting_curator.construct_curated_units()
w = nwb2widget(units, custom_curated_unit_vis)
units_viewers["curated"] = w
if units:
w = nwb2widget(units, custom_curated_unit_vis)
units_viewers["curated"] = w

@self.output.capture()
def on_save_to_nwb(change):
Expand Down

0 comments on commit 1569843

Please sign in to comment.