-
Notifications
You must be signed in to change notification settings - Fork 234
Allow run_sorter to accept dicts
#4005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
ba817c0
39461e3
c07905f
c5000d4
6302fff
035416b
9ca1ef3
6edf988
1246e17
3b0bf56
7aca913
54ce475
0129600
a83fa8a
71b9332
96f5d8b
3638f12
f927649
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,12 @@ def _guess_object_from_local_folder(folder): | |
| with open(folder / "spikeinterface_info.json", "r") as f: | ||
| spikeinterface_info = json.load(f) | ||
| return _guess_object_from_dict(spikeinterface_info) | ||
| elif ( | ||
| (folder / "sorter_output").is_dir() | ||
| and (folder / "spikeinterface_params.json").is_file() | ||
| and (folder / "spikeinterface_log.json").is_file() | ||
| ): | ||
| return "SorterFolder" | ||
| elif (folder / "waveforms").is_dir(): | ||
| # before the SortingAnlazer, it was WaveformExtractor (v<0.101) | ||
| return "WaveformExtractor" | ||
|
|
@@ -212,13 +218,20 @@ def _guess_object_from_local_folder(folder): | |
| return "Recording|Sorting" | ||
|
|
||
|
|
||
| def _load_object_from_folder(folder, object_type, **kwargs): | ||
| def _load_object_from_folder(folder, object_type: str, **kwargs): | ||
|
|
||
| if object_type == "SortingAnalyzer": | ||
| from .sortinganalyzer import load_sorting_analyzer | ||
|
|
||
| analyzer = load_sorting_analyzer(folder, **kwargs) | ||
| return analyzer | ||
|
|
||
| elif object_type == "SorterFolder": | ||
| from spikeinterface.sorters import read_sorter_folder | ||
|
|
||
| sorting = read_sorter_folder(folder) | ||
| return sorting | ||
|
|
||
| elif object_type == "Motion": | ||
| from spikeinterface.core.motion import Motion | ||
|
|
||
|
|
@@ -244,6 +257,16 @@ def _load_object_from_folder(folder, object_type, **kwargs): | |
| si_file = f | ||
| return BaseExtractor.load(si_file, base_folder=folder) | ||
|
|
||
| elif object_type.startswith("Group"): | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feedback on these lines of code very welcome! Wasn't sure best way to proceed. |
||
|
|
||
| sub_object_type = object_type.split("[")[1].split("]")[0] | ||
| with open(folder / "spikeinterface_info.json", "r") as f: | ||
| spikeinterface_info = json.load(f) | ||
| group_keys = spikeinterface_info.get("dict_keys") | ||
|
|
||
| group_of_objects = {key: _load_object_from_folder(folder / str(key), sub_object_type) for key in group_keys} | ||
chrishalcrow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return group_of_objects | ||
|
|
||
|
|
||
| def _guess_object_from_zarr(zarr_folder): | ||
| # here it can be a zarr folder for Recording|Sorting|SortingAnalyzer|Template | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -344,6 +344,17 @@ def get_result_from_folder(cls, output_folder, register_recording=True, sorting_ | |
| if recording is not None: | ||
| sorting.register_recording(recording) | ||
|
|
||
| if recording.get_annotation("split_by_property") is not None: | ||
|
||
| split_by_property = recording.get_annotation("split_by_property") | ||
| property_values = set(recording.get_property(split_by_property)) | ||
| if len(property_values) > 1: | ||
| warnings.warn( | ||
| f"Registered Recording has non-unique {split_by_property} keys. They are {property_values}." | ||
| ) | ||
| elif len(property_values) == 1: | ||
| property_value = next(iter(property_values)) | ||
| sorting.set_property("split_by_property", values=[property_value] * sorting.get_num_units()) | ||
|
|
||
| if sorting_info: | ||
| # set sorting info to Sorting object | ||
| if (output_folder / "spikeinterface_recording.json").exists(): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.