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.

inconsistencies in edf reader and annotation readers

See original GitHub issue

I have a couple of issues here but bunching them together as they seem related.

1. EDF reader should work with preload=False

If I do:

import mne
from mne.datasets import eegbci
edf_path = eegbci.load_data(subject=1, runs=2)[0]
raw = mne.io.read_raw_edf(edf_path, preload=False)

I get

RuntimeError: EDF+ Annotations (TAL) channel needs to be parsed completely on loading. You must set preload parameter to True.

However, I can actually do:

import mne
from mne.datasets import eegbci
from mne.io.edf.edf import read_annotations_edf

edf_path = eegbci.load_data(subject=1, runs=2)[0]
raw = mne.io.read_raw_edf(edf_path, preload=False, stim_channel=None)

annot = read_annotations_edf(edf_path)
raw.set_annotations(annot)

and it gives me the same result as:

raw2 = mne.io.read_raw_edf(edf_path, preload=True)
assert raw.annotations.duration[0] == raw2.annotations.duration[0]

So, it seems to me that it should already be possible to load EDF files with preload=False as all the necessary components already exist.

2. find_edf_events and mne.events_from_annotations don’t give same results

Here is the code to reproduce (continuing from code above):

events, event_id = mne.events_from_annotations(raw)
events2 = raw.find_edf_events()
print(events)
print(events2)

3. namespaces of read_annotations_xxx

I have to do:

from mne import read_annotations  # for fif files
from mne.io import read_annotations_brainvision  # for brainvision
from mne.io import read_annotations_eeglab  # for eeglab
from mne.io.edf.edf import read_annotations_edf  # for edf

This is quite confusing. In fact, I don’t see a good rational for having different functions as all these different file formats (debatable) since all you need is a filename for most of these readers. So you should be able to triage based on the extension. In any case, having them in the same namespace would already be a start ! (and maybe read_annotations -> read_annotations_fif ?)

4. documentation issues

read_annotations_edf says I need a .vmrk file. This looks incorrect, right?

Happy to help out with these after the mne-bids release. If someone else has time to work before (@massich ?), I am happy to review the code 😃

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
larsonercommented, Nov 5, 2018

FYI to me it is weird to have a read_annotations that triages by file type but no read_raw that does the same. The more consistent fix would be to have read_annotations renamed to read_annotations_fif. But I can live with the inconsistency.

0reactions
larsonercommented, Nov 6, 2018

The conversation went a bit off-topic (to mne.io.read_raw), I think it’s fine to leave closed

Read more comments on GitHub >

github_iconTop Results From Across the Web

EDF/BDF file reader edfreader - PyEDFlib - Read the Docs
CyEdfReader. This provides a simple interface to read EDF, EDF+, BDF and BDF+ files. ... readAnnotations (self), Annotations from a edf-file.
Read more >
EDFbrowser manual
EDF (+)/BDF(+) to ASCII (CSV) format converter. Reduce signals, duration and/or samplerate. Export filtered signals. Export annotations/events.
Read more >
EDF FAQ - European Data Format
EDF FAQ. Important: this FAQ only applies to EDF, NOT to EDF+! EDF+ solved all EDF problems mentioned below, but not allways according...
Read more >
edfReader vignette
The reading of signals can be restricted to a specific set by using the signals parameter. Signals can be identified by their EDF...
Read more >
Reading ".edf" file - MATLAB Answers - MathWorks
The errors don't seem to have anything whatsoever to do with the file name but the content of the file. The first message...
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