NeuralEnsemble / python-neo

Neo is a package for representing electrophysiology data in Python, together with support for reading a wide range of neurophysiology file formats
http://neo.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
316 stars 249 forks source link

EDF blocks access when io is opened. #1557

Open h-mayorquin opened 3 days ago

h-mayorquin commented 3 days ago

This is coming from here in Spikeinterface:

https://github.com/SpikeInterface/spikeinterface/issues/1228

Here, basically this format can't only be opened once per file-system.

from pathlib import Path

from spikeinterface.extractors import EDFRecordingExtractor
from spikeinterface.core.base import _load_extractor_from_dict

file_path = Path("/home/heberto/neuroconv_testing_data/ephy_testing_data/edf/edf+C.edf")

recorder = EDFRecordingExtractor(file_path=file_path)
recorder_dict = recorder.to_dict()
recorder_from_dict = _load_extractor_from_dict(recorder_dict)

  File "/home/heberto/miniconda3/envs/spikeinterface_env/lib/python3.10/site-packages/neo/rawio/edfrawio.py", line 70, in _parse_header
    self.edf_reader = EdfReader(self.filename)
  File "pyedflib/_extensions/_pyedflib.pyx", line 146, in pyedflib._extensions._pyedflib.CyEdfReader.__init__
  File "pyedflib/_extensions/_pyedflib.pyx", line 209, in pyedflib._extensions._pyedflib.CyEdfReader.open
  File "pyedflib/_extensions/_pyedflib.pyx", line 181, in pyedflib._extensions._pyedflib.CyEdfReader.check_open_ok
OSError: /home/heberto/neuroconv_testing_data/ephy_testing_data/edf/edf+C.edf: file has already been opened
zm711 commented 3 days ago

Wasn't this a long term issue. I have no clue how to fix. Since you have some data from somewhere are you okay trying to make a fix?

h-mayorquin commented 3 days ago

Yeah, unfortunately, the fix would be to redo the IO entirely as we use a library for this one and is blocking. I don't think it would be too hard but I would be more weary about testing it.

h-mayorquin commented 3 days ago

Mmm now that I think about it, we could use MNE. That should be easier.

zm711 commented 3 days ago

Yeah if it's possible. That'd be cool.