question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

trying to import edf file using mne on linux.

See original GitHub issue

Please check the below code and suggest edit. When I run the same in windows, it works. the package versions are identical.

>>> data  = mne.io.read_raw_edf('eeg1.edf',preload=True)

Extracting EDF parameters from /wsu/home/ha/ha82/ha8276/Desktop/EEG/eeg1.edf...
EDF file detected

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-11-8c2213f7e7ee> in <module>
----> 1 data  = mne.io.read_raw_edf('eeg1.edf',preload=True,exclude='meas_date')

~/.local/lib/python3.7/site-packages/mne/io/edf/edf.py in read_raw_edf(input_fname, eog, misc, stim_channel, exclude, preload, verbose)
   1179     return RawEDF(input_fname=input_fname, eog=eog, misc=misc,
   1180                   stim_channel=stim_channel, exclude=exclude, preload=preload,
-> 1181                   verbose=verbose)
   1182 
   1183 

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

~/.local/lib/python3.7/site-packages/mne/io/edf/edf.py in __init__(self, input_fname, eog, misc, stim_channel, exclude, preload, verbose)
    113         info, edf_info, orig_units = _get_info(input_fname,
    114                                                stim_channel, eog, misc,
--> 115                                                exclude, preload)
    116         logger.info('Creating raw.info structure...')
    117 

~/.local/lib/python3.7/site-packages/mne/io/edf/edf.py in _get_info(fname, stim_channel, eog, misc, exclude, preload)
    375     misc = misc if misc is not None else []
    376 
--> 377     edf_info, orig_units = _read_header(fname, exclude)
    378 
    379     # XXX: `tal_ch_names` to pass to `_check_stim_channel` should be computed

~/.local/lib/python3.7/site-packages/mne/io/edf/edf.py in _read_header(fname, exclude)
    362     logger.info('%s file detected' % ext.upper())
    363     if ext in ('bdf', 'edf'):
--> 364         return _read_edf_header(fname, exclude)
    365     elif ext in ('gdf'):
    366         return _read_gdf_header(fname, exclude), None

~/.local/lib/python3.7/site-packages/mne/io/edf/edf.py in _read_edf_header(fname, exclude)
    543         century = 2000 if year < 50 else 1900
    544         meas_date = datetime(year + century, month, day, hour, minute, sec,
--> 545                              tzinfo=timezone.utc)
    546 
    547         header_nbytes = int(fid.read(8).decode())

ValueError: month must be in 1..12

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
harmeet9307commented, Jul 27, 2020

I figured it out. there were some issues with the edf files I downloaded. Works fine with another batch of files. Thank you are all the help

0reactions
drammockcommented, Jul 22, 2020

Can you do a %debug after you get the error and let us know the values of month and the other date-related ones?

This is still the logical next step in debugging, and since none of us can replicate your error, you’ll need to do this yourself @harmeet9307

Since it looks like you’re not using ipython, the equivalent of %debug would be import pdb; pdb.pm() to enter the debugger immediately after the error occurs. from there you should be able to view the values of the variables year, month, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

problems when loading edf file · Issue #6091 · mne ... - GitHub
I lose the miliseconds in raw.info['meas_date'] (despite being in the file); when I do mne.find_events(raw) (when stim_channel is present) I get ...
Read more >
mne.io.read_raw_edf — MNE 1.2.2 documentation
Reader function for EDF or EDF+ files. ... If True, try to infer channel types from channel labels. If a channel label starts...
Read more >
Getting error to read edf file using mne-python - Stack Overflow
Better you try to be in the exact directory and try reading the file, i.e go to your home directory and then try...
Read more >
EDF downloads - European Data Format
This page aims to list all freely available EDF(+) files and software, ... If you want to try it, just start with the...
Read more >
How to read edf data in Python 3 - Intellipaat Community
Try using MNE library. Try the below code: import mne. file = "my_path\\my_file.edf". data = mne.io.read_raw_edf(file).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found