Skip to content

Commit

Permalink
Merge pull request #2459 from h-mayorquin/avoid_double_parsing_in_neo
Browse files Browse the repository at this point in the history
avoid double parsing in Plexon
  • Loading branch information
samuelgarcia authored Feb 2, 2024
2 parents ef6ddbf + 6910abc commit 7afa822
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class _NeoBaseExtractor:
NeoRawIOClass = None

def __init__(self, block_index, **neo_kwargs):
if not hasattr(self, "neo_reader"): # Avoid double initialization

# Avoids double initiation of the neo reader if it was already done in the __init__ of the child class
if not hasattr(self, "neo_reader"):
self.neo_reader = self.get_neo_io_reader(self.NeoRawIOClass, **neo_kwargs)

if self.neo_reader.block_count() > 1 and block_index is None:
Expand Down
5 changes: 2 additions & 3 deletions src/spikeinterface/extractors/neoextractors/plexon.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, file_path, stream_id=None, stream_name=None, all_annotations=
NeoBaseRecordingExtractor.__init__(
self, stream_id=stream_id, stream_name=stream_name, all_annotations=all_annotations, **neo_kwargs
)
self._kwargs.update({"file_path": str(Path(file_path).absolute())})
self._kwargs.update({"file_path": str(Path(file_path).resolve())})

@classmethod
def map_to_neo_kwargs(cls, file_path):
Expand Down Expand Up @@ -60,10 +60,9 @@ class PlexonSortingExtractor(NeoBaseSortingExtractor):
def __init__(self, file_path):
neo_kwargs = self.map_to_neo_kwargs(file_path)
self.neo_reader = NeoBaseSortingExtractor.get_neo_io_reader(self.NeoRawIOClass, **neo_kwargs)
self.neo_reader.parse_header()
sampling_frequency = self.neo_reader._global_ssampling_rate
NeoBaseSortingExtractor.__init__(self, sampling_frequency=sampling_frequency, **neo_kwargs)
self._kwargs = {"file_path": str(Path(file_path).absolute())}
self._kwargs = {"file_path": str(Path(file_path).resolve())}

@classmethod
def map_to_neo_kwargs(cls, file_path):
Expand Down

0 comments on commit 7afa822

Please sign in to comment.