From 6255c71b97b0c0344eb8def2ad8b75fb4308cd12 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Tue, 24 Feb 2026 12:18:04 +0100 Subject: [PATCH 1/3] Remove sparsity column and add 'clear' label shortcut --- spikeinterface_gui/unitlistview.py | 24 ++++++++++++----------- spikeinterface_gui/waveformheatmapview.py | 16 +++++++-------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/spikeinterface_gui/unitlistview.py b/spikeinterface_gui/unitlistview.py index 5512aadf..43489c04 100644 --- a/spikeinterface_gui/unitlistview.py +++ b/spikeinterface_gui/unitlistview.py @@ -105,6 +105,10 @@ def _qt_make_layout(self): self.shortcut_mua = None self.shortcut_noise = None if self.controller.has_default_quality_labels: + self.shortcut_clear = QT.QShortcut(self.qt_widget) + self.shortcut_clear.setKey(QT.QKeySequence('c')) + self.shortcut_clear.activated.connect(lambda: self._qt_set_default_label(None)) + self.shortcut_good = QT.QShortcut(self.qt_widget) self.shortcut_good.setKey(QT.QKeySequence('g')) self.shortcut_good.activated.connect(lambda: self._qt_set_default_label('good')) @@ -212,7 +216,7 @@ def _qt_full_table_refresh(self): self.table.clear() - internal_column_names = ['unit_id', 'visible', 'channel_id', 'sparsity'] + internal_column_names = ['unit_id', 'visible', 'channel_id'] # internal labels column_labels = list(internal_column_names) @@ -272,11 +276,6 @@ def _qt_full_table_refresh(self): item = CustomItem(f'{channel_id}') item.setFlags(QT.Qt.ItemIsEnabled|QT.Qt.ItemIsSelectable) self.table.setItem(i, 2, item) - - num_chan = np.sum(self.controller.get_sparsity_mask()[i, :]) - item = CustomItem(f'{num_chan}') - item.setFlags(QT.Qt.ItemIsEnabled|QT.Qt.ItemIsSelectable) - self.table.setItem(i, 3, item) n_first = len(internal_column_names) self.label_columns = list(range(n_first, n_first + num_labels)) @@ -476,10 +475,8 @@ def _panel_make_layout(self): if label == "quality": frozen_columns.append(label) data["channel_id"] = [] - data["sparsity"] = [] self.main_cols = list(data.keys()) - sparsity_mask = self.controller.get_sparsity_mask() for unit_index, unit_id in enumerate(unit_ids): data["unit_id"].append( {"id": str(unit_id), "color": mcolors.to_hex(self.controller.get_unit_color(unit_id))} @@ -487,9 +484,6 @@ def _panel_make_layout(self): data["channel_id"].append( self.controller.channel_ids[self.controller.get_extremum_channel(unit_id)] ) - data["sparsity"].append( - np.sum(sparsity_mask[unit_index, :]) - ) for col in self.controller.displayed_unit_properties: data[col] = self.controller.units_table[col] @@ -564,6 +558,7 @@ def _panel_make_layout(self): if self.controller.has_default_quality_labels: shortcuts.extend( [ + KeyboardShortcut(name="clear", key="c", ctrlKey=False), KeyboardShortcut(name="good", key="g", ctrlKey=False), KeyboardShortcut(name="mua", key="m", ctrlKey=False), KeyboardShortcut(name="noise", key="n", ctrlKey=False), @@ -767,6 +762,12 @@ def _panel_handle_shortcut(self, event): self.controller.set_visible_unit_ids(selected_unit_ids) self.notify_unit_visibility_changed() self.refresh() + elif event.data == "clear": + for unit_id in selected_unit_ids: + self.controller.set_label_to_unit(unit_id, "quality", None) + self.table.value.loc[selected_unit_ids, "quality"] = "" + self.notify_manual_curation_updated() + self.refresh() elif event.data == "good": for unit_id in selected_unit_ids: self.controller.set_label_to_unit(unit_id, "quality", "good") @@ -800,6 +801,7 @@ def _panel_handle_shortcut(self, event): * **ctrl + arrow up/down** : select next/previous unit and make it visible alone * **press 'ctrl+d'** : delete selected units (if curation=True) * **press 'ctrl+m'** : merge selected units (if curation=True) +* **press 'c'** : clear label of selected units (if curation=True) * **press 'g'** : label selected units as good (if curation=True) * **press 'm'** : label selected units as mua (if curation=True) * **press 'n'** : label selected units as noise (if curation=True) diff --git a/spikeinterface_gui/waveformheatmapview.py b/spikeinterface_gui/waveformheatmapview.py index 7ea52055..b86d2152 100644 --- a/spikeinterface_gui/waveformheatmapview.py +++ b/spikeinterface_gui/waveformheatmapview.py @@ -11,14 +11,14 @@ class WaveformHeatMapView(ViewBase): id = "waveformheatmap" _supported_backend = ['qt', 'panel'] _settings = [ - {'name': 'colormap', 'type': 'list', 'limits' : ['hot', 'viridis', 'jet', 'gray', ] }, - {'name': 'show_channel_id', 'type': 'bool', 'value': True}, - #~ {'name': 'data', 'type': 'list', 'limits' : ['waveforms', 'features', ] }, - {'name': 'bin_min', 'type': 'float', 'value' : -20. }, - {'name': 'bin_max', 'type': 'float', 'value' : 8. }, - {'name': 'bin_size', 'type': 'float', 'value' : .1 }, - {'name': 'max_unit', 'type': 'int', 'value' : 4 }, - ] + {'name': 'colormap', 'type': 'list', 'limits' : ['hot', 'viridis', 'jet', 'gray', ] }, + {'name': 'show_channel_id', 'type': 'bool', 'value': True}, + #~ {'name': 'data', 'type': 'list', 'limits' : ['waveforms', 'features', ] }, + {'name': 'bin_min', 'type': 'float', 'value' : -20. }, + {'name': 'bin_max', 'type': 'float', 'value' : 8. }, + {'name': 'bin_size', 'type': 'float', 'value' : .1 }, + {'name': 'max_unit', 'type': 'int', 'value' : 4 }, + ] _depend_on = ['waveforms'] From 405529b14e9d9db6a8633ad49b86015fda54e48c Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Tue, 24 Feb 2026 14:27:13 +0100 Subject: [PATCH 2/3] Add 'num_chan' column to units_table --- spikeinterface_gui/controller.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spikeinterface_gui/controller.py b/spikeinterface_gui/controller.py index 04f62505..3b18368a 100644 --- a/spikeinterface_gui/controller.py +++ b/spikeinterface_gui/controller.py @@ -326,6 +326,13 @@ def __init__( self._traces_cached = {} self.units_table = make_units_table_from_analyzer(analyzer, extra_properties=extra_unit_properties) + # add num_chan column as first column + num_chan = np.sum(self.get_sparsity_mask(), axis=1) + self.units_table.loc[:, 'num_chan'] = num_chan + cols = self.units_table.columns.tolist() + cols = ['num_chan'] + [c for c in cols if c != 'num_chan'] + self.units_table = self.units_table[cols] + if displayed_unit_properties is None: displayed_unit_properties = list(_default_displayed_unit_properties) if extra_unit_properties is not None: From a8b6b2e90e75e20b3ad21be8d85d446df25100ea Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 27 Feb 2026 10:49:20 +0100 Subject: [PATCH 3/3] Apply suggestion from @alejoe91 --- spikeinterface_gui/controller.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spikeinterface_gui/controller.py b/spikeinterface_gui/controller.py index 3b18368a..955cf57f 100644 --- a/spikeinterface_gui/controller.py +++ b/spikeinterface_gui/controller.py @@ -326,12 +326,6 @@ def __init__( self._traces_cached = {} self.units_table = make_units_table_from_analyzer(analyzer, extra_properties=extra_unit_properties) - # add num_chan column as first column - num_chan = np.sum(self.get_sparsity_mask(), axis=1) - self.units_table.loc[:, 'num_chan'] = num_chan - cols = self.units_table.columns.tolist() - cols = ['num_chan'] + [c for c in cols if c != 'num_chan'] - self.units_table = self.units_table[cols] if displayed_unit_properties is None: displayed_unit_properties = list(_default_displayed_unit_properties)