eegdash.io.mef module#

MNE’s MEF3 reader, refusing a session that would crash pymef.

pymef 1.4.8 (meflib) does not check that a segment has its files: a .segd holding only its .tmet (on004624 sub-c04 Longterm Passive run-10, channel CH20; the OpenNeuro deposit has no .tdat/.tidx there either) ends the process with SIGSEGV in read_mef_session_metadata, which killed the on004624 read-check job twice. The session is checked first and refused with a Python error, so one bad recording no longer takes the whole job down.

MNE refuses a session whose channels have different lengths (“MEF channels have inconsistent n_samples”). In on004624 the 32 neural channels start 0.1-0.2 s after the aux channels (accelerometers, BCI2000 states) and they all end together; in some sessions a channel ends a few samples early. With one rate, starts a whole number of samples apart, and the same discontinuities, every channel is read on the time window they all have, so sample i is the same time on every channel: leading samples of the earlier channels and the tail of the longer ones are dropped, with a warning that names them per channel. events.tsv onsets, counted from the earliest start, are moved back by the dropped lead (bids.py). In two sessions the neural channels also skip 0.1 s right after their start; the window then starts after that gap, if that only drops a short leading part. Nothing is padded; anything else is refused.

eegdash.io.mef.check_session(fname)[source]

Raise ValueError if a time-series segment lacks one of its files.

eegdash.io.mef.crop_to_common_window(session)[source]

Read every channel on the time window they all have, in the metadata MNE reads.

A channel that starts k samples later than another (on004624: 100-200 samples, the channels ending together) is read from the later start: the earlier channels lose k leading samples, the longer ones their tail. Only for one rate, starts a whole number of samples apart, and discontinuities at the same times inside the window, so sample i is the same time on every channel. pymef reads samples by index per channel, so MNE’s read is shifted per channel.

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

Check MEF3 sessions before pymef opens them; read channels on a common window.

eegdash.io.mef.read_raw_mef(fname, *args, **kwargs)[source]

Read a MEF3 session with mne.io.read_raw_mef() under fixes().