Skip to content

Commit

Permalink
fix curation
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 committed Feb 20, 2024
1 parent 4e9e367 commit f19a4eb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/expipe_plugin_cinpla/nwbutils/nwbwidgetsunitviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
15 changes: 9 additions & 6 deletions src/expipe_plugin_cinpla/scripts/curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"]
Expand Down
11 changes: 6 additions & 5 deletions src/expipe_plugin_cinpla/widgets/curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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":
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit f19a4eb

Please sign in to comment.