File tree Expand file tree Collapse file tree
src/spikeinterface/metrics/template Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,6 +176,18 @@ def _handle_backward_compatibility_on_load(self):
176176 if "peaks_data" not in self .data :
177177 self .tmp_data_to_save = []
178178
179+ # We used to use whichever `template_operator` was available in the template computation, but now the user
180+ # can specify. Default to "average" unless the only computed templates were computed with median.
181+ if "template_operator" not in self .params :
182+ self .params ["template_operator" ] = "average"
183+ if self .sorting_analyzer .has_extension ("templates" ):
184+ available_template_keys = self .sorting_analyzer .get_extension ("templates" ).data .keys ()
185+ template_keys_which_are_operators = [
186+ key for key in available_template_keys if key in ["average" , "median" ]
187+ ]
188+ if len (template_keys_which_are_operators ) == 1 :
189+ self .params ["template_operator" ] = template_keys_which_are_operators [0 ]
190+
179191 def _set_params (
180192 self ,
181193 metric_names : list [str ] | None = None ,
You can’t perform that action at this time.
0 commit comments