|
| 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") |
0 commit comments