mne_bids.write_anat¶
-
mne_bids.
write_anat
(t1w, bids_path, raw=None, trans=None, landmarks=None, deface=False, 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_pathBIDSPath
The file to write. The
mne_bids.BIDSPath
instance passed here must have theroot
andsubject
attributes set.- t1wstr | pathlib.Path | 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.
- 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
- defacebool | dict
If False, no defacing is performed. If True, deface with default parameters. trans and raw must not be None if True. If dict, accepts the following keys:
inset: how far back in millimeters to start defacing relative to the nasion (default 20)
theta: is the angle of the defacing shear in degrees relative to the normal to the plane passing through the anatomical landmarks (default 35).
- landmarks: instance of DigMontage | str
The DigMontage or filepath to a DigMontage with landmarks that can be passed to provide information for defacing. Landmarks can be determined from the head model using mne coreg GUI, or they can be determined from the MRI using freeview.
- 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
- bids_pathBIDSPath
Path to the anatomical scan in the BIDS directory.