eegdash.io.edf module#

MNE’s EDF/BDF reader, tolerant of an invalid start time, explicit about a bad header.

The fixes wrap _read_edf_header of mne/io/edf/edf.py (MNE 1.13, unchanged on main as of 2026-10-18); the upstream PR is still to be written:

  • A start time with 60 seconds (10.47.60: on003555, on003775, on004381, on004752) makes datetime.replace raise ValueError: second must be in 0..59 after the date was read, so the whole file is refused. MNE already reads a file whose start date is invalid, with meas_date unset and the warning “Invalid measurement date encountered in the header.”; an invalid start time now goes the same way. No date or time is made up.

  • A header whose header-size field disagrees with its number of signals fails a bare assert. on003343 (59 BDF): 20 signals take 5376 bytes, the field says 4608 (or 4352), and the file size is exactly field + n_records x record size: the writer put the data at the field’s offset, then wrote the full header over its first 768 (1024) bytes. MNE already reads the data from the field’s offset; it gets the header with the field corrected, in memory, and the samples of the first channel under the header are annotated BAD_header_overlap (kept by read_raw_bids), with an eegdash warning. Any other mismatch is refused with a ValueError that says why (“Bad EDF/BDF header: …”). Nothing is written; once the deposit has a correct header (nemarDatasets/on003343#3) this path is not taken.

  • MNE scales a channel by its header unit only for µV and mV; any other unit, nV included, is read as is. nV and pV are scaled, and a channel whose header range reads beyond 1 V (a voltage) or 100 rad is reported with an eegdash warning: nm000281 stored joint angles as rad x 1e6 under rad, so MNE read them up to 2e6 rad. Nothing is changed for such a channel.

eegdash.io.edf.fixes()[source]

Patch MNE’s EDF/BDF header reader while reading.

eegdash.io.edf.read_raw_bdf(input_fname, **kwargs)[source]

Read a BDF file with mne.io.read_raw_bdf() under fixes().

eegdash.io.edf.read_raw_edf(input_fname, **kwargs)[source]

Read an EDF file with mne.io.read_raw_edf() under fixes().