Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions spikeinterface_gui/mergeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def _qt_make_layout(self):

def _qt_refresh(self):
from .myqt import QT
from .utils_qt import CustomItem
from .utils_qt import CustomItem, CustomItemUnitID

self.table.clear()
self.table.setSortingEnabled(False)
Expand All @@ -287,6 +287,7 @@ def _qt_refresh(self):
self.table.setColumnCount(len(labels))
self.table.setHorizontalHeaderLabels(labels)
self.table.setRowCount(len(rows))
unit_ids = self.controller.unit_ids

for r, row in enumerate(rows):
for c, label in enumerate(labels):
Expand All @@ -298,7 +299,7 @@ def _qt_refresh(self):
pix = QT.QPixmap(16, 16)
pix.fill(color)
icon = QT.QIcon(pix)
item = QT.QTableWidgetItem(name)
item = CustomItemUnitID(unit_ids, name)
item.setData(QT.Qt.ItemDataRole.UserRole, unit_id)
item.setFlags(QT.Qt.ItemIsEnabled | QT.Qt.ItemIsSelectable)
self.table.setItem(r, c, item)
Expand Down
8 changes: 6 additions & 2 deletions spikeinterface_gui/utils_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,14 @@ def __init__(self, unit_ids, *args, **kwargs):
self.unit_ids = [f"{u}" for u in unit_ids]

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


class OrderableCheckItem(QT.QTableWidgetItem):
# special case for checkbox
def is_checked(self):
Expand Down