Skip to content

Commit a7048b9

Browse files
committed
Simpler fix: use existing CustomUnitIdItem
1 parent 97a2881 commit a7048b9

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

spikeinterface_gui/mergeview.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def _qt_refresh(self):
287287
self.table.setColumnCount(len(labels))
288288
self.table.setHorizontalHeaderLabels(labels)
289289
self.table.setRowCount(len(rows))
290+
unit_ids = self.controller.unit_ids
290291

291292
for r, row in enumerate(rows):
292293
for c, label in enumerate(labels):
@@ -298,7 +299,7 @@ def _qt_refresh(self):
298299
pix = QT.QPixmap(16, 16)
299300
pix.fill(color)
300301
icon = QT.QIcon(pix)
301-
item = CustomItemUnitID(name)
302+
item = CustomItemUnitID(unit_ids, name)
302303
item.setData(QT.Qt.ItemDataRole.UserRole, unit_id)
303304
item.setFlags(QT.Qt.ItemIsEnabled | QT.Qt.ItemIsSelectable)
304305
self.table.setItem(r, c, item)

spikeinterface_gui/utils_qt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,11 @@ def __init__(self, unit_ids, *args, **kwargs):
470470
self.unit_ids = [f"{u}" for u in unit_ids]
471471

472472
def __lt__(self, other):
473-
ind = self.unit_ids.index(self.text())
474-
other_ind = self.unit_ids.index(other.text())
473+
# since mergeview has "{unit_id} (n={n_spikes})" as name, we split and keep the first part
474+
unit_id = self.text().split(' ')[0]
475+
other_unit_id = other.text().split(' ')[0]
476+
ind = self.unit_ids.index(unit_id)
477+
other_ind = self.unit_ids.index(other_unit_id)
475478
return ind < other_ind
476479

477480

0 commit comments

Comments
 (0)