Skip to content

Commit

Permalink
Merge pull request #3195 from h-mayorquin/enable_name_as_ids_in_extra…
Browse files Browse the repository at this point in the history
…ctors

Propagate option for using neo channel names as ids in all neo extractors without changing the deafult behavior
  • Loading branch information
samuelgarcia authored Jul 15, 2024
2 parents 0fa4367 + f8abacc commit 11f480b
Show file tree
Hide file tree
Showing 19 changed files with 226 additions and 33 deletions.
20 changes: 18 additions & 2 deletions src/spikeinterface/extractors/neoextractors/alphaomega.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,30 @@ class AlphaOmegaRecordingExtractor(NeoBaseRecordingExtractor):
If there are several streams, specify the stream name you want to load.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "AlphaOmegaRawIO"

def __init__(self, folder_path, lsx_files=None, stream_id="RAW", stream_name=None, all_annotations=False):
def __init__(
self,
folder_path,
lsx_files=None,
stream_id="RAW",
stream_name=None,
all_annotations: bool = False,
use_names_as_ids: bool = False,
):
neo_kwargs = self.map_to_neo_kwargs(folder_path, lsx_files)
NeoBaseRecordingExtractor.__init__(
self, stream_id=stream_id, stream_name=stream_name, all_annotations=all_annotations, **neo_kwargs
self,
stream_id=stream_id,
stream_name=stream_name,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)
self._kwargs.update(dict(folder_path=str(Path(folder_path).absolute()), lsx_files=lsx_files))

Expand Down
12 changes: 10 additions & 2 deletions src/spikeinterface/extractors/neoextractors/axona.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ class AxonaRecordingExtractor(NeoBaseRecordingExtractor):
The file path to load the recordings from.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "AxonaRawIO"

def __init__(self, file_path, all_annotations=False):
def __init__(self, file_path: str | Path, all_annotations: bool = False, use_names_as_ids: bool = False):
neo_kwargs = self.map_to_neo_kwargs(file_path)
NeoBaseRecordingExtractor.__init__(self, all_annotations=all_annotations, **neo_kwargs)
NeoBaseRecordingExtractor.__init__(
self,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)
self._kwargs.update({"file_path": str(Path(file_path).absolute())})

@classmethod
Expand Down
13 changes: 11 additions & 2 deletions src/spikeinterface/extractors/neoextractors/biocam.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class BiocamRecordingExtractor(NeoBaseRecordingExtractor):
If there are several streams, specify the stream name you want to load.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "BiocamRawIO"
Expand All @@ -40,11 +43,17 @@ def __init__(
electrode_width=None,
stream_id=None,
stream_name=None,
all_annotations=False,
all_annotations: bool = False,
use_names_as_ids: bool = 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,
stream_id=stream_id,
stream_name=stream_name,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)

# load probe from probeinterface
Expand Down
7 changes: 4 additions & 3 deletions src/spikeinterface/extractors/neoextractors/blackrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class BlackrockRecordingExtractor(NeoBaseRecordingExtractor):
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
If False, use default IDs inherited from Neo. If True, use channel names as IDs.
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

Expand All @@ -38,8 +39,8 @@ def __init__(
file_path,
stream_id=None,
stream_name=None,
all_annotations=False,
use_names_as_ids=False,
all_annotations: bool = False,
use_names_as_ids: bool = False,
):
neo_kwargs = self.map_to_neo_kwargs(file_path)
neo_kwargs["load_nev"] = False # Avoid loading spikes release in neo 0.12.0
Expand Down
14 changes: 12 additions & 2 deletions src/spikeinterface/extractors/neoextractors/ced.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,24 @@ class CedRecordingExtractor(NeoBaseRecordingExtractor):
If there are several streams, specify the stream name you want to load.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "CedRawIO"

def __init__(self, file_path, stream_id=None, stream_name=None, all_annotations=False):
def __init__(
self, file_path, stream_id=None, stream_name=None, all_annotations: bool = False, use_names_as_ids: bool = 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,
stream_id=stream_id,
stream_name=stream_name,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)
self._kwargs.update(dict(file_path=str(Path(file_path).absolute())))
self.extra_requirements.append("neo[ced]")
Expand Down
19 changes: 17 additions & 2 deletions src/spikeinterface/extractors/neoextractors/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,29 @@ class EDFRecordingExtractor(NeoBaseRecordingExtractor):
If there are several streams, specify the stream name you want to load.
all_annotations: bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "EDFRawIO"

