Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/spikeinterface/extractors/neoextractors/biocam.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(
)

@classmethod
def map_to_neo_kwargs(cls, file_path, fill_gaps_strategy):
def map_to_neo_kwargs(cls, file_path, fill_gaps_strategy=None):
neo_kwargs = {
"filename": str(file_path),
"fill_gaps_strategy": fill_gaps_strategy,
Expand Down
16 changes: 8 additions & 8 deletions src/spikeinterface/extractors/neoextractors/blackrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def __init__(
use_names_as_ids: bool = False,
gap_tolerance_ms: float | None = None,
):
neo_kwargs = self.map_to_neo_kwargs(file_path)
if gap_tolerance_ms is not None:
neo_kwargs["gap_tolerance_ms"] = gap_tolerance_ms
neo_kwargs = self.map_to_neo_kwargs(file_path, gap_tolerance_ms=gap_tolerance_ms)
neo_kwargs["load_nev"] = False # Avoid loading spikes release in neo 0.12.0

# trick to avoid to select automatically the correct stream_id
Expand All @@ -63,8 +61,10 @@ def __init__(
self._kwargs.update({"file_path": str(Path(file_path).absolute()), "gap_tolerance_ms": gap_tolerance_ms})

@classmethod
def map_to_neo_kwargs(cls, file_path):
def map_to_neo_kwargs(cls, file_path, gap_tolerance_ms=None):
neo_kwargs = {"filename": str(file_path)}
if gap_tolerance_ms is not None:
neo_kwargs["gap_tolerance_ms"] = gap_tolerance_ms
return neo_kwargs


Expand Down Expand Up @@ -109,9 +109,7 @@ def __init__(
nsx_to_load: int | list | str | None = None,
gap_tolerance_ms: float | None = None,
):
neo_kwargs = self.map_to_neo_kwargs(file_path)
if gap_tolerance_ms is not None:
neo_kwargs["gap_tolerance_ms"] = gap_tolerance_ms
neo_kwargs = self.map_to_neo_kwargs(file_path, gap_tolerance_ms=gap_tolerance_ms)
NeoBaseSortingExtractor.__init__(
self,
stream_id=stream_id,
Expand All @@ -130,8 +128,10 @@ def __init__(
}

@classmethod
def map_to_neo_kwargs(cls, file_path):
def map_to_neo_kwargs(cls, file_path, gap_tolerance_ms=None):
neo_kwargs = {"filename": str(file_path)}
if gap_tolerance_ms is not None:
neo_kwargs["gap_tolerance_ms"] = gap_tolerance_ms
return neo_kwargs


Expand Down
13 changes: 9 additions & 4 deletions src/spikeinterface/extractors/neoextractors/neuralynx.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(
)

@classmethod
def map_to_neo_kwargs(cls, folder_path, exclude_filename, strict_gap_mode):
def map_to_neo_kwargs(cls, folder_path, exclude_filename=None, strict_gap_mode=False):
neo_kwargs = {"dirname": str(folder_path), "exclude_filename": exclude_filename}
if version("neo") >= "0.13.1":
neo_kwargs["strict_gap_mode"] = strict_gap_mode
Expand All @@ -92,6 +92,9 @@ class NeuralynxSortingExtractor(NeoBaseSortingExtractor):
Used to extract information about the sampling frequency and t_start from the analog signal if provided.
stream_name : str, default: None
Used to extract information about the sampling frequency and t_start from the analog signal if provided.
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.
"""

NeoRawIOClass = "NeuralynxRawIO"
Expand All @@ -104,8 +107,9 @@ def __init__(
sampling_frequency: float | None = None,
stream_id: str | None = None,
stream_name: str | None = None,
exclude_filename: list[str] | None = None,
):
neo_kwargs = self.map_to_neo_kwargs(folder_path)
neo_kwargs = self.map_to_neo_kwargs(folder_path, exclude_filename)
NeoBaseSortingExtractor.__init__(
self,
sampling_frequency=sampling_frequency,
Expand All @@ -119,11 +123,12 @@ def __init__(
"sampling_frequency": sampling_frequency,
"stream_id": stream_id,
"stream_name": stream_name,
"exclude_filename": exclude_filename,
}

@classmethod
def map_to_neo_kwargs(cls, folder_path):
neo_kwargs = {"dirname": str(folder_path)}
def map_to_neo_kwargs(cls, folder_path, exclude_filename=None):
neo_kwargs = {"dirname": str(folder_path), "exclude_filename": exclude_filename}
return neo_kwargs


Expand Down
19 changes: 19 additions & 0 deletions src/spikeinterface/extractors/tests/common_tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pickle
import inspect

import numpy as np

Expand Down Expand Up @@ -75,6 +76,24 @@ def test_open(self):
trace_scaled = rec.get_traces(segment_index=segment_index, return_in_uV=True, end_frame=2)
assert trace_scaled.dtype == "float32"

def test_get_streams(self):
for entity in self.entities:
if isinstance(entity, tuple):
path, kwargs = entity
elif isinstance(entity, str):
path = entity
kwargs = {}

if not hasattr(self.ExtractorClass, "NeoRawIOClass"):
continue

# get_streams is called before the extractor exists, with the path and whatever neo needs to open it
neo_parameters = inspect.signature(self.ExtractorClass.map_to_neo_kwargs).parameters
neo_kwargs = {key: value for key, value in kwargs.items() if key in neo_parameters}

stream_names, stream_ids = self.ExtractorClass.get_streams(self.get_full_path(path), **neo_kwargs)
assert len(stream_names) == len(stream_ids)

def test_neo_annotations(self):
for entity in self.entities:
if isinstance(entity, tuple):
Expand Down
Loading