Skip to content

Commit 26882bf

Browse files
authored
Merge pull request #248 from alejoe91/fix-traces-multi-shank
Fix tracemapview for multishank
2 parents 86c3b4c + 30db38a commit 26882bf

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
@@ -693,6 +693,12 @@ def get_traces(self, trace_source='preprocessed', **kargs):
693693
def get_contact_location(self):
694694
location = self.analyzer.get_channel_locations()
695695
return location
696+
697+
def get_channel_groups(self):
698+
if self.has_extension("recording"):
699+
return self.analyzer.recording.get_channel_groups()
700+
else:
701+
return np.zeros(self.analyzer.get_num_channels(), dtype=int)
696702

697703
def get_waveform_sweep(self):
698704
return self.nbefore, self.nafter
@@ -704,7 +710,7 @@ def get_waveforms(self, unit_id):
704710
wfs = self.waveforms_ext.get_waveforms_one_unit(unit_id, force_dense=False)
705711
if self.analyzer.sparsity is None:
706712
# dense waveforms
707-
chan_inds = np.arange(self.analyzer.recording.get_num_channels(), dtype='int64')
713+
chan_inds = np.arange(self.analyzer.get_num_channels(), dtype='int64')
708714
else:
709715
# sparse waveforms
710716
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(np.unique(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("black"))
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
@@ -945,7 +945,7 @@ def _panel_clear_scalebars(self):
945945
self.scalebar_lines_source.data = dict(xs=[], ys=[], colors=[])
946946

947947
def _panel_add_scalebars(self):
948-
from bokeh.models import Span, Label
948+
from bokeh.models import Label
949949

950950
if not self.settings["x_scalebar"] and not self.settings["y_scalebar"]:
951951
return

0 commit comments

Comments
 (0)