diff --git a/src/expipe_plugin_cinpla/nwbutils/nwbwidgetsunitviewer.py b/src/expipe_plugin_cinpla/nwbutils/nwbwidgetsunitviewer.py index 845dc62..d92bfb9 100644 --- a/src/expipe_plugin_cinpla/nwbutils/nwbwidgetsunitviewer.py +++ b/src/expipe_plugin_cinpla/nwbutils/nwbwidgetsunitviewer.py @@ -115,7 +115,7 @@ def __init__( if spatial_series is None: self.spatial_series = self.get_spatial_series() if len(self.spatial_series) == 0: - self.children = [widgets.HTML("No trials present")] + self.children = [widgets.HTML("No sparial series present")] return elif len(self.spatial_series) > 1: self.spatial_series_selector = widgets.Dropdown( diff --git a/src/expipe_plugin_cinpla/scripts/curation.py b/src/expipe_plugin_cinpla/scripts/curation.py index 39c239b..3a694c5 100644 --- a/src/expipe_plugin_cinpla/scripts/curation.py +++ b/src/expipe_plugin_cinpla/scripts/curation.py @@ -4,6 +4,7 @@ import numpy as np from pynwb import NWBHDF5IO from pynwb.testing.mock.file import mock_NWBFile +import warnings import spikeinterface.full as si import spikeinterface.extractors as se @@ -15,6 +16,7 @@ from .utils import _get_data_path, add_units_from_waveform_extractor, compute_and_set_unit_groups +warnings.filterwarnings("ignore", category=ResourceWarning) metric_metric_str_to_si_metric_name = { "amplitude_cutoff": "amplitude_cutoff", @@ -100,16 +102,17 @@ def load_main_units(self): return nwbfile.units def construct_curated_units(self): - nwbfile_mock = mock_NWBFile() + self.io = NWBHDF5IO(self.nwb_path_main, "r") + nwbfile = self.io.read() add_units_from_waveform_extractor( self.curated_we, - nwbfile_mock, - unit_table_name="units", + nwbfile, + unit_table_name="curated units", unit_table_description=self.curation_description, - write_in_processing_module=False, + write_in_processing_module=True, write_electrodes_column=False, ) - return nwbfile_mock.units + return nwbfile.units def load_processed_recording(self, sorter): preprocessed_json = self.si_path / sorter / "preprocessed.json" @@ -184,7 +187,7 @@ def get_phy_run_command(self, sorter): def get_sortingview_link(self, sorter): visualization_json = self.si_path / sorter / "sortingview_links.json" if not visualization_json.is_file(): - return "" + return "Sorting view link not found." with open(visualization_json, "r") as f: sortingview_links = json.load(f) return sortingview_links["raw"] diff --git a/src/expipe_plugin_cinpla/widgets/curation.py b/src/expipe_plugin_cinpla/widgets/curation.py index 69fd3a5..1e63576 100644 --- a/src/expipe_plugin_cinpla/widgets/curation.py +++ b/src/expipe_plugin_cinpla/widgets/curation.py @@ -205,6 +205,8 @@ def on_action(change): sv_visualization_link.value = self.sorting_curator.get_sortingview_link(sorter_list.value[0]) elif strategy.value == "Phy": run_phy_command.value = self.sorting_curator.get_phy_run_command(sorter_list.value[0]) + units_dropdown.value = "Raw" + on_choose_units(None) def on_sorter(change): required_values_filled(actions_list) @@ -216,20 +218,17 @@ def on_sorter(change): if units_raw is not None: w = nwb2widget(units_raw, custom_raw_unit_vis) units_viewers["raw"] = w - else: - units_viewers["raw"] = sorting_not_found units_main = self.sorting_curator.load_main_units() if units_main is not None: w = nwb2widget(units_main, custom_main_unit_vis) units_viewers["main"] = w - else: - units_viewers["main"] = sorting_not_found - units_viewers["curated"] = sorting_not_found if strategy.value == "Sortingview": # load visualization link sv_visualization_link.value = self.sorting_curator.get_sortingview_link(sorter_list.value[0]) elif strategy.value == "Phy": run_phy_command.value = self.sorting_curator.get_phy_run_command(sorter_list.value[0]) + units_dropdown.value = "Raw" + on_choose_units(None) def on_change_strategy(change): if change["new"] == "Phy": @@ -275,6 +274,8 @@ def on_choose_units(change): units_widget = units_viewers[units_dropdown.value.lower()] if units_widget is not None: units_col.children = [units_dropdown, units_widget] + else: + units_col.children = [units_dropdown, sorting_not_found] @self.output.capture() def on_set_default_qms(change):