Skip to content

Commit 12a1276

Browse files
authored
Merge pull request #3478 from chrishalcrow/fix_tm_check
Only load `template_metrics` extension on compute if keeping some metrics
2 parents f5a50c8 + cedabd9 commit 12a1276

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/spikeinterface/core/sortinganalyzer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,19 +2033,18 @@ def load(cls, sorting_analyzer):
20332033
return None
20342034

20352035
def load_run_info(self):
2036+
run_info = None
20362037
if self.format == "binary_folder":
20372038
extension_folder = self._get_binary_extension_folder()
20382039
run_info_file = extension_folder / "run_info.json"
20392040
if run_info_file.is_file():
20402041
with open(str(run_info_file), "r") as f:
20412042
run_info = json.load(f)
2042-
else:
2043-
warnings.warn(f"Found no run_info file for {self.extension_name}, extension should be re-computed.")
2044-
run_info = None
20452043

20462044
elif self.format == "zarr":
20472045
extension_group = self._get_zarr_extension_group(mode="r")
20482046
run_info = extension_group.attrs.get("run_info", None)
2047+
20492048
if run_info is None:
20502049
warnings.warn(f"Found no run_info file for {self.extension_name}, extension should be re-computed.")
20512050
self.run_info = run_info

src/spikeinterface/postprocessing/template_metrics.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,18 @@ def _run(self, verbose=False):
327327
)
328328

329329
existing_metrics = []
330-
tm_extension = self.sorting_analyzer.get_extension("template_metrics")
331-
if (
332-
delete_existing_metrics is False
333-
and tm_extension is not None
334-
and tm_extension.data.get("metrics") is not None
335-
):
336-
existing_metrics = tm_extension.params["metric_names"]
330+
331+
# Check if we need to propogate any old metrics. If so, we'll do that.
332+
# Otherwise, we'll avoid attempting to load an empty template_metrics.
333+
if set(self.params["metrics_to_compute"]) != set(self.params["metric_names"]):
334+
335+
tm_extension = self.sorting_analyzer.get_extension("template_metrics")
336+
if (
337+
delete_existing_metrics is False
338+
and tm_extension is not None
339+
and tm_extension.data.get("metrics") is not None
340+
):
341+
existing_metrics = tm_extension.params["metric_names"]
337342

338343
existing_metrics = []
339344
# here we get in the loaded via the dict only (to avoid full loading from disk after params reset)

0 commit comments

Comments
 (0)