Skip to content

Commit

Permalink
Merge pull request #3352 from alejoe91/load-analyzer-or-waveforms
Browse files Browse the repository at this point in the history
Add `load_sorting_analyzer_or_waveforms` function
  • Loading branch information
samuelgarcia authored Sep 3, 2024
2 parents 161efc4 + 7501eda commit 62f2d39
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
13 changes: 13 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ Low-level

.. autoclass:: ChunkRecordingExecutor


Back-compatibility with ``WaveformExtractor`` (version < 0.101.0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. automodule:: spikeinterface.core
:noindex:

.. autofunction:: extract_waveforms
.. autofunction:: load_waveforms
.. autofunction:: load_sorting_analyzer_or_waveforms



spikeinterface.extractors
-------------------------

Expand Down
6 changes: 5 additions & 1 deletion src/spikeinterface/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,8 @@

# Important not for compatibility!!
# This wil be uncommented after 0.100
from .waveforms_extractor_backwards_compatibility import extract_waveforms, load_waveforms
from .waveforms_extractor_backwards_compatibility import (
extract_waveforms,
load_waveforms,
load_sorting_analyzer_or_waveforms,
)
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,31 @@ def get_template(
return templates[0]


def load_sorting_analyzer_or_waveforms(folder, sorting=None):
"""
Load a SortingAnalyzer from either a newly saved SortingAnalyzer folder or an old WaveformExtractor folder.
Parameters
----------
folder: str | Path
The folder to the sorting analyzer or waveform extractor
sorting: BaseSorting | None, default: None
The sorting object to instantiate with the SortingAnalyzer (only used for old WaveformExtractor)
Returns
-------
sorting_analyzer: SortingAnalyzer
The returned SortingAnalyzer.
"""
folder = Path(folder)
if folder.suffix == ".zarr":
return load_sorting_analyzer(folder)
elif (folder / "spikeinterface_info.json").exists():
return load_sorting_analyzer(folder)
else:
return load_waveforms(folder, sorting=sorting, output="SortingAnalyzer")


def load_waveforms(
folder,
with_recording: bool = True,
Expand Down

0 comments on commit 62f2d39

Please sign in to comment.