Skip to content

Commit 1d21a8d

Browse files
authored
Merge pull request #4021 from h-mayorquin/add_axon
Add Axon recording
2 parents 276e012 + 6d914d3 commit 1d21a8d

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

src/spikeinterface/extractors/neoextractors/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .alphaomega import AlphaOmegaRecordingExtractor, AlphaOmegaEventExtractor, read_alphaomega, read_alphaomega_event
2+
from .axon import AxonRecordingExtractor, read_axon
23
from .axona import AxonaRecordingExtractor, read_axona
34
from .biocam import BiocamRecordingExtractor, read_biocam
45
from .blackrock import BlackrockRecordingExtractor, BlackrockSortingExtractor, read_blackrock, read_blackrock_sorting
@@ -44,6 +45,7 @@
4445

4546
neo_recording_extractors_dict = {
4647
AlphaOmegaRecordingExtractor: dict(wrapper_string="read_alphaomega", wrapper_class=read_alphaomega),
48+
AxonRecordingExtractor: dict(wrapper_string="read_axon", wrapper_class=read_axon),
4749
AxonaRecordingExtractor: dict(wrapper_string="read_axona", wrapper_class=read_axona),
4850
BiocamRecordingExtractor: dict(wrapper_string="read_biocam", wrapper_class=read_biocam),
4951
BlackrockRecordingExtractor: dict(wrapper_string="read_blackrock", wrapper_class=read_blackrock),
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from __future__ import annotations
2+
3+
from pathlib import Path
4+
5+
from spikeinterface.core.core_tools import define_function_from_class
6+
7+
from .neobaseextractor import NeoBaseRecordingExtractor
8+
9+
10+
class AxonRecordingExtractor(NeoBaseRecordingExtractor):
11+
"""
12+
Class for reading Axon Binary Format (ABF) files.
13+
14+
Based on :py:class:`neo.rawio.AxonRawIO`
15+
16+
Supports both ABF1 (pClamp ≤9) and ABF2 (pClamp ≥10) formats.
17+
Can read data from pCLAMP and AxoScope software.
18+
19+
Parameters
20+
----------
21+
file_path : str or Path
22+
The ABF file path to load the recordings from.
23+
stream_id : str or None, default: None
24+
If there are several streams, specify the stream id you want to load.
25+
stream_name : str or None, default: None
26+
If there are several streams, specify the stream name you want to load.
27+
all_annotations : bool, default: False
28+
Load exhaustively all annotations from neo.
29+
use_names_as_ids : bool, default: False
30+
Determines the format of the channel IDs used by the extractor.
31+
32+
Examples
33+
--------
34+
>>> from spikeinterface.extractors import read_axon
35+
>>> recording = read_axon(file_path='path/to/file.abf')
36+
"""
37+
38+
NeoRawIOClass = "AxonRawIO"
39+
40+
def __init__(
41+
self,
42+
file_path,
43+
stream_id=None,
44+
stream_name=None,
45+
all_annotations: bool = False,
46+
use_names_as_ids: bool = False,
47+
):
48+
neo_kwargs = self.map_to_neo_kwargs(file_path)
49+
NeoBaseRecordingExtractor.__init__(
50+
self,
51+
stream_id=stream_id,
52+
stream_name=stream_name,
53+
all_annotations=all_annotations,
54+
use_names_as_ids=use_names_as_ids,
55+
**neo_kwargs,
56+
)
57+
58+
self._kwargs.update(dict(file_path=str(Path(file_path).absolute())))
59+
60+
@classmethod
61+
def map_to_neo_kwargs(cls, file_path):
62+
neo_kwargs = {"filename": str(file_path)}
63+
return neo_kwargs
64+
65+
66+
read_axon = define_function_from_class(source_class=AxonRecordingExtractor, name="read_axon")

src/spikeinterface/extractors/tests/test_neoextractors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
Spike2RecordingExtractor,
4141
EDFRecordingExtractor,
4242
Plexon2RecordingExtractor,
43+
AxonRecordingExtractor,
4344
)
4445

4546
from spikeinterface.extractors.extractor_classes import KiloSortSortingExtractor
@@ -294,6 +295,12 @@ class TdTRecordingTest(RecordingCommonTestSuite, unittest.TestCase):
294295
entities = [("tdt/aep_05", {"stream_id": "1"})]
295296

296297

298+
class AxonRecordingTest(RecordingCommonTestSuite, unittest.TestCase):
299+
ExtractorClass = AxonRecordingExtractor
300+
downloads = ["axon"]
301+
entities = ["axon/extracellular_data/four_electrodes/24606005_SampleData.abf"]
302+
303+
297304
class AxonaRecordingTest(RecordingCommonTestSuite, unittest.TestCase):
298305
ExtractorClass = AxonaRecordingExtractor
299306
downloads = ["axona"]

0 commit comments

Comments
 (0)