Note
This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.
nilearn.masking.compute_multi_brain_mask¶
- nilearn.masking.compute_multi_brain_mask(target_imgs, threshold=0.5, connected=True, opening=2, memory=None, verbose=0, mask_type='whole-brain', **kwargs)[source]¶
Compute the whole-brain, grey-matter or white-matter mask for a list of images.
The mask is calculated through the resampling of the corresponding MNI152 template mask onto the target image.
Added in version 0.8.1.
- Parameters:
- target_imgs
list
of Niimg-like object See Input and output: neuroimaging data representation. Images used to compute the mask. 3D and 4D images are accepted.
Note
The images in this list must be of same shape and affine. The mask is calculated with the first element of the list for only the shape/affine of the image is used for this masking strategy.
- threshold
float
, default=0.5 The value under which the MNI template is cut off.
- connected
bool
, optional If connected is True, only the largest connect component is kept. Default=True.
- opening
bool
orint
, optional This parameter determines whether a morphological opening is performed, to keep only large structures. This step is useful to remove parts of the skull that might have been included. opening can be:
A
bool
: If False, no opening is performed. If True, it is equivalent to opening=1.An
int
n: The opening is performed via n erosions (seescipy.ndimage.binary_erosion
). The largest connected component is then estimated if connected is set to True, and 2`n` dilation operations are performed (seescipy.ndimage.binary_dilation
) followed by n erosions. This corresponds to 1 opening operation of order n followed by a closing operator of order n.
Note
Turning off opening (opening=False) will also prevent any smoothing applied to the image during the mask computation.
Default=2.
- mask_type{“whole-brain”, “gm”, “wm”}, default=”whole-brain”
Type of mask to be computed:
"whole-brain"
: Computes the whole-brain mask."gm"
: Computes the grey-matter mask."wm"
: Computes the white-matter mask.
- memoryNone, instance of
joblib.Memory
,str
, orpathlib.Path
Used to cache the masking process. By default, no caching is done. If a
str
is given, it is the path to the caching directory.- verbose
int
, default=0 Verbosity level (0 means no message).
- .. note::
Argument not used but kept to fit the API
- **kwargsoptional arguments
Arguments such as ‘target_affine’ are used in the call of other masking strategies, which then would raise an error for this function which does not need such arguments.
- target_imgs
- Returns:
- mask
nibabel.nifti1.Nifti1Image
The brain mask (3D image).
- mask
See also