From ce7338e1bef86448c8c94bbde070745a83070592 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Thu, 12 Sep 2024 09:28:09 -0600 Subject: [PATCH 1/3] expose reading attempts --- .../extractors/neoextractors/plexon2.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/spikeinterface/extractors/neoextractors/plexon2.py b/src/spikeinterface/extractors/neoextractors/plexon2.py index 2f360ed864..7a5f463fef 100644 --- a/src/spikeinterface/extractors/neoextractors/plexon2.py +++ b/src/spikeinterface/extractors/neoextractors/plexon2.py @@ -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. + readding_attemps : 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 -------- @@ -37,7 +41,15 @@ class Plexon2RecordingExtractor(NeoBaseRecordingExtractor): NeoRawIOClass = "Plexon2RawIO" - def __init__(self, file_path, stream_id=None, stream_name=None, use_names_as_ids=True, all_annotations=False): + def __init__( + self, + file_path, + stream_id=None, + stream_name=None, + use_names_as_ids=True, + all_annotations=False, + readding_attemps: int = 25, + ): neo_kwargs = self.map_to_neo_kwargs(file_path) NeoBaseRecordingExtractor.__init__( self, @@ -45,6 +57,7 @@ def __init__(self, file_path, stream_id=None, stream_name=None, use_names_as_ids stream_name=stream_name, all_annotations=all_annotations, use_names_as_ids=use_names_as_ids, + readding_attemps=readding_attemps, **neo_kwargs, ) self._kwargs.update({"file_path": str(file_path)}) From 98cd18d7d7dca067a20eb626067fd90ae784a7b8 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Thu, 12 Sep 2024 10:06:22 -0600 Subject: [PATCH 2/3] take into account neo version --- .../extractors/neoextractors/plexon2.py | 17 +++++++++++++---- .../extractors/tests/test_neoextractors.py | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/spikeinterface/extractors/neoextractors/plexon2.py b/src/spikeinterface/extractors/neoextractors/plexon2.py index 7a5f463fef..1f0d40a253 100644 --- a/src/spikeinterface/extractors/neoextractors/plexon2.py +++ b/src/spikeinterface/extractors/neoextractors/plexon2.py @@ -48,23 +48,32 @@ def __init__( stream_name=None, use_names_as_ids=True, all_annotations=False, - readding_attemps: int = 25, + reading_attempts: int = 25, ): - neo_kwargs = self.map_to_neo_kwargs(file_path) + neo_kwargs = self.map_to_neo_kwargs(file_path, reading_attempts=reading_attempts) NeoBaseRecordingExtractor.__init__( self, stream_id=stream_id, stream_name=stream_name, all_annotations=all_annotations, use_names_as_ids=use_names_as_ids, - readding_attemps=readding_attemps, **neo_kwargs, ) 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 diff --git a/src/spikeinterface/extractors/tests/test_neoextractors.py b/src/spikeinterface/extractors/tests/test_neoextractors.py index acd7ebe8ad..33d02fbde2 100644 --- a/src/spikeinterface/extractors/tests/test_neoextractors.py +++ b/src/spikeinterface/extractors/tests/test_neoextractors.py @@ -359,7 +359,7 @@ class Plexon2RecordingTest(RecordingCommonTestSuite, unittest.TestCase): ExtractorClass = Plexon2RecordingExtractor downloads = ["plexon"] entities = [ - ("plexon/4chDemoPL2.pl2", {"stream_id": "3"}), + ("plexon/4chDemoPL2.pl2", {"stream_name": "WB-Wideband"}), ] From ae5edd6e717a2e030886079c278b67fc2de6a0b4 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Thu, 19 Sep 2024 11:55:01 -0600 Subject: [PATCH 3/3] Update src/spikeinterface/extractors/neoextractors/plexon2.py Co-authored-by: Zach McKenzie <92116279+zm711@users.noreply.github.com> --- src/spikeinterface/extractors/neoextractors/plexon2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spikeinterface/extractors/neoextractors/plexon2.py b/src/spikeinterface/extractors/neoextractors/plexon2.py index 1f0d40a253..e0604f7496 100644 --- a/src/spikeinterface/extractors/neoextractors/plexon2.py +++ b/src/spikeinterface/extractors/neoextractors/plexon2.py @@ -28,7 +28,7 @@ class Plexon2RecordingExtractor(NeoBaseRecordingExtractor): ids: ["source3.1" , "source3.2", "source3.3", "source3.4"] all_annotations : bool, default: False Load exhaustively all annotations from neo. - readding_attemps : int, default: 25 + 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.