Hey everyone. I have been running into an issue in my code.
I have a list of files that are formatted similarly to this.
‘IS_data/derivatives/sub-01/ses-01/sub-01_ses-01_eeg-epo.fif’
According to the api reference, the mne.read_epochs function reads epoch data that ends with ‘-epo.fif’ I formatted my code as below:
mne.read_epochs(‘IS_data/derivatives/sub-01/ses-01/sub-01_ses-01_eeg-epo.fif’)
I figured it would work perfectly with the data I have. Instead I keep getting this error:
File line 126, in fiff_open
return _fiff_open(fname, fid, preload)
File line 145, in _fiff_open
raise ValueError(f’{prefix} start with a file id tag’)
ValueError: file does not start with a file id tag
Does anyone have any ideas as to why this is happening? If so please let me know. I am very confused!
MNE version: e.g. 0.24.0
operating system: e.g. macOS 12 / Windows 10 / Ubuntu 18.04
Could you share the file and the complete error traceback?
There is a chance that what is stored in this FIF file is not Epochs but something else (despite the ending "-epo" matching the convention), in which case a different reader should be used to open it.
Also, try to update your MNE version. 0.24 is a couple of years old, many bugs have been fixed and improvements added. A recent version might be able to load your file.
And finally, if the file is really damaged, there is little to be done.
Traceback (most recent call last):
File "/Users/sophieeisenberg/PycharmProjects/innerSpeech/main.py", line 18, in <module>
epoch = mne.read_epochs(path)
File "<decorator-gen-282>", line 12, in read_epochs
File "/Users/sophieeisenberg/opt/anaconda3/lib/python3.9/site-packages/mne/epochs.py", line 3175, in read_epochs
return EpochsFIF(fname, proj, preload, verbose)
File "<decorator-gen-283>", line 12, in __init__
File "/Users/sophieeisenberg/opt/anaconda3/lib/python3.9/site-packages/mne/epochs.py", line 3234, in __init__
fid, tree, _ = fiff_open(fname, preload=preload)
File "<decorator-gen-9>", line 12, in fiff_open
File "/Users/sophieeisenberg/opt/anaconda3/lib/python3.9/site-packages/mne/io/open.py", line 126, in fiff_open
return _fiff_open(fname, fid, preload)
File "/Users/sophieeisenberg/opt/anaconda3/lib/python3.9/site-packages/mne/io/open.py", line 145, in _fiff_open
raise ValueError(f'{prefix} start with a file id tag')
ValueError: file '/Users/sophieeisenberg/PycharmProjects/innerSpeech/IS_data/derivatives/sub-01/ses-01/sub-01_ses-01_eeg-epo.fif' does not start with a file id tag
Reading /Users/sophieeisenberg/PycharmProjects/innerSpeech/IS_data/derivatives/sub-01/ses-01/sub-01_ses-01_eeg-epo.fif ...
I am not sure how to upload the file, but this is the link to the dataset I am using: OpenNeuro
I am attempting to read the file: sub-01_ses-01_eeg-epo.fif
My MNE version is actually 1.3.1, I mistyped, and I am on a mac. Thank you so much for the help.
Ah an openneuro one; it happens often that the dataset is broken after download. Personally, I use openneuro-py to download openneuro datasets, I had less trouble with this download method.