def __init__(self, file_path, stream_id=None, stream_name=None, all_annotations=False):
def __init__(
self,
file_path,
stream_id=None,
stream_name=None,
all_annotations: bool = False,
use_names_as_ids: bool = False,
):
neo_kwargs = {"filename": str(file_path)}
NeoBaseRecordingExtractor.__init__(
self, stream_id=stream_id, stream_name=stream_name, all_annotations=all_annotations, **neo_kwargs
self,
stream_id=stream_id,
stream_name=stream_name,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)
self._kwargs.update({"file_path": str(Path(file_path).absolute())})
self.extra_requirements.append("neo[edf]")
Expand Down
6 changes: 5 additions & 1 deletion src/spikeinterface/extractors/neoextractors/intan.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ class IntanRecordingExtractor(NeoBaseRecordingExtractor):
check we perform is that timestamps are continuous. Setting this to True will ignore this check and set
the attribute `discontinuous_timestamps` to True in the underlying neo object.
use_names_as_ids : bool, default: False
If False, use default IDs inherited from Neo. If True, use channel names as IDs.
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
In Intan the ids provided by NeoRawIO are the hardware channel ids while the names are custom names given by
the user
"""
Expand Down
5 changes: 5 additions & 0 deletions src/spikeinterface/extractors/neoextractors/maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class MaxwellRecordingExtractor(NeoBaseRecordingExtractor):
If there are several streams, specify the stream name you want to load.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
rec_name : str, default: None
When the file contains several recordings you need to specify the one
you want to extract. (rec_name='rec0000').
Expand All @@ -50,6 +53,7 @@ def __init__(
all_annotations=False,
rec_name=None,
install_maxwell_plugin=False,
use_names_as_ids: bool = False,
):
if install_maxwell_plugin:
self.install_maxwell_plugin()
Expand All @@ -61,6 +65,7 @@ def __init__(
stream_name=stream_name,
block_index=block_index,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)

Expand Down
14 changes: 13 additions & 1 deletion src/spikeinterface/extractors/neoextractors/mcsraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,30 @@ class MCSRawRecordingExtractor(NeoBaseRecordingExtractor):
If there are several blocks, specify the block index you want to load.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "RawMCSRawIO"

def __init__(self, file_path, stream_id=None, stream_name=None, block_index=None, all_annotations=False):
def __init__(
self,
file_path,
stream_id=None,
stream_name=None,
block_index=None,
all_annotations=False,
use_names_as_ids: bool = False,
):
neo_kwargs = self.map_to_neo_kwargs(file_path)
NeoBaseRecordingExtractor.__init__(
self,
stream_id=stream_id,
stream_name=stream_name,
block_index=block_index,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)
self._kwargs.update(dict(file_path=str(Path(file_path).absolute())))
Expand Down
12 changes: 10 additions & 2 deletions src/spikeinterface/extractors/neoextractors/mearec.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ class MEArecRecordingExtractor(NeoBaseRecordingExtractor):
The file path to load the recordings from.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "MEArecRawIO"

def __init__(self, file_path: Union[str, Path], all_annotations: bool = False):
def __init__(self, file_path: Union[str, Path], all_annotations: bool = False, use_names_as_ids: bool = False):
neo_kwargs = self.map_to_neo_kwargs(file_path)
NeoBaseRecordingExtractor.__init__(self, all_annotations=all_annotations, **neo_kwargs)
NeoBaseRecordingExtractor.__init__(
self,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)

self.extra_requirements.append("mearec")

Expand Down
13 changes: 11 additions & 2 deletions src/spikeinterface/extractors/neoextractors/neuralynx.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class NeuralynxRecordingExtractor(NeoBaseRecordingExtractor):
exclude_filename : list[str], default: None
List of filename to exclude from the loading.
For example, use `exclude_filename=["events.nev"]` to skip loading the event file.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
strict_gap_mode : bool, default: False
See neo documentation.
Detect gaps using strict mode or not.
Expand All @@ -44,16 +47,22 @@ class NeuralynxRecordingExtractor(NeoBaseRecordingExtractor):

def __init__(
self,
folder_path,
folder_path: str | Path,
stream_id=None,
stream_name=None,
all_annotations=False,
exclude_filename=None,
strict_gap_mode=False,
use_names_as_ids: bool = False,
):
neo_kwargs = self.map_to_neo_kwargs(folder_path, exclude_filename, strict_gap_mode)
NeoBaseRecordingExtractor.__init__(
self, stream_id=stream_id, stream_name=stream_name, all_annotations=all_annotations, **neo_kwargs
self,
stream_id=stream_id,
stream_name=stream_name,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)
self._kwargs.update(
dict(folder_path=str(Path(folder_path).absolute()), exclude_filename=exclude_filename),
Expand Down
14 changes: 12 additions & 2 deletions src/spikeinterface/extractors/neoextractors/neuroexplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,24 @@ class NeuroExplorerRecordingExtractor(NeoBaseRecordingExtractor):
If there are several streams, specify the stream name you want to load.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "NeuroExplorerRawIO"

def __init__(self, file_path, stream_id=None, stream_name=None, all_annotations=False):
def __init__(
self, file_path, stream_id=None, stream_name=None, all_annotations: bool = False, use_names_as_ids: bool = False
):
neo_kwargs = {"filename": str(file_path)}
NeoBaseRecordingExtractor.__init__(
self, stream_id=stream_id, stream_name=stream_name, all_annotations=all_annotations, **neo_kwargs
self,
stream_id=stream_id,
stream_name=stream_name,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)
self._kwargs.update({"file_path": str(Path(file_path).absolute())})
self.extra_requirements.append("neo[edf]")
Expand Down
20 changes: 18 additions & 2 deletions src/spikeinterface/extractors/neoextractors/neuroscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,31 @@ class NeuroScopeRecordingExtractor(NeoBaseRecordingExtractor):
If there are several streams, specify the stream name you want to load.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "NeuroScopeRawIO"

def __init__(self, file_path, xml_file_path=None, stream_id=None, stream_name=None, all_annotations=False):
def __init__(
self,
file_path,
xml_file_path=None,
stream_id=None,
stream_name: bool = None,
all_annotations: bool = False,
use_names_as_ids: bool = False,
):
neo_kwargs = self.map_to_neo_kwargs(file_path, xml_file_path)

NeoBaseRecordingExtractor.__init__(
self, stream_id=stream_id, stream_name=stream_name, all_annotations=all_annotations, **neo_kwargs
self,
stream_id=stream_id,
stream_name=stream_name,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)
if xml_file_path is not None:
xml_file_path = str(Path(xml_file_path).absolute())
Expand Down
14 changes: 13 additions & 1 deletion src/spikeinterface/extractors/neoextractors/nix.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,30 @@ class NixRecordingExtractor(NeoBaseRecordingExtractor):
If there are several blocks, specify the block index you want to load.
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
use_names_as_ids : bool, default: False
Determines the format of the channel IDs used by the extractor. If set to True, the channel IDs will be the
names from NeoRawIO. If set to False, the channel IDs will be the ids provided by NeoRawIO.
"""

NeoRawIOClass = "NIXRawIO"

def __init__(self, file_path, stream_id=None, stream_name=None, block_index=None, all_annotations=False):
def __init__(
self,
file_path,
stream_id=None,
stream_name=None,
block_index=None,
all_annotations: bool = False,
use_names_as_ids: bool = False,
):
neo_kwargs = self.map_to_neo_kwargs(file_path)
NeoBaseRecordingExtractor.__init__(
self,
stream_id=stream_id,
stream_name=stream_name,
block_index=block_index,
all_annotations=all_annotations,
use_names_as_ids=use_names_as_ids,
**neo_kwargs,
)
self._kwargs.update(dict(file_path=str(Path(file_path).absolute()), stream_id=stream_id))
Expand Down
Loading

0 comments on commit 11f480b

Please sign in to comment.