MEG tutorial

MEG: convert an Elekta 3-session dataset.

Two-subject Elekta MEG sample with multiple sessions per subject. The scanner reads the FIF metadata, the path structure flags two date-named subfolders as separate sessions, and the pipeline runs unchanged from MRI.

The MEG story showcases automatic session inference.

One subject in this dataset has two date-named recording folders (220209 and 220215). BIDS Manager notices the multi-date layout and assigns them to ses-1 and ses-2 automatically. The other subject has only one date folder, so no session entity is written. No user override needed.

Example data

Elekta sample (2 subjects, 3 sessions)

Two subject folders. sub_us04rt22/ holds two date-named sessions (220209 and 220215); sub_ye07us06/ holds one (220221). 23 FIF files total across the standard MEG tasks: driving (with runs), rest, empty-room pre and post.

Download MEG sample dataset →

Dataset overview

2 subjects, 3 sessions, 23 FIF files.

The MEG sample uses Elekta's standard date-named-folder convention. The scanner's subject_identity module reads each FIF's mne.info (channels, sample rate, duration) and uses path structure to cluster sessions.

MEG_Elekta_sample_data/ 23 FIFs
sub_us04rt22/ sub-001
220209/ ses-1 5 files
task_driving_run_01.fif
task_driving_run_02.fif
task_emptypre.fif
task_emptypost.fif
task_rest.fif
220215/ ses-2 9 files
task_driving_run_01_00.fif … task_driving_run_06_00.fif
task_emptypre_00.fif, task_emptypost_00.fif, task_rest_00.fif
sub_ye07us06/ sub-002
220221/ no session 9 files
task_driving_run_01.fif … task_driving_run_06.fif
task_rest.fif, task_emptypre.fif, task_emptypost.fif

How the session inference works

When the path between the subject folder and the recording contains a date-shaped token (YYMMDD or YYYY-MM-DD), the scanner treats each date as a separate session. Multiple dates per subject → one session per date, ordered by date. One date per subject → no session entity. The recording basenames carry the auto-inferred entity.

What you'll see

Real numbers from the MEG pipeline.

The same four commands. Real outputs captured on the local copy of the Elekta sample:

Scan 23 inventory rows

One row per .fif. Zero skips. Subject identity from folder name; session from the date-shaped subfolder between subject and recording.

Convert 23 / 23 runs written

All conversions succeed. mne-bids writes each FIF as a BIDS-named .fif plus a channel TSV, coordinate TSV, and JSON sidecar. The empty-room recordings get acq-emptypre and acq-emptypost tags.

Validate 50 / 24 / 0 ok / warn / err

Zero errors. All 24 warnings are bidsmgr.todo_placeholder: the dataset-level fields plus the MEG-specific recommended fields (ManufacturersModelName, SoftwareVersions, RecordingDuration in some cases).

What's different vs MRI

One workflow, modality-specific quirks.

  • Automatic session inference. Multiple date-named subfolders → multiple sessions, ordered by date. The MRI sample dataset uses SeriesDescription tokens like ses-pre / ses-post instead; MEG's file-system convention is honoured here.
  • Tasks parse cleanly. The filename task_driving_run_01.fif decomposes into task=driving, run=1. No user override needed.
  • Empty-room recordings stay BIDS-valid. task_emptypre and task_emptypost become task-noise with acq-pre / acq-post, the canonical BIDS naming for empty-room recordings.
  • FIF native format kept. mne-bids writes FIFs as FIFs (no transcoding). The MEG datatype skips the standard montage step that EEG runs.