eegdash.io.bids module#

MNE-BIDS’s read_raw_bids, tolerant of two sidecar layouts real deposits have.

Each fix patches one global of MNE-BIDS 0.20 (read.py, tsv_handler.py; unchanged on main 085e309 as of 2026-10-18); the upstream PRs are still to be written:

  • RecordingType: "epoched" on a continuous container (.vhdr, .edf, .bdf): read_raw_bids refuses the file and points to read_epochs_bids, which slices it with EpochLength and fails on most real events.tsv files (no EpochLength, stimulus rows, empty or non-integer events). The file on disk is continuous, so it is read as Raw; events.tsv still becomes annotations. Only .set with trials is refused.

  • An events.tsv column named after a reserved mne.Annotations key (description in nm000536) makes the extras raise ValueError; the column is kept as events_<name>.

  • A negative events.tsv duration (on004703: -16.35 s) trips an assertion in mne.Annotations.crop; it becomes 0 and a warning is logged.

  • A participants.tsv age that is not an age in years (nm000149: the year 2018) puts the birthday, meas_date - age, before year 1: OverflowError. The birthday is left unset, as MNE-BIDS does when meas_date is unknown; the other participant fields are kept.

  • A TSV that is not UTF-8 (on004588 sub-S37 events.tsv): MNE-BIDS checks only the first 64 KiB for UTF-8 and otherwise reads latin-1, so a later non-UTF-8 byte raises UnicodeDecodeError, and cp1252 characters (–, €, ’) come back as control characters. The whole file is checked, and cp1252 is tried before latin-1. This replaces EEGDash’s rewrite of the cached TSV to UTF-8, which made every new session download it again.

  • A reader that drops a recording’s leading samples (mef.py: on004624’s neural channels start 0.1-0.2 s after its aux channels) sets raw._eegdash_lead_s; events.tsv onsets, counted from the earliest start, are moved back by as much so they stay on the same samples.

Several space- electrodes files matching a recording equally well (nm000485 space-Other and space-Talairach) make MNE-BIDS read no positions, and BIDSPath(space=) would rename the data file too. The electrodes and coordsystem lookups then take one space: a named coordinate system before Other, then alphabetical. Positions are never merged across spaces.

without_events() reads a recording as if it had no events.tsv, for an events file MNE-BIDS cannot turn into annotations. Only reads in the calling thread are affected; nothing in the dataset folder is renamed, so other runs read in parallel keep their own events.

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

Patch MNE-BIDS’s reader globals while reading.

eegdash.io.bids.tsv_encoding(fname)[source]

Return the encoding to read the TSV fname with (UTF-8, else cp1252, else latin-1).

Replaces mne_bids.tsv_handler._detect_file_encoding while reading.

eegdash.io.bids.without_events()[source]

Make read_raw_bids in this thread (or task) skip the events sidecars.