|
10 | 10 | from spikeinterface.core.core_tools import define_function_from_class |
11 | 11 | from spikeinterface.extractors.neuropixels_utils import get_neuropixels_sample_shifts |
12 | 12 |
|
13 | | -from .neobaseextractor import NeoBaseRecordingExtractor |
| 13 | +from .neobaseextractor import NeoBaseRecordingExtractor, NeoBaseEventExtractor |
14 | 14 |
|
15 | 15 |
|
16 | 16 | class SpikeGLXRecordingExtractor(NeoBaseRecordingExtractor): |
@@ -98,3 +98,47 @@ def map_to_neo_kwargs(cls, folder_path, load_sync_channel=False): |
98 | 98 |
|
99 | 99 |
|
100 | 100 | read_spikeglx = define_function_from_class(source_class=SpikeGLXRecordingExtractor, name="read_spikeglx") |
| 101 | + |
| 102 | + |
| 103 | +class SpikeGLXEventExtractor(NeoBaseEventExtractor): |
| 104 | + """ |
| 105 | + Class for reading events saved on the event channel by SpikeGLX software. |
| 106 | +
|
| 107 | + Parameters |
| 108 | + ---------- |
| 109 | + folder_path: str |
| 110 | +
|
| 111 | + """ |
| 112 | + |
| 113 | + mode = "folder" |
| 114 | + NeoRawIOClass = "SpikeGLXRawIO" |
| 115 | + name = "spikeglx" |
| 116 | + |
| 117 | + def __init__(self, folder_path, block_index=None): |
| 118 | + neo_kwargs = self.map_to_neo_kwargs(folder_path) |
| 119 | + NeoBaseEventExtractor.__init__(self, block_index=block_index, **neo_kwargs) |
| 120 | + |
| 121 | + @classmethod |
| 122 | + def map_to_neo_kwargs(cls, folder_path): |
| 123 | + neo_kwargs = {"dirname": str(folder_path)} |
| 124 | + return neo_kwargs |
| 125 | + |
| 126 | + |
| 127 | +def read_spikeglx_event(folder_path, block_index=None): |
| 128 | + """ |
| 129 | + Read SpikeGLX events |
| 130 | +
|
| 131 | + Parameters |
| 132 | + ---------- |
| 133 | + folder_path: str or Path |
| 134 | + Path to openephys folder |
| 135 | + block_index: int, default: None |
| 136 | + If there are several blocks (experiments), specify the block index you want to load. |
| 137 | +
|
| 138 | + Returns |
| 139 | + ------- |
| 140 | + event: SpikeGLXEventExtractor |
| 141 | + """ |
| 142 | + |
| 143 | + event = SpikeGLXEventExtractor(folder_path, block_index=block_index) |
| 144 | + return event |
0 commit comments