# annotating .edf file

**URL:** https://mne.discourse.group/t/annotating-edf-file/4561
**Category:** Support & Discussions
**Created:** [March 16, 2022, 10:03am UTC](https://mne.discourse.group/t/annotating-edf-file/4561 "2022-03-16T10:03:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MBhuvi](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@MBhuvi](https://mne.discourse.group/u/MBhuvi)
#### Post date: [March 16, 2022, 10:03am UTC](https://mne.discourse.group/t/annotating-edf-file/4561/1 "2022-03-16T10:03:28Z")

</div>

```python
raw_train = mne.io.read_raw_edf('C:/Users/Admin/Downloads/wesley_annot2022.03.11_12.18.26.edf', stim_channel=None)
annot_train = mne.read_annotations(raw_train)

raw_train.set_annotations(annot_train, emit_warning=False)

raw_train.plot(start=60, duration=60,
               scalings=dict(eeg=1e-4, resp=1e3, eog=1e-4, emg=1e-7,
                             misc=1e-1))

```

while running this code I get the following error:

```python
Extracting EDF parameters from C:\Users\Admin\Downloads\wesley_annot2022.03.11_12.18.26.edf...
EDF file detected
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-e3a998e7f9d8> in <module>
----> 1 raw_train = mne.io.read_raw_edf('C:/Users/Admin/Downloads/wesley_annot2022.03.11_12.18.26.edf', stim_channel=None)
      2 annot_train = mne.read_annotations(raw_train)
      3 
      4 raw_train.set_annotations(annot_train, emit_warning=False)
      5 

~\anaconda3\lib\site-packages\mne\io\edf\edf.py in read_raw_edf(input_fname, eog, misc, stim_channel, exclude, preload, verbose)
   1218 raise NotImplementedError(
   1219 'Only EDF files are supported by read_raw_edf, got %s' % (ext,))
-> 1220 return RawEDF(input_fname=input_fname, eog=eog, misc=misc,
   1221 stim_channel=stim_channel, exclude=exclude, preload=preload,
   1222 verbose=verbose)

<decorator-gen-197> in __init__ (self, input_fname, eog, misc, stim_channel, exclude, preload, verbose)

~\anaconda3\lib\site-packages\mne\io\edf\edf.py in __init__ (self, input_fname, eog, misc, stim_channel, exclude, preload, verbose)
    112 logger.info('Extracting EDF parameters from {}...'.format(input_fname))
    113 input_fname = os.path.abspath(input_fname)
--> 114 info, edf_info, orig_units = _get_info(input_fname,
    115 stim_channel, eog, misc,
    116 exclude, preload)

~\anaconda3\lib\site-packages\mne\io\edf\edf.py in _get_info(fname, stim_channel, eog, misc, exclude, preload)
    356 misc = misc if misc is not None else []
    357 
--> 358 edf_info, orig_units = _read_header(fname, exclude)
    359 
    360 # XXX: `tal_ch_names` to pass to `_check_stim_channel` should be computed

~\anaconda3\lib\site-packages\mne\io\edf\edf.py in _read_header(fname, exclude)
    343 logger.info('%s file detected' % ext.upper())
    344 if ext in ('bdf', 'edf'):
--> 345 return _read_edf_header(fname, exclude)
    346 elif ext == 'gdf':
    347 return _read_gdf_header(fname, exclude), None

~\anaconda3\lib\site-packages\mne\io\edf\edf.py in _read_edf_header(fname, exclude)
    569 else:
    570 meas_date = fid.read(8).decode('latin-1')
--> 571 day, month, year = [int(x) for x in meas_date.split('.')]
    572 year = year + 2000 if year < 85 else year + 1900
    573 

~\anaconda3\lib\site-packages\mne\io\edf\edf.py in <listcomp>(.0)
    569 else:
    570 meas_date = fid.read(8).decode('latin-1')
--> 571 day, month, year = [int(x) for x in meas_date.split('.')]
    572 year = year + 2000 if year < 85 else year + 1900
    573 

ValueError: invalid literal for int() with base 10: ''

```

Kindly help me to fix this error.

---

<div class="post-metadata">

### Author: ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)
#### Post date: [March 16, 2022, 4:35pm UTC](https://mne.discourse.group/t/annotating-edf-file/4561/2 "2022-03-16T16:35:10Z")

</div>

It would really help readers if you formatted your code in your question correctly (I’ve done this for you now).

Regarding the issue, `mne.read_annotations()` takes the filename as the first input argument, but you are trying to load that file with `mne.io.read_raw_edf()`. Can you try to run

```python
annot_train = mne.read_annotations('C:/Users/Admin/Downloads/wesley_annot2022.03.11_12.18.26.edf')

```

to see if this fixes the problem?

---

<div class="post-metadata">

### Author: ![MBhuvi](https://avatars.discourse-cdn.com/v4/letter/m/edb3f5/32.png) [@MBhuvi](https://mne.discourse.group/u/MBhuvi)
#### Post date: [March 17, 2022, 3:56am UTC](https://mne.discourse.group/t/annotating-edf-file/4561/3 "2022-03-17T03:56:54Z")

</div>

Thank you @cbrnr for your support. I will structure my code from now on. I was now able to read the annotations. thank you so much.
