-
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ba817c0
allow for sort_by_dict
chrishalcrow 39461e3
add a Path, and use dict of Sorting
chrishalcrow c07905f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c5000d4
add dict_key_types
chrishalcrow 6302fff
add docs and docstrings
chrishalcrow 035416b
Merge branch 'main' into sort-dict-minimal
chrishalcrow 9ca1ef3
change format and add load for Groups, and load tests
chrishalcrow 6edf988
Merge branch 'sort-dict-minimal' of https://github.com/chrishalcrow/s…
chrishalcrow 1246e17
Merge branch 'main' into sort-dict-minimal
chrishalcrow 3b0bf56
SorterOutput to SorterFolder
chrishalcrow 7aca913
add split_by_property to basesorter load
chrishalcrow 54ce475
docs link fix
chrishalcrow 0129600
Merge branch 'main' into sort-dict-minimal
chrishalcrow a83fa8a
respond to sam
chrishalcrow 71b9332
Merge branch 'sort-dict-minimal' of https://github.com/chrishalcrow/s…
chrishalcrow 96f5d8b
move pop
chrishalcrow 3638f12
Merge branch 'main' into sort-dict-minimal
chrishalcrow f927649
output_folder -> folder in test
chrishalcrow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -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 "SorterOutput" | ||
| 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 == "SorterOutput": | ||
| 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 | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.