From 1411c6fdf9d89c68a205c1512b1dce9ce2a29c62 Mon Sep 17 00:00:00 2001 From: OlivierPeron <79974181+OlivierPeron@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:59:20 +0200 Subject: [PATCH 1/2] Loading templates Loading templates whatever the operator --- src/spikeinterface/core/template_tools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/spikeinterface/core/template_tools.py b/src/spikeinterface/core/template_tools.py index 934b18ed49..769610ad2b 100644 --- a/src/spikeinterface/core/template_tools.py +++ b/src/spikeinterface/core/template_tools.py @@ -31,7 +31,8 @@ def get_dense_templates_array(one_object: Templates | SortingAnalyzer, return_sc ) ext = one_object.get_extension("templates") if ext is not None: - templates_array = ext.data["average"] + templates_array = ext.data.get("average") or ext.data.get("median") + assert templates_array is not None, "Average or median templates have not been computed." else: raise ValueError("SortingAnalyzer need extension 'templates' to be computed to retrieve templates") else: From 72357a68a25acc58c6634300d574e056a1e46857 Mon Sep 17 00:00:00 2001 From: OlivierPeron <79974181+OlivierPeron@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:22:52 +0200 Subject: [PATCH 2/2] Update src/spikeinterface/core/template_tools.py Co-authored-by: Alessio Buccino --- src/spikeinterface/core/template_tools.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/spikeinterface/core/template_tools.py b/src/spikeinterface/core/template_tools.py index 769610ad2b..3c8663df70 100644 --- a/src/spikeinterface/core/template_tools.py +++ b/src/spikeinterface/core/template_tools.py @@ -31,8 +31,12 @@ def get_dense_templates_array(one_object: Templates | SortingAnalyzer, return_sc ) ext = one_object.get_extension("templates") if ext is not None: - templates_array = ext.data.get("average") or ext.data.get("median") - assert templates_array is not None, "Average or median templates have not been computed." + if "average" in ext.data: + templates_array = ext.data.get("average") + elif "median" in ext.data: + templates_array = ext.data.get("median") + else: + raise ValueError("Average or median templates have not been computed.") else: raise ValueError("SortingAnalyzer need extension 'templates' to be computed to retrieve templates") else: