-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2403 from samuelgarcia/improve_zar_sorting
Improve ZarrSortingExtractor
- Loading branch information
Showing
2 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import pytest | ||
from pathlib import Path | ||
|
||
import shutil | ||
|
||
import zarr | ||
|
||
from spikeinterface.core import ( | ||
ZarrRecordingExtractor, | ||
ZarrSortingExtractor, | ||
generate_sorting, | ||
load_extractor, | ||
) | ||
from spikeinterface.core.zarrextractors import add_sorting_to_zarr_group | ||
|
||
if hasattr(pytest, "global_test_folder"): | ||
cache_folder = pytest.global_test_folder / "core" | ||
else: | ||
cache_folder = Path("cache_folder") / "core" | ||
|
||
|
||
def test_ZarrSortingExtractor(): | ||
np_sorting = generate_sorting() | ||
|
||
# store in root standard normal way | ||
folder = cache_folder / "zarr_sorting" | ||
if folder.is_dir(): | ||
shutil.rmtree(folder) | ||
ZarrSortingExtractor.write_sorting(np_sorting, folder) | ||
sorting = ZarrSortingExtractor(folder) | ||
sorting = load_extractor(sorting.to_dict()) | ||
|
||
# store the sorting in a sub group (for instance SortingResult) | ||
folder = cache_folder / "zarr_sorting_sub_group" | ||
if folder.is_dir(): | ||
shutil.rmtree(folder) | ||
zarr_root = zarr.open(folder, mode="w") | ||
zarr_sorting_group = zarr_root.create_group("sorting") | ||
add_sorting_to_zarr_group(sorting, zarr_sorting_group) | ||
sorting = ZarrSortingExtractor(folder, zarr_group="sorting") | ||
# and reaload | ||
sorting = load_extractor(sorting.to_dict()) | ||
|
||
|
||
if __name__ == "__main__": | ||
test_ZarrSortingExtractor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters