Skip to content

Commit

Permalink
Merge pull request #2442 from manimoh/adding_event_reading_in_spikeglx
Browse files Browse the repository at this point in the history
Implementing read_spikeglx_event()
  • Loading branch information
alejoe91 authored Jun 24, 2024
2 parents fa39967 + b946935 commit cf55923
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/spikeinterface/extractors/neoextractors/spikeglx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from spikeinterface.core.core_tools import define_function_from_class
from spikeinterface.extractors.neuropixels_utils import get_neuropixels_sample_shifts

from .neobaseextractor import NeoBaseRecordingExtractor
from .neobaseextractor import NeoBaseRecordingExtractor, NeoBaseEventExtractor


class SpikeGLXRecordingExtractor(NeoBaseRecordingExtractor):
Expand Down Expand Up @@ -98,3 +98,47 @@ def map_to_neo_kwargs(cls, folder_path, load_sync_channel=False):


read_spikeglx = define_function_from_class(source_class=SpikeGLXRecordingExtractor, name="read_spikeglx")


class SpikeGLXEventExtractor(NeoBaseEventExtractor):
"""
Class for reading events saved on the event channel by SpikeGLX software.
Parameters
----------
folder_path: str
"""

mode = "folder"
NeoRawIOClass = "SpikeGLXRawIO"
name = "spikeglx"

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 = {"dirname": str(folder_path)}
return neo_kwargs


def read_spikeglx_event(folder_path, block_index=None):
"""
Read SpikeGLX events
Parameters
----------
folder_path: str or Path
Path to openephys folder
block_index: int, default: None
If there are several blocks (experiments), specify the block index you want to load.
Returns
-------
event: SpikeGLXEventExtractor
"""

event = SpikeGLXEventExtractor(folder_path, block_index=block_index)
return event

0 comments on commit cf55923

Please sign in to comment.