Skip to content

Commit ed4802e

Browse files
committed
Fix tracemapview for multishank
1 parent fccfee1 commit ed4802e

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

spikeinterface_gui/controller.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,12 @@ def get_traces(self, trace_source='preprocessed', **kargs):
706706
def get_contact_location(self):
707707
location = self.analyzer.get_channel_locations()
708708
return location
709+
710+
def get_channel_groups(self):
711+
if self.has_extension("recording"):
712+
return self.analyzer.recording.get_channel_groups()
713+
else:
714+
return np.zeros(self.analyzer.get_num_channels(), dtype=int)
709715

710716
def get_waveform_sweep(self):
711717
return self.nbefore, self.nafter
@@ -717,7 +723,7 @@ def get_waveforms(self, unit_id):
717723
wfs = self.waveforms_ext.get_waveforms_one_unit(unit_id, force_dense=False)
718724
if self.analyzer.sparsity is None:
719725
# dense waveforms
720-
chan_inds = np.arange(self.analyzer.recording.get_num_channels(), dtype='int64')
726+
chan_inds = np.arange(self.analyzer.get_num_channels(), dtype='int64')
721727
else:
722728
# sparse waveforms
723729
chan_inds = self.analyzer.sparsity.unit_id_to_channel_indices[unit_id]

spikeinterface_gui/tracemapview.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ class TraceMapView(ViewBase, MixinViewTrace):
2424

2525
def __init__(self, controller=None, parent=None, backend="qt"):
2626
pos = controller.get_contact_location()
27-
self.channel_order = np.lexsort((-pos[:, 0], pos[:, 1], ))
27+
channel_groups = controller.get_channel_groups()
28+
self.channel_order = np.lexsort((-pos[:, 0], pos[:, 1], channel_groups))
2829
self.channel_order_reverse = np.argsort(self.channel_order, kind="stable")
30+
if len(channel_groups) > 1:
31+
self.chan_group_offsets, = np.nonzero(np.diff(np.sort(channel_groups)))
32+
self.chan_group_offsets = self.chan_group_offsets + 1
33+
else:
34+
self.chan_group_offsets = None
2935
self.color_limit = None
3036
self.last_data_curves = None
3137
self.factor = None
@@ -163,6 +169,11 @@ def _qt_seek(self, t):
163169
self.plot.setXRange(t1, t2, padding=0.0)
164170
self.plot.setYRange(0, num_chans, padding=0.0)
165171

172+
if self.chan_group_offsets is not None:
173+
for ch in self.chan_group_offsets:
174+
hline = pg.InfiniteLine(pos=ch, angle=0, movable=False, pen=pg.mkPen("y"))
175+
self.plot.addItem(hline)
176+
166177
def _qt_on_time_info_updated(self):
167178
# Update segment and time slider range
168179
time, segment_index = self.controller.get_time()
@@ -224,7 +235,7 @@ def _panel_make_layout(self):
224235
self.figure.xaxis.major_tick_line_color = "white"
225236
self.figure.yaxis.visible = False
226237
self.figure.x_range = Range1d(start=0, end=0.5)
227-
self.figure.y_range = Range1d(start=0, end=1)
238+
self.figure.y_range = Range1d(start=0, end=self.controller.num_channels)
228239

229240

230241
# Add data sources
@@ -245,6 +256,9 @@ def _panel_make_layout(self):
245256
x="x", y="y", size=10, fill_color="color", fill_alpha=self.settings['alpha'], source=self.spike_source
246257
)
247258

259+
if self.chan_group_offsets is not None:
260+
self.figure.hspan(y=list(self.chan_group_offsets), line_color="yellow")
261+
248262
# # Add hover tool for spikes
249263
# hover_spikes = HoverTool(renderers=[self.spike_renderer], tooltips=[("Unit", "@unit_id")])
250264
# self.figure.add_tools(hover_spikes)

spikeinterface_gui/waveformview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ def _panel_clear_scalebars(self):
939939
self.scalebar_labels = []
940940

941941
def _panel_add_scalebars(self):
942-
from bokeh.models import Span, Label
942+
from bokeh.models import Label
943943

944944
if not self.settings["x_scalebar"] and not self.settings["y_scalebar"]:
945945
return

0 commit comments

Comments
 (0)