Remove waveform_extractor.recording form template_tools
import numpy as np
import numpy.lib.recfunctions as rfn
+import scipy.spatial.distance
+
from ..core import get_channel_distances, get_noise_levels
@@ -82,7 +84,7 @@ def get_template_extremum_channel(waveform_extractor, peak_sign: str = "neg", mo
assert outputs in ("id", "index")
unit_ids = waveform_extractor.sorting.unit_ids
- channel_ids = waveform_extractor.recording.channel_ids
+ channel_ids = waveform_extractor.channel_ids
peak_values = get_template_amplitudes(waveform_extractor, peak_sign=peak_sign, mode=mode)
extremum_channels_id = {}
@@ -163,7 +165,8 @@ def get_template_channel_sparsity(
elif method == "radius":
assert radius_um is not None
best_chan = get_template_extremum_channel(we, outputs="index")
- distances = get_channel_distances(we.recording)
+ locations = we.get_channel_locations()
+ distances = scipy.spatial.distance.cdist(locations, locations)
for unit_id in unit_ids:
chan_ind = best_chan[unit_id]
(chan_inds,) = np.nonzero(distances[chan_ind, :] <= radius_um)
