From 4e000ed041b11a9f2195691caf0bcb39bca4a500 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 6 Sep 2024 19:24:07 +0200 Subject: [PATCH] same for multi-channel --- .../postprocessing/template_metrics.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/spikeinterface/postprocessing/template_metrics.py b/src/spikeinterface/postprocessing/template_metrics.py index 9d21e56611..726ec49558 100644 --- a/src/spikeinterface/postprocessing/template_metrics.py +++ b/src/spikeinterface/postprocessing/template_metrics.py @@ -276,12 +276,16 @@ def _compute_metrics(self, sorting_analyzer, unit_ids=None, verbose=False, **job sampling_frequency_up = sampling_frequency func = _metric_name_to_func[metric_name] - value = func( - template_upsampled, - channel_locations=channel_locations_sparse, - sampling_frequency=sampling_frequency_up, - **self.params["metrics_kwargs"], - ) + try: + value = func( + template_upsampled, + channel_locations=channel_locations_sparse, + sampling_frequency=sampling_frequency_up, + **self.params["metrics_kwargs"], + ) + except Exception as e: + warnings.warn(f"Error computing metric {metric_name} for unit {unit_id}: {e}") + value = np.nan template_metrics.at[index, metric_name] = value return template_metrics