Skip to content

Commit 2355487

Browse files
committed
Explose alpha as param
1 parent 970c64c commit 2355487

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

spikeinterface_gui/waveformview.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class WaveformView(ViewBase):
2121
"value": False,
2222
}, # true here can be very slow because it loads traces
2323
{"name": "plot_waveforms_samples", "type": "bool", "value": False},
24+
{"name": "waveforms_alpha", "type": "float", "value": 0.3},
2425
{"name": "num_waveforms", "type": "int", "value": 20},
2526
{"name": "auto_zoom_on_unit_selection", "type": "bool", "value": False},
2627
{"name": "auto_move_on_unit_selection", "type": "bool", "value": True},
@@ -566,7 +567,8 @@ def _qt_refresh_with_spikes(self):
566567
for i, (unit_id, waveforms) in enumerate(unit_waveforms_data):
567568
color = self.get_unit_color(unit_id)
568569
color_with_alpha = QT.QColor(color)
569-
color_with_alpha.setAlpha(int(0.3 * 255)) # 30% alpha
570+
alpha = self.settings["waveforms_alpha"]
571+
color_with_alpha.setAlpha(int(alpha * 255)) # 30% alpha
570572

571573
# Get the x-vector for this specific unit (handles overlap setting)
572574
unit_xvect = xvects[i]
@@ -736,7 +738,8 @@ def _plot_waveforms_for_unit(self, waveforms, color, width, common_channel_index
736738
all_y = np.array(all_y)
737739
all_connect = np.array(all_connect, dtype="bool")
738740

739-
curve = pg.PlotCurveItem(all_x, all_y, pen=pg.mkPen(color, width=1), connect=all_connect)
741+
alpha = self.settings["waveforms_alpha"]
742+
curve = pg.PlotCurveItem(all_x, all_y, pen=pg.mkPen(color, width=1, alpha=int(alpha * 255)), connect=all_connect)
740743
self.plot1.addItem(curve)
741744
self.curve_waveforms_samples.append(curve)
742745

@@ -1255,6 +1258,8 @@ def _panel_plot_waveforms_for_unit(self, waveforms, color, width, common_channel
12551258
if n_waveforms == 0:
12561259
return
12571260

1261+
alpha = self.settings["waveforms_alpha"]
1262+
12581263
if self.mode == "flatten":
12591264
# For flatten mode, plot all waveforms as continuous lines
12601265
all_x = []
@@ -1269,7 +1274,7 @@ def _panel_plot_waveforms_for_unit(self, waveforms, color, width, common_channel
12691274
all_y.append(None)
12701275

12711276
line = self.figure_avg.line(
1272-
"x", "y", source=dict(x=all_x, y=all_y), line_color=color, line_width=1, alpha=0.7
1277+
"x", "y", source=dict(x=all_x, y=all_y), line_color=color, line_width=1, alpha=alpha
12731278
)
12741279
self.lines_waveforms_samples.append(line)
12751280

@@ -1291,7 +1296,7 @@ def _panel_plot_waveforms_for_unit(self, waveforms, color, width, common_channel
12911296
all_y.extend(wf_plot.T.flatten().tolist())
12921297

12931298
line = self.figure_geom.line(
1294-
"x", "y", source=dict(x=all_x, y=all_y), line_color=color, line_width=1, alpha=0.7
1299+
"x", "y", source=dict(x=all_x, y=all_y), line_color=color, line_width=1, alpha=alpha
12951300
)
12961301
self.lines_waveforms_samples.append(line)
12971302

0 commit comments

Comments
 (0)