-
Notifications
You must be signed in to change notification settings - Fork 189
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 #1736 from JuliaSprenger/add/pl2
Add plexon2 recording, sorting and event support
- Loading branch information
Showing
6 changed files
with
210 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,21 @@ | ||
name: Install packages | ||
description: This action installs the package and its dependencies for testing | ||
|
||
inputs: | ||
python-version: | ||
description: 'Python version to set up' | ||
required: false | ||
os: | ||
description: 'Operating system to set up' | ||
required: false | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install wine (needed for Plexon2) | ||
run: | | ||
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list | ||
sudo dpkg --add-architecture i386 | ||
sudo apt-get update -qq | ||
sudo apt-get install -yqq --allow-downgrades libc6:i386 libgcc-s1:i386 libstdc++6:i386 wine | ||
shell: bash |
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