Skip to content

Commit 90f3e05

Browse files
committed
merge with main
2 parents ca137a5 + 38d3bc4 commit 90f3e05

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

spikeinterface_gui/waveformview.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,22 @@ def __init__(self, controller=None, parent=None, backend="qt"):
4444
num_chan = len(self.controller.channel_ids)
4545
self.xvect = np.zeros((num_chan, width), dtype="float32")
4646
self.contact_location = self.controller.get_contact_location().copy()
47-
xpos = self.contact_location[:, 0]
48-
ypos = self.contact_location[:, 1]
49-
unique_x = np.sort(np.unique(np.round(xpos)))
50-
if unique_x.size > 1:
51-
self.delta_x = np.min(np.diff(unique_x))
47+
xpos = self.contact_location[:,0]
48+
ypos = self.contact_location[:,1]
49+
50+
# copied directly from spikeinterface.widgets.unit_waveform
51+
manh = np.abs(
52+
self.contact_location[None, :] - self.contact_location[:, None]
53+
) # vertical and horizontal distances between each channel
54+
eucl = np.linalg.norm(manh, axis=2) # Euclidean distance matrix
55+
np.fill_diagonal(eucl, np.inf) # the distance of a channel to itself is not considered
56+
gaus = np.exp(-0.5 * (eucl / eucl.min()) ** 2) # sigma uses the min distance between channels
57+
weight = manh[..., 0] / eucl * gaus
58+
if weight.sum() == 0:
59+
self.delta_x = 10
5260
else:
53-
self.delta_x = 40.0 # um
61+
self.delta_x = (manh[..., 0] * weight).sum() / weight.sum()
62+
5463
unique_y = np.sort(np.unique(np.round(ypos)))
5564
if unique_y.size > 1:
5665
self.delta_y = np.min(np.diff(unique_y))

0 commit comments

Comments
 (0)