Skip to content

Commit 1263de6

Browse files
authored
Remove default num_chan (sparsity) column and add 'clear' label shortcut (#244)
* Remove sparsity column and add 'clear' label shortcut * Add 'num_chan' column to units_table * Apply suggestion from @alejoe91
1 parent f552464 commit 1263de6

3 files changed

Lines changed: 22 additions & 19 deletions

File tree

spikeinterface_gui/controller.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ def __init__(
326326
self._traces_cached = {}
327327

328328
self.units_table = make_units_table_from_analyzer(analyzer, extra_properties=extra_unit_properties)
329+
329330
if displayed_unit_properties is None:
330331
displayed_unit_properties = list(_default_displayed_unit_properties)
331332
if extra_unit_properties is not None:

spikeinterface_gui/unitlistview.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ def _qt_make_layout(self):
105105
self.shortcut_mua = None
106106
self.shortcut_noise = None
107107
if self.controller.has_default_quality_labels:
108+
self.shortcut_clear = QT.QShortcut(self.qt_widget)
109+
self.shortcut_clear.setKey(QT.QKeySequence('c'))
110+
self.shortcut_clear.activated.connect(lambda: self._qt_set_default_label(None))
111+
108112
self.shortcut_good = QT.QShortcut(self.qt_widget)
109113
self.shortcut_good.setKey(QT.QKeySequence('g'))
110114
self.shortcut_good.activated.connect(lambda: self._qt_set_default_label('good'))
@@ -212,7 +216,7 @@ def _qt_full_table_refresh(self):
212216
self.table.clear()
213217

214218

215-
internal_column_names = ['unit_id', 'visible', 'channel_id', 'sparsity']
219+
internal_column_names = ['unit_id', 'visible', 'channel_id']
216220

217221
# internal labels
218222
column_labels = list(internal_column_names)
@@ -272,11 +276,6 @@ def _qt_full_table_refresh(self):
272276
item = CustomItem(f'{channel_id}')
273277
item.setFlags(QT.Qt.ItemIsEnabled|QT.Qt.ItemIsSelectable)
274278
self.table.setItem(i, 2, item)
275-
276-
num_chan = np.sum(self.controller.get_sparsity_mask()[i, :])
277-
item = CustomItem(f'{num_chan}')
278-
item.setFlags(QT.Qt.ItemIsEnabled|QT.Qt.ItemIsSelectable)
279-
self.table.setItem(i, 3, item)
280279

281280
n_first = len(internal_column_names)
282281
self.label_columns = list(range(n_first, n_first + num_labels))
@@ -476,20 +475,15 @@ def _panel_make_layout(self):
476475
if label == "quality":
477476
frozen_columns.append(label)
478477
data["channel_id"] = []
479-
data["sparsity"] = []
480478

481479
self.main_cols = list(data.keys())
482-
sparsity_mask = self.controller.get_sparsity_mask()
483480
for unit_index, unit_id in enumerate(unit_ids):
484481
data["unit_id"].append(
485482
{"id": str(unit_id), "color": mcolors.to_hex(self.controller.get_unit_color(unit_id))}
486483
)
487484
data["channel_id"].append(
488485
self.controller.channel_ids[self.controller.get_extremum_channel(unit_id)]
489486
)
490-
data["sparsity"].append(
491-
np.sum(sparsity_mask[unit_index, :])
492-
)
493487
for col in self.controller.displayed_unit_properties:
494488
data[col] = self.controller.units_table[col]
495489

@@ -563,6 +557,7 @@ def _panel_make_layout(self):
563557
if self.controller.has_default_quality_labels:
564558
shortcuts.extend(
565559
[
560+
KeyboardShortcut(name="clear", key="c", ctrlKey=False),
566561
KeyboardShortcut(name="good", key="g", ctrlKey=False),
567562
KeyboardShortcut(name="mua", key="m", ctrlKey=False),
568563
KeyboardShortcut(name="noise", key="n", ctrlKey=False),
@@ -772,6 +767,12 @@ def _panel_handle_shortcut(self, event):
772767
self.controller.set_visible_unit_ids(selected_unit_ids)
773768
self.notify_unit_visibility_changed()
774769
self.refresh()
770+
elif event.data == "clear":
771+
for unit_id in selected_unit_ids:
772+
self.controller.set_label_to_unit(unit_id, "quality", None)
773+
self.table.value.loc[selected_unit_ids, "quality"] = ""
774+
self.notify_manual_curation_updated()
775+
self.refresh()
775776
elif event.data == "good":
776777
for unit_id in selected_unit_ids:
777778
self.controller.set_label_to_unit(unit_id, "quality", "good")
@@ -805,6 +806,7 @@ def _panel_handle_shortcut(self, event):
805806
* **ctrl + arrow up/down** : select next/previous unit and make it visible alone
806807
* **press 'ctrl+d'** : delete selected units (if curation=True)
807808
* **press 'ctrl+m'** : merge selected units (if curation=True)
809+
* **press 'c'** : clear label of selected units (if curation=True)
808810
* **press 'g'** : label selected units as good (if curation=True)
809811
* **press 'm'** : label selected units as mua (if curation=True)
810812
* **press 'n'** : label selected units as noise (if curation=True)

spikeinterface_gui/waveformheatmapview.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class WaveformHeatMapView(ViewBase):
1111
id = "waveformheatmap"
1212
_supported_backend = ['qt', 'panel']
1313
_settings = [
14-
{'name': 'colormap', 'type': 'list', 'limits' : ['hot', 'viridis', 'jet', 'gray', ] },
15-
{'name': 'show_channel_id', 'type': 'bool', 'value': True},
16-
#~ {'name': 'data', 'type': 'list', 'limits' : ['waveforms', 'features', ] },
17-
{'name': 'bin_min', 'type': 'float', 'value' : -20. },
18-
{'name': 'bin_max', 'type': 'float', 'value' : 8. },
19-
{'name': 'bin_size', 'type': 'float', 'value' : .1 },
20-
{'name': 'max_unit', 'type': 'int', 'value' : 4 },
21-
]
14+
{'name': 'colormap', 'type': 'list', 'limits' : ['hot', 'viridis', 'jet', 'gray', ] },
15+
{'name': 'show_channel_id', 'type': 'bool', 'value': True},
16+
#~ {'name': 'data', 'type': 'list', 'limits' : ['waveforms', 'features', ] },
17+
{'name': 'bin_min', 'type': 'float', 'value' : -20. },
18+
{'name': 'bin_max', 'type': 'float', 'value' : 8. },
19+
{'name': 'bin_size', 'type': 'float', 'value' : .1 },
20+
{'name': 'max_unit', 'type': 'int', 'value' : 4 },
21+
]
2222

2323
_depend_on = ['waveforms']
2424

0 commit comments

Comments
 (0)