mne_bids.write_anat

mne_bids.write_anat(bids_root, subject, t1w, session=None, acquisition=None, raw=None, trans=None, overwrite=False, verbose=False)[source]

Put anatomical MRI data into a BIDS format.

Given a BIDS directory and a T1 weighted MRI scan for a certain subject, format the MRI scan to be in BIDS format and put it into the correct location in the bids_dir. If a transformation matrix is supplied, a sidecar JSON file will be written for the T1 weighted data.

Parameters
bids_rootstr

Path to root of the BIDS folder

subjectstr

Subject label as in ‘sub-<label>’, for example: ‘01’

t1wstr | nibabel image object

Path to a T1 weighted MRI scan of the subject. Can be in any format readable by nibabel. Can also be a nibabel image object of a T1 weighted MRI scan. Will be written as a .nii.gz file.

sessionstr | None

The session for t1w. Corresponds to “ses”

acquisition: str | None

The acquisition parameters for t1w. Corresponds to “acq”

rawinstance of Raw | None

The raw data of subject corresponding to t1w. If raw is None, trans has to be None as well

transinstance of mne.transforms.Transform | str | None

The transformation matrix from head coordinates to MRI coordinates. Can also be a string pointing to a .trans file containing the transformation matrix. If None, no sidecar JSON file will be written for t1w

overwritebool

Whether to overwrite existing files or data in files. Defaults to False. If overwrite is True, any existing files with the same BIDS parameters will be overwritten with the exception of the participants.tsv and scans.tsv files. For these files, parts of pre-existing data that match the current data will be replaced. If overwrite is False, no existing data will be overwritten or replaced.

verbosebool

If verbose is True, this will print a snippet of the sidecar files. If False, no content will be printed.

Returns
anat_dirstr

Path to the anatomical scan in the bids_dir