From 3dc57290dbde0aeaa5048f2301ee75015a93fe26 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Mon, 29 Dec 2025 15:43:44 +0100 Subject: [PATCH 1/3] Test IBL extractors tests failing for PI update --- src/spikeinterface/extractors/tests/test_iblextractors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spikeinterface/extractors/tests/test_iblextractors.py b/src/spikeinterface/extractors/tests/test_iblextractors.py index 972a8e7bb0..56d01e38cf 100644 --- a/src/spikeinterface/extractors/tests/test_iblextractors.py +++ b/src/spikeinterface/extractors/tests/test_iblextractors.py @@ -76,8 +76,8 @@ def test_offsets(self): def test_probe_representation(self): probe = self.recording.get_probe() - expected_probe_representation = "Probe - 384ch - 1shanks" - assert repr(probe) == expected_probe_representation + expected_probe_representation = "Probe - 384ch" + assert expected_probe_representation in repr(probe) def test_property_keys(self): expected_property_keys = [ From 1d6f831ebc7262e04b9ea7e012ee7c19dcc51adb Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Wed, 25 Mar 2026 11:53:30 +0100 Subject: [PATCH 2/3] Add 'zarr_class_info' field to read_zarr --- src/spikeinterface/core/zarrextractors.py | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/spikeinterface/core/zarrextractors.py b/src/spikeinterface/core/zarrextractors.py index e58ef4ee68..69df4f1115 100644 --- a/src/spikeinterface/core/zarrextractors.py +++ b/src/spikeinterface/core/zarrextractors.py @@ -8,7 +8,7 @@ from .base import minimum_spike_dtype from .baserecording import BaseRecording, BaseRecordingSegment from .basesorting import BaseSorting, SpikeVectorSortingSegment -from .core_tools import define_function_from_class, check_json +from .core_tools import define_function_from_class, check_json, retrieve_importing_provenance from .job_tools import split_job_kwargs from .core_tools import is_path_remote @@ -212,6 +212,7 @@ def write_recording( recording: BaseRecording, folder_path: str | Path, storage_options: dict | None = None, **kwargs ): zarr_root = zarr.open(str(folder_path), mode="w", storage_options=storage_options) + zarr_root.attrs["zarr_class_info"] = retrieve_importing_provenance(ZarrRecordingExtractor) add_recording_to_zarr_group(recording, zarr_root, **kwargs) @@ -320,6 +321,7 @@ def write_sorting(sorting: BaseSorting, folder_path: str | Path, storage_options Write a sorting extractor to zarr format. """ zarr_root = zarr.open(str(folder_path), mode="w", storage_options=storage_options) + zarr_root.attrs["zarr_class_info"] = retrieve_importing_provenance(ZarrSortingExtractor) add_sorting_to_zarr_group(sorting, zarr_root, **kwargs) @@ -345,15 +347,22 @@ def read_zarr( extractor : ZarrExtractor The loaded extractor """ - # TODO @alessio : we should have something more explicit in our zarr format to tell which object it is. - # for the futur SortingAnalyzer we will have this 2 fields!!! root = super_zarr_open(folder_path, mode="r", storage_options=storage_options) - if "channel_ids" in root.keys(): - return read_zarr_recording(folder_path, storage_options=storage_options) - elif "unit_ids" in root.keys(): - return read_zarr_sorting(folder_path, storage_options=storage_options) + zarr_class_info = root.attrs.get("zarr_class_info", None) + if zarr_class_info is not None: + class_name = zarr_class_info["class"] + extractor_class = _get_class_from_string(class_name) + return extractor_class(folder_path, storage_options=storage_options) else: - raise ValueError("Cannot find 'channel_ids' or 'unit_ids' in zarr root. Not a valid SpikeInterface zarr format") + # For version<0.105.0 zarr files, revert to old way of loading based on the presence of "channel_ids"/"unit_ids" + if "channel_ids" in root.keys(): + return read_zarr_recording(folder_path, storage_options=storage_options) + elif "unit_ids" in root.keys(): + return read_zarr_sorting(folder_path, storage_options=storage_options) + else: + raise ValueError( + "Cannot find 'channel_ids' or 'unit_ids' in zarr root. Not a valid SpikeInterface zarr format" + ) ### UTILITY FUNCTIONS ### From 1d14461a52be94da985517853cff449eafd0f529 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Wed, 25 Mar 2026 12:23:16 +0100 Subject: [PATCH 3/3] fix: imports --- src/spikeinterface/core/zarrextractors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spikeinterface/core/zarrextractors.py b/src/spikeinterface/core/zarrextractors.py index 69df4f1115..a3bdd8d0a8 100644 --- a/src/spikeinterface/core/zarrextractors.py +++ b/src/spikeinterface/core/zarrextractors.py @@ -5,7 +5,7 @@ from probeinterface import ProbeGroup -from .base import minimum_spike_dtype +from .base import minimum_spike_dtype, _get_class_from_string from .baserecording import BaseRecording, BaseRecordingSegment from .basesorting import BaseSorting, SpikeVectorSortingSegment from .core_tools import define_function_from_class, check_json, retrieve_importing_provenance