Use enumerate
@@ -59,7 +59,7 @@ class TemplateMetricsCalculator(BaseWaveformExtractorExtension):
peak_sign = self._params['peak_sign']
upsampling_factor = self._params['upsampling_factor']
unit_ids = self.waveform_extractor.sorting.unit_ids
- sampling_frequency = self.waveform_extractor.recording.get_sampling_frequency()
+ sampling_frequency = self.waveform_extractor.sampling_frequency
if sparsity is None:
extremum_channels_ids = get_template_extremum_channel(self.waveform_extractor,
@@ -81,8 +81,7 @@ class TemplateMetricsCalculator(BaseWaveformExtractorExtension):
index=multi_index, columns=metric_names)
all_templates = self.waveform_extractor.get_all_templates()
- for unit_id in unit_ids:
- unit_index = self.waveform_extractor.sorting.id_to_index(unit_id)
+ for unit_index, unit_id in enumerate(unit_ids):
template_all_chans = all_templates[unit_index]
chan_ids = np.array(extremum_channels_ids[unit_id])
if chan_ids.ndim == 0:
