# Error Reading Epochs

**URL:** <https://mne.discourse.group/t/error-reading-epochs/6773>\
**Category:** Support & Discussions\
**Tags:** preprocessing, eeg, epochs\
**Created:** [April 22, 2023, 1:54am UTC](https://mne.discourse.group/t/error-reading-epochs/6773 "2023-04-22T01:54:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sophie1](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sophie1](https://mne.discourse.group/u/sophie1)\
**Post date:** [April 22, 2023, 1:54am UTC](https://mne.discourse.group/t/error-reading-epochs/6773/1 "2023-04-22T01:54:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![agramfort](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@agramfort](https://mne.discourse.group/u/agramfort)\
**Post date:** [April 22, 2023, 10:37am UTC](https://mne.discourse.group/t/error-reading-epochs/6773/2 "2023-04-22T10:37:08Z")

</div>

it should work. I suspect your file is damaged.

Alex

---

<div class="post-metadata">

**Author:** ![sophie1](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sophie1](https://mne.discourse.group/u/sophie1)\
**Post date:** [April 22, 2023, 7:36pm UTC](https://mne.discourse.group/t/error-reading-epochs/6773/3 "2023-04-22T19:36:31Z")

</div>

How would I fix a damaged file?

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [April 22, 2023, 9:32pm UTC](https://mne.discourse.group/t/error-reading-epochs/6773/4 "2023-04-22T21:32:46Z")

</div>

Hello,

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.

Mathieu

---

<div class="post-metadata">

**Author:** ![sophie1](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sophie1](https://mne.discourse.group/u/sophie1)\
**Post date:** [April 22, 2023, 10:05pm UTC](https://mne.discourse.group/t/error-reading-epochs/6773/5 "2023-04-22T22:05:10Z")

</div>

This is the complete error traceback.

```python
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](https://openneuro.org/datasets/ds003626/versions/2.1.0)  
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.

---

<div class="post-metadata">

**Author:** ![dasdiptyajit](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/dasdiptyajit/32/4796_2.png) [@dasdiptyajit](https://mne.discourse.group/u/dasdiptyajit)\
**Post date:** [April 22, 2023, 11:07pm UTC](https://mne.discourse.group/t/error-reading-epochs/6773/6 "2023-04-22T23:07:16Z")

</div>

Hi @sophie1,

I can’t reproduce the error. I am on a linux machine though. Can you try to load the data using a different IDE or download the data again?

```python
In [1]: from mne import read_epochs

In [2]: fname='/home/dip_linux/Downloads/derivatives sub-01 ses-01 sub-01_ses-01_eeg-epo.fif'

In [3]: epochs= read_epochs(fname)
Reading /home/dip_linux/Downloads/derivatives sub-01 ses-01 sub-01_ses-01_eeg-epo.fif ...
Isotrak not found
    Found the data of interest:
        t = -500.00 ... 4000.00 ms
        0 CTF compensation matrices available
Not setting metadata
200 matching events found
No baseline correction applied
0 projection items activated

In [4]: epochs.info
Out[4]: 
<Info | 10 non-empty values
 bads: []
 ch_names: A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, ...
 chs: 128 EEG
 custom_ref_applied: True
 file_id: 4 items (dict)
 highpass: 0.5 Hz
 lowpass: 100.0 Hz
 meas_date: 2019-08-20 10:57:41 UTC
 meas_id: 4 items (dict)
 nchan: 128
 projs: []
 sfreq: 256.0 Hz

In [5]: epochs.plot()
Using qt as 2D backend.
Out[5]: <mne_qt_browser._pg_figure.MNEQtBrowser at 0x7f7816e676d0>

```

Apparently, file id is also readable.

```python
In [6]: epochs.info['file_id']
Out[6]: 
{'version': 65540,
 'machid': array([808661043, 808661043], dtype=int32),
 'secs': 0,
 'usecs': 2147483647}

```

best,  
Dip

---

<div class="post-metadata">

**Author:** ![sophie1](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sophie1](https://mne.discourse.group/u/sophie1)\
**Post date:** [April 23, 2023, 1:39am UTC](https://mne.discourse.group/t/error-reading-epochs/6773/7 "2023-04-23T01:39:53Z")

</div>

Update: I redownloaded the dataset and it is working now. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)\
**Post date:** [April 23, 2023, 2:52pm UTC](https://mne.discourse.group/t/error-reading-epochs/6773/8 "2023-04-23T14:52:19Z")

</div>

Ah an `openneuro` one; it happens often that the dataset is broken after download. Personally, I use [openneuro-py](https://github.com/hoechenberger/openneuro-py) to download `openneuro` datasets, I had less trouble with this download method.
