Skip to content

Commit a606364

Browse files
authored
Merge pull request #3401 from h-mayorquin/expose_attempts_in_plexon2
Expose reading attempts in Plexon2
2 parents 65d4b1e + 94ab456 commit a606364

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/spikeinterface/extractors/neoextractors/plexon2.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class Plexon2RecordingExtractor(NeoBaseRecordingExtractor):
2828
ids: ["source3.1" , "source3.2", "source3.3", "source3.4"]
2929
all_annotations : bool, default: False
3030
Load exhaustively all annotations from neo.
31+
reading_attempts : int, default: 25
32+
Number of attempts to read the file before raising an error
33+
This opening process is somewhat unreliable and might fail occasionally. Adjust this higher
34+
if you encounter problems in opening the file.
3135
3236
Examples
3337
--------
@@ -37,8 +41,16 @@ class Plexon2RecordingExtractor(NeoBaseRecordingExtractor):
3741

3842
NeoRawIOClass = "Plexon2RawIO"
3943

40-
def __init__(self, file_path, stream_id=None, stream_name=None, use_names_as_ids=True, all_annotations=False):
41-
neo_kwargs = self.map_to_neo_kwargs(file_path)
44+
def __init__(
45+
self,
46+
file_path,
47+
stream_id=None,
48+
stream_name=None,
49+
use_names_as_ids=True,
50+
all_annotations=False,
51+
reading_attempts: int = 25,
52+
):
53+
neo_kwargs = self.map_to_neo_kwargs(file_path, reading_attempts=reading_attempts)
4254
NeoBaseRecordingExtractor.__init__(
4355
self,
4456
stream_id=stream_id,
@@ -50,8 +62,18 @@ def __init__(self, file_path, stream_id=None, stream_name=None, use_names_as_ids
5062
self._kwargs.update({"file_path": str(file_path)})
5163

5264
@classmethod
53-
def map_to_neo_kwargs(cls, file_path):
65+
def map_to_neo_kwargs(cls, file_path, reading_attempts: int = 25):
66+
5467
neo_kwargs = {"filename": str(file_path)}
68+
69+
from packaging.version import Version
70+
import neo
71+
72+
neo_version = Version(neo.__version__)
73+
74+
if neo_version > Version("0.13.3"):
75+
neo_kwargs["reading_attempts"] = reading_attempts
76+
5577
return neo_kwargs
5678

5779

src/spikeinterface/extractors/tests/test_neoextractors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class Plexon2RecordingTest(RecordingCommonTestSuite, unittest.TestCase):
368368
ExtractorClass = Plexon2RecordingExtractor
369369
downloads = ["plexon"]
370370
entities = [
371-
("plexon/4chDemoPL2.pl2", {"stream_id": "3"}),
371+
("plexon/4chDemoPL2.pl2", {"stream_name": "WB-Wideband"}),
372372
]
373373

374374

0 commit comments

Comments
 (0)