-
Notifications
You must be signed in to change notification settings - Fork 190
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
Add plexon2 recording, sorting and event support #1736
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f498179
Add plexon2 recording, sorting and event support
JuliaSprenger 9f42895
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1326c27
Merge branch 'main' into add/pl2
JuliaSprenger eb9c46c
Merge branch 'main' into add/pl2
h-mayorquin 6be684f
Merge branch 'main' into add/pl2
alejoe91 2d7b08f
Add zugbruecke in extractors install for plexon2
alejoe91 4a9f429
Update naming following #1626
alejoe91 aae39c6
Install wine for plexon2
alejoe91 26fdba2
Add shell
alejoe91 8bcec5f
Expose sampling_frequency in pl2 sorting (needed for multi-stream)
alejoe91 3ffb76c
Add sampling_frequency kwargs in tests
alejoe91 6247dc0
Update self._kwargs
alejoe91 dfcd3ca
Mark plexon2 tests and install Wine only if needed
alejoe91 23f8677
Install zugbruecke not on win
alejoe91 99602f1
Make plexon2 tests conditional on Wine dependency (on Linux)
alejoe91 e73cf7e
Simplify plexon2 tests (only run when dependencies are installed)
alejoe91 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 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 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 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 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,103 @@ | ||
from spikeinterface.core.core_tools import define_function_from_class | ||
|
||
from .neobaseextractor import NeoBaseRecordingExtractor, NeoBaseSortingExtractor, NeoBaseEventExtractor | ||
|
||
|
||
class Plexon2RecordingExtractor(NeoBaseRecordingExtractor): | ||
""" | ||
Class for reading plexon pl2 files. | ||
|
||
Based on :py:class:`neo.rawio.Plexon2RawIO` | ||
|
||
Parameters | ||
---------- | ||
file_path: str | ||
The file path to load the recordings from. | ||
stream_id: str, optional | ||
If there are several streams, specify the stream id you want to load. | ||
stream_name: str, optional | ||
If there are several streams, specify the stream name you want to load. | ||
all_annotations: bool, default: False | ||
Load exhaustively all annotations from neo. | ||
""" | ||
|
||
mode = "file" | ||
NeoRawIOClass = "Plexon2RawIO" | ||
name = "plexon2" | ||
|
||
def __init__(self, file_path, stream_id=None, stream_name=None, all_annotations=False): | ||
neo_kwargs = self.map_to_neo_kwargs(file_path) | ||
NeoBaseRecordingExtractor.__init__( | ||
self, stream_id=stream_id, stream_name=stream_name, all_annotations=all_annotations, **neo_kwargs | ||
) | ||
self._kwargs.update({"file_path": str(file_path)}) | ||
|
||
@classmethod | ||
def map_to_neo_kwargs(cls, file_path): | ||
neo_kwargs = {"filename": str(file_path)} | ||
return neo_kwargs | ||
|
||
|
||
class Plexon2SortingExtractor(NeoBaseSortingExtractor): | ||
""" | ||
Class for reading plexon spiking data from .pl2 files. | ||
|
||
Based on :py:class:`neo.rawio.Plexon2RawIO` | ||
|
||
Parameters | ||
---------- | ||
file_path: str | ||
The file path to load the recordings from. | ||
sampling_frequency: float, default: None | ||
The sampling frequency of the sorting (required for multiple streams with different sampling frequencies). | ||
""" | ||
|
||
mode = "file" | ||
NeoRawIOClass = "Plexon2RawIO" | ||
neo_returns_frames = True | ||
name = "plexon2" | ||
|
||
def __init__(self, file_path, sampling_frequency=None): | ||
from neo.rawio import Plexon2RawIO | ||
|
||
neo_kwargs = self.map_to_neo_kwargs(file_path) | ||
neo_reader = Plexon2RawIO(**neo_kwargs) | ||
neo_reader.parse_header() | ||
NeoBaseSortingExtractor.__init__(self, sampling_frequency=sampling_frequency, **neo_kwargs) | ||
self._kwargs.update({"file_path": str(file_path), "sampling_frequency": sampling_frequency}) | ||
|
||
@classmethod | ||
def map_to_neo_kwargs(cls, file_path): | ||
neo_kwargs = {"filename": str(file_path)} | ||
return neo_kwargs | ||
|
||
|
||
class Plexon2EventExtractor(NeoBaseEventExtractor): | ||
""" | ||
Class for reading plexon spiking data from .pl2 files. | ||
|
||
Based on :py:class:`neo.rawio.Plexon2RawIO` | ||
|
||
Parameters | ||
---------- | ||
folder_path: str | ||
|
||
""" | ||
|
||
mode = "file" | ||
NeoRawIOClass = "Plexon2RawIO" | ||
name = "plexon2" | ||
|
||
def __init__(self, folder_path, block_index=None): | ||
neo_kwargs = self.map_to_neo_kwargs(folder_path) | ||
NeoBaseEventExtractor.__init__(self, block_index=block_index, **neo_kwargs) | ||
|
||
@classmethod | ||
def map_to_neo_kwargs(cls, folder_path): | ||
neo_kwargs = {"filename": str(folder_path)} | ||
return neo_kwargs | ||
|
||
|
||
read_plexon2 = define_function_from_class(source_class=Plexon2RecordingExtractor, name="read_plexon2") | ||
read_plexon2_sorting = define_function_from_class(source_class=Plexon2SortingExtractor, name="read_plexon2_sorting") | ||
read_plexon2_event = define_function_from_class(source_class=Plexon2EventExtractor, name="read_plexon2_event") |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be quite heavy and not needed (unless plexon2 wrapper changes). We could make a manual workflow that installs wine and tests plexon2 only.
Otherwise we can make an
install_wine.yml
action and install + run plexon2 tests only if plexon2 has changed.