Skip to content

Commit

Permalink
Merge pull request #3401 from h-mayorquin/expose_attempts_in_plexon2
Browse files Browse the repository at this point in the history
Expose reading attempts in Plexon2
  • Loading branch information
alejoe91 authored Oct 18, 2024
2 parents 65d4b1e + 94ab456 commit a606364
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
28 changes: 25 additions & 3 deletions src/spikeinterface/extractors/neoextractors/plexon2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class Plexon2RecordingExtractor(NeoBaseRecordingExtractor):
ids: ["source3.1" , "source3.2", "source3.3", "source3.4"]
all_annotations : bool, default: False
Load exhaustively all annotations from neo.
reading_attempts : int, default: 25
Number of attempts to read the file before raising an error
This opening process is somewhat unreliable and might fail occasionally. Adjust this higher
if you encounter problems in opening the file.
Examples
--------
Expand All @@ -37,8 +41,16 @@ class Plexon2RecordingExtractor(NeoBaseRecordingExtractor):

NeoRawIOClass = "Plexon2RawIO"

def __init__(self, file_path, stream_id=None, stream_name=None, use_names_as_ids=True, all_annotations=False):
neo_kwargs = self.map_to_neo_kwargs(file_path)
def __init__(
self,
file_path,
stream_id=None,
stream_name=None,
use_names_as_ids=True,
all_annotations=False,
reading_attempts: int = 25,
):
neo_kwargs = self.map_to_neo_kwargs(file_path, reading_attempts=reading_attempts)
NeoBaseRecordingExtractor.__init__(
self,
stream_id=stream_id,
Expand All @@ -50,8 +62,18 @@ def __init__(self, file_path, stream_id=None, stream_name=None, use_names_as_ids
self._kwargs.update({"file_path": str(file_path)})

@classmethod
def map_to_neo_kwargs(cls, file_path):
def map_to_neo_kwargs(cls, file_path, reading_attempts: int = 25):

neo_kwargs = {"filename": str(file_path)}

from packaging.version import Version
import neo

neo_version = Version(neo.__version__)

if neo_version > Version("0.13.3"):
neo_kwargs["reading_attempts"] = reading_attempts

return neo_kwargs


Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/extractors/tests/test_neoextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class Plexon2RecordingTest(RecordingCommonTestSuite, unittest.TestCase):
ExtractorClass = Plexon2RecordingExtractor
downloads = ["plexon"]
entities = [
("plexon/4chDemoPL2.pl2", {"stream_id": "3"}),
("plexon/4chDemoPL2.pl2", {"stream_name": "WB-Wideband"}),
]


Expand Down

0 comments on commit a606364

Please sign in to comment.