mne_bids.write_anat¶
- mne_bids.write_anat(image, bids_path, landmarks=None, deface=False, raw=None, trans=None, t1w=None, overwrite=False, verbose=False)[source]¶
Put anatomical MRI data into a BIDS format.
Given an MRI scan, format and store the MR data according to BIDS in the correct location inside the specified
mne_bids.BIDSPath
. If a transformation matrix is supplied, this information will be stored in a sidecar JSON file.Note
To generate the JSON sidecar with anatomical landmark coordinates (“fiducials”), you need to pass the landmarks via the
landmarks
parameter.mne_bids.get_anat_landmarks()
may be useful for getting thelandmarks
.- Parameters
- image
str
|pathlib.Path
|NibabelImageObject
Path to an MRI scan (e.g. T1w) of the subject. Can be in any format readable by nibabel. Can also be a nibabel image object of an MRI scan. Will be written as a .nii.gz file.
- bids_path
mne_bids.BIDSPath
The file to write. The
mne_bids.BIDSPath
instance passed here must have theroot
andsubject
attributes set. The suffix is assumed to be'T1w'
if not present. It can also be'FLASH'
, for example, to indicate FLASH MRI.- landmarks
mne.channels.DigMontage
|str
|None
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. If
None
and notrans
parameter is passed, no sidecar JSON file will be created.- 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 voxels to start defacing relative to the nasion (default 5)
theta: is the angle of the defacing shear in degrees relative to vertical (default 15).
- raw
mne.io.Raw
|None
The raw data of
subject
corresponding to the MR scan inimage
. IfNone
,trans
has to beNone
as well.Deprecated in v0.8, use
mne_bids.get_anat_landmarks()
instead.- trans
mne.transforms.Transform
|str
|None
The transformation matrix from head to MRI coordinates. Can also be a string pointing to a
.trans
file containing the transformation matrix. IfNone
and nolandmarks
parameter is passed, no sidecar JSON file will be created.Deprecated in v0.8, use
mne_bids.get_anat_landmarks()
instead.- t1w
str
|pathlib.Path
|NibabelImageObject
|None
This parameter is useful if image written is not already a T1 image. If the image written is to have a sidecar or be defaced, this can be done using raw, trans and t1w. The T1 must be passed here because the coregistration uses freesurfer surfaces which are in T1 space.
Deprecated in v0.8, use
mne_bids.get_anat_landmarks()
instead.- 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
True
, this will print a snippet of the sidecar files. IfFalse
, no content will be printed.
- image
- Returns
- bids_path
mne_bids.BIDSPath
Path to the written MRI data.
- bids_path