mne_bids.deface_mri#

mne_bids.deface_mri(image, landmarks, *, offset=-5, theta=15)[source]#

Remove identifying facial detail from an MRI.

This function blacks out MRI voxels anterior to a nearly vertical plane set by the nasion location. Watershed surfaces made using a defaced MRI will also have no identifying facial detail.

Parameters:
imagenibabel.spatialimages.SpatialImage

Anatomical image as a nibabel object.

landmarksarray_like

Coordinates (x / y / z) of left pre-auricular, nasion, and right pre-auricular points in MRI (voxel) coordinate space (3x3 list of lists or array with nasion coords in the middle).

offsetint

Controls how close the blackout plane sits to the nasion point in mm (an offset value of 5 will set the blackout plane 5 mm anterior to the nasion, whereas -5 will move the plane posterior to the nasion). Defaults to -5.

thetafloat | int

Controls the angle of the blackout plane with respect to vertical (expressed in degrees from 0 to 90). Defaults to 15.

Returns:
imagenibabel.spatialimages.SpatialImage

Defaced anatomical image as a nibabel object.

Raises:
TypeError

If image input is not an instance of nibabel.spatialimages.SpatialImage.

TypeError

If landmarks are not array-like (list of lists or array).

TypeError

If offset is not an integer.

TypeError

If theta is not an int or float.

ValueError

If theta is not between 0 and 90 degrees.