Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strict_gap_mode in read_neuralynx to reflect neo. #2550

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions src/spikeinterface/extractors/neoextractors/neuralynx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from typing import Optional
from pathlib import Path

from importlib.metadata import version

from spikeinterface.core.core_tools import define_function_from_class

from .neobaseextractor import NeoBaseRecordingExtractor, NeoBaseSortingExtractor
Expand All @@ -27,22 +29,44 @@ class NeuralynxRecordingExtractor(NeoBaseRecordingExtractor):
exlude_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.
strict_gap_mode: bool, default: False
See neo documentation.
Detect gaps using strict mode or not.
* strict_gap_mode = True then a gap is consider when timstamp difference between two
consequtive data packet is more than one sample interval.
samuelgarcia marked this conversation as resolved.
Show resolved Hide resolved
* strict_gap_mode = False then a gap has an increased tolerance. Some new system with different clock need this option
samuelgarcia marked this conversation as resolved.
Show resolved Hide resolved
otherwise, too many gaps are detected
Note hat here the default is False contrary to neo.
samuelgarcia marked this conversation as resolved.
Show resolved Hide resolved
"""

mode = "folder"
NeoRawIOClass = "NeuralynxRawIO"
name = "neuralynx"

def __init__(self, folder_path, stream_id=None, stream_name=None, all_annotations=False, exclude_filename=None):
neo_kwargs = self.map_to_neo_kwargs(folder_path, exclude_filename)
def __init__(
self,
folder_path,
stream_id=None,
stream_name=None,
all_annotations=False,
exclude_filename=None,
strict_gap_mode=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._kwargs.update(dict(folder_path=str(Path(folder_path).absolute()), exclude_filename=exclude_filename))
self._kwargs.update(
dict(folder_path=str(Path(folder_path).absolute()), exclude_filename=exclude_filename),
strict_gap_mode=strict_gap_mode,
)

@classmethod
def map_to_neo_kwargs(cls, folder_path, exclude_filename):
def map_to_neo_kwargs(cls, folder_path, exclude_filename, strict_gap_mode):
neo_kwargs = {"dirname": str(folder_path), "exclude_filename": exclude_filename}
if version("neo") >= "0.13.1":
neo_kwargs["strict_gap_mode"] = strict_gap_mode

return neo_kwargs


Expand Down
Loading