Skip to content

Commit 7d2e45b

Browse files
committed
set vel to nan rather than inf
1 parent 0ef443f commit 7d2e45b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/spikeinterface/metrics/template/metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ def get_velocity_fits(template, channel_locations, sampling_frequency, **kwargs)
361361
peak_times_ms_above = np.argmin(template_above, 0) / sampling_frequency * 1000 - max_peak_time
362362
distances_um_above = np.array([np.linalg.norm(cl - max_channel_location) for cl in channel_locations_above])
363363
inv_velocity_above, score = fit_line_robust(distances_um_above, peak_times_ms_above)
364-
if score > min_r2:
365-
velocity_above = 1 / inv_velocity_above if np.abs(inv_velocity_above) > 1e-9 else np.inf
364+
if score > min_r2 and np.abs(inv_velocity_above) > 1e-9:
365+
velocity_above = 1 / inv_velocity_above
366366
else:
367367
velocity_above = np.nan
368368

@@ -376,8 +376,8 @@ def get_velocity_fits(template, channel_locations, sampling_frequency, **kwargs)
376376
peak_times_ms_below = np.argmin(template_below, 0) / sampling_frequency * 1000 - max_peak_time
377377
distances_um_below = np.array([np.linalg.norm(cl - max_channel_location) for cl in channel_locations_below])
378378
inv_velocity_below, score = fit_line_robust(distances_um_below, peak_times_ms_below)
379-
if score > min_r2:
380-
velocity_below = 1 / inv_velocity_below if np.abs(inv_velocity_below) > 1e-9 else np.inf
379+
if score > min_r2 and np.abs(inv_velocity_below) > 1e-9:
380+
velocity_below = 1 / inv_velocity_below
381381
else:
382382
velocity_below = np.nan
383383

0 commit comments

Comments
 (0)