diff --git a/src/spikeinterface/core/sortinganalyzer.py b/src/spikeinterface/core/sortinganalyzer.py index 9edb527879..170be9bd86 100644 --- a/src/spikeinterface/core/sortinganalyzer.py +++ b/src/spikeinterface/core/sortinganalyzer.py @@ -968,7 +968,13 @@ def compute_several_extensions(self, extensions, save=True, **job_kwargs): extensions_with_pipeline = {} extensions_without_pipeline = {} + extensions_post_pipeline = {} for extension_name, extension_params in extensions.items(): + if extension_name == "quality_metrics": + # PATCH: the quality metric is computed after the pipeline, since some of the metrics optionally require + # the output of the pipeline extensions (e.g., spike_amplitudes, spike_locations). + extensions_post_pipeline[extension_name] = extension_params + continue extension_class = get_extension_class(extension_name) if extension_class.use_nodepipeline: extensions_with_pipeline[extension_name] = extension_params @@ -1020,6 +1026,17 @@ def compute_several_extensions(self, extensions, save=True, **job_kwargs): if save: extension_instance.save() + # PATCH: the quality metric is computed after the pipeline, since some of the metrics optionally require + # the output of the pipeline extensions (e.g., spike_amplitudes, spike_locations). + # An alternative could be to extend the "depend_on" attribute to use optional and to check if an extension + # depends on the output of the pipeline nodes (e.g. depend_on=["spike_amplitudes[optional]"]) + for extension_name, extension_params in extensions_post_pipeline.items(): + extension_class = get_extension_class(extension_name) + if extension_class.need_job_kwargs: + self.compute_one_extension(extension_name, save=save, **extension_params, **job_kwargs) + else: + self.compute_one_extension(extension_name, save=save, **extension_params) + def get_saved_extension_names(self): """ Get extension names saved in folder or zarr that can be loaded. @@ -1173,7 +1190,7 @@ def _get_children_dependencies(extension_name): This function is making the reverse way : get all children that depend of a particular extension. - This is recurssive so this includes : children and so grand children and grand grand children + This is recursive so this includes : children and so grand children and great grand children This function is usefull for deleting on recompute. For instance recompute the "waveforms" need to delete "template"