Skip to content

Commit f383468

Browse files
committed
Merge branch 'main' of github.com:SpikeInterface/spikeinterface-gui into busy-indicator
2 parents b4c6d99 + 38d3bc4 commit f383468

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

spikeinterface_gui/waveformview.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,20 @@ def __init__(self, controller=None, parent=None, backend="qt"):
3535
self.contact_location = self.controller.get_contact_location().copy()
3636
xpos = self.contact_location[:,0]
3737
ypos = self.contact_location[:,1]
38-
unique_x = np.sort(np.unique(np.round(xpos)))
39-
if unique_x.size>1:
40-
self.delta_x = np.min(np.diff(unique_x))
38+
39+
# copied directly from spikeinterface.widgets.unit_waveform
40+
manh = np.abs(
41+
self.contact_location[None, :] - self.contact_location[:, None]
42+
) # vertical and horizontal distances between each channel
43+
eucl = np.linalg.norm(manh, axis=2) # Euclidean distance matrix
44+
np.fill_diagonal(eucl, np.inf) # the distance of a channel to itself is not considered
45+
gaus = np.exp(-0.5 * (eucl / eucl.min()) ** 2) # sigma uses the min distance between channels
46+
weight = manh[..., 0] / eucl * gaus
47+
if weight.sum() == 0:
48+
self.delta_x = 10
4149
else:
42-
self.delta_x = 40. # um
50+
self.delta_x = (manh[..., 0] * weight).sum() / weight.sum()
51+
4352
unique_y = np.sort(np.unique(np.round(ypos)))
4453
if unique_y.size>1:
4554
self.delta_y = np.min(np.diff(unique_y))

0 commit comments

Comments
 (0)