Repository navigation
Description
Hey!
I’m In the process of analysing data recorded with the Open Ephys system (v0.4.6) using 16 tetrode shuttle drives (64ch). I've used the Spikeinterface toolbox and I’m having problems loading .continuous files in some recordings (while other sessions have no issues loading at all). The error exists within the neo site-package, so I was hoping someone here would have some advice for how I can solve this.
When I execute “recordings.append(si.read_openephys(recording_path[i], stream_name='Signals CH'))” I get the following error:
Traceback (most recent call last):
File "C:\Users\joach\anaconda3\envs\si_env\lib\site-packages\IPython\core\interactiveshell.py", line 3433, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-314ef08b03de>", line 53, in <module>
recordings.append(si.read_openephys(recording_path[i], stream_name='Signals CH'))
File "C:\Users\joach\anaconda3\envs\si_env\lib\site-packages\spikeinterface\extractors\neoextractors\openephys.py", line 220, in read_openephys
recording = OpenEphysLegacyRecordingExtractor(folder_path, **kwargs)
File "C:\Users\joach\anaconda3\envs\si_env\lib\site-packages\spikeinterface\extractors\neoextractors\openephys.py", line 56, in __init__
NeoBaseRecordingExtractor.__init__(self, stream_id=stream_id,
File "C:\Users\joach\anaconda3\envs\si_env\lib\site-packages\spikeinterface\extractors\neoextractors\neobaseextractor.py", line 43, in __init__
_NeoBaseExtractor.__init__(self, block_index, **neo_kwargs)
File "C:\Users\joach\anaconda3\envs\si_env\lib\site-packages\spikeinterface\extractors\neoextractors\neobaseextractor.py", line 25, in __init__
self.neo_reader = get_reader(self.NeoRawIOClass, **neo_kwargs)
File "C:\Users\joach\anaconda3\envs\si_env\lib\site-packages\spikeinterface\extractors\neoextractors\neobaseextractor.py", line 15, in get_reader
neo_reader.parse_header()
File "C:\Users\joach\anaconda3\envs\si_env\lib\site-packages\neo\rawio\baserawio.py", line 179, in parse_header
self._parse_header()
File "C:\Users\joach\anaconda3\envs\si_env\lib\site-packages\neo\rawio\openephysrawio.py", line 117, in _parse_header
assert np.all(diff == RECORD_SIZE), \
AssertionError: Not continuous timestamps for 100_CH1.continuous. Maybe because recording was paused/stopped.
I don’t remember pausing or stopping this recording, so I don’t think this is the reason for the error. I also don’t think the data is corrupted, as I am able to read it in my Matlab pipieline using OpenEphys’ own loading function “[data, timestamps, info] = load_open_ephys_data(inputdata)”.
I get this error with a handful of recording sessions in my dataset, and I really need to get it to work but I have no clue how to fix this error. Any insight as to how it could be fixed would be very much appreciated.
I've uploaded one of my .continuous files that elicits this error, along with the respective settings file here:
https://drive.google.com/drive/folders/1LR4zth7zluBofwv2QDiPo2ArugkyF5x9?usp=sharing
Environment:
- OS: Windows 11
- Python version 3.9.15
- Neo version 0.11.1
- NumPy version 1.21.6
Best regards
Jo
Activity
alejoe91 commentedon Feb 2, 2023
Hi @ThePuppetShow
Sorry for the delay in replying to this!
I pushed a fix in this PR (#1213). Note that I couldn't test the full io because all other files are needed.
Can you test the PR and let us know if that works for you?
Do you know how to install from an open PR?
Cheers
Alessio
ThePuppetShow commentedon Feb 2, 2023
Dear Alessio, thank you so much for looking into this : )
I have uploaded an entire session to this drive https://drive.google.com/drive/folders/18EPl6bJDsZCbRzFYPrtfrM6xJUCTCrNp?usp=sharing
Will this make it possible for you to recreate my issue?
I'm afraid that I don't understand how to install from an open PR (pull request?). I opened your link, and found the area of the code that shows the error I got, but I'm quite new to github and python so I don't know what to do from there.
Thanks again for helping me with this!
Best
Joachim
ThePuppetShow commentedon Feb 8, 2023
Small update on this issue.
I used the official loading function from OpenEphys (Matlab) to load "100_CH1.continuous" from this session, and looked at the amplitude and timestamp values.
The timestamps are not discontinuous

and the LFP value for the whole session (7 minutes) looks normal to me

The only thing I could think of is that the timestamps don't start at 0, but after 1.536 seconds. Could this be why the code thinks that there is a pause in the data?

I can also note, that when I first got this error message, it referenced the "100_ADC1.continuous" file (an unused digital input channel). I then tried to move out all files that were not channel data, and only kept the 64 "100_CH*" files. This gave the same error, but with 100_CH1.continuous at the end of the error message. In other words, it seems that the error occurs with whatever the first .continuous file is in the folder. I can read the ADC files as well with the OpenEphys code, and they start at the same timestamp and have the same number of elements.
Not sure if this helps, but its what I could figure out.
Best
J
ThePuppetShow commentedon Feb 15, 2023
Another update to this issue.
I managed to run the script from the pull request you made, and the files are loaded, giving the following Warning message:
The code does however manage to process all the 64 .continuous files in what seems to be a correct way.
However, the code breaks down later when I try to run spike sorters (mountainsort4 and spykingcircus) I think because it runs through the online Docker. I run the sorters as such with spikeinterface:
si.run_mountainsort4(recording=recording, output_folder=sortingPath, docker_image=True)
I believe that this executes the neo package from the main branch, rather than the pull request.
In other words. The pull request seems to have fixed my issue, but I get the same error once the code enters the docker image, with an error similar to the original one:
Would it be possible to unify the PR with the main branch to have the docker load the same workaround?
Best
Joachim
alejoe91 commentedon Mar 14, 2023
@ThePuppetShow a workaround for running spike sorting in docker is to save the data in binary format (which is much more efficient than the legacy open ephys format):
ThePuppetShow commentedon Mar 14, 2023
Hey, and thanks for getting back to me : )
Indeed. This would be a workaround, but unfortunately I do not have the opportunity to make new recordings. I was only physically present in the lab to perform these recordings until last year. Following a pipeline where the legacy format was used.
alejoe91 commentedon Mar 14, 2023
You wouldn't need to make new recordings. You can just load the legacy format with the NEO PR, and save it to binary in SpikeInterface.
ThePuppetShow commentedon Mar 14, 2023
Hey again.
I tried this out, and I believe that it may be a functional workaround for me. Thanks a lot for the advice!