mne_rt.tools.save_as_bids#

mne_rt.tools.save_as_bids(raw: BaseRaw, nf_data: dict, output_dir: str | Path, subject: str, session: str | None = None, task: str = 'neurofeedback', run: str | None = None, overwrite: bool = False, verbose: bool | str | None = None) Path[source]#

Save a neurofeedback session in BIDS format.

Writes the raw EEG recording as a BIDS EEG dataset and exports the per-window NF feature time-series as a *_beh.tsv behavioural side-car file.

Parameters:
rawmne.io.BaseRaw

The raw EEG (or MEG) recording to export.

nf_datadict

Dictionary mapping modality name → list of per-window values (as returned by record_main()).

output_dirstr | Path

Root BIDS directory (created if it does not exist).

subjectstr

BIDS subject label (without the sub- prefix).

sessionstr | None, default None

BIDS session label (without the ses- prefix). None omits the session level.

taskstr, default “neurofeedback”

BIDS task label.

runstr | None, default None

BIDS run label (without the run- prefix).

overwritebool, default False

Overwrite existing files.

verbosebool | str | None, default None

Verbosity passed to mne-bids.

Returns:
bids_pathPath

Root BIDS output directory.

Raises:
FileExistsError

If overwrite=False and output files already exist.

Notes

If mne_bids is installed (pip install mne-bids) it is used for writing the EEG data with full BIDS compliance. Otherwise a minimal BIDS-like layout is written manually (EEG as .fif, NF data as _beh.tsv, and stub dataset_description.json / participants.tsv files).

Added in version 1.0.0.