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.apply_mask¶
- nilearn.masking.apply_mask(imgs, mask_img, dtype='f', smoothing_fwhm=None, ensure_finite=True)[source]¶
Extract signals from images using specified mask.
Read the time series from the given Niimg-like object, using the mask.
- Parameters:
- imgs
list
of 4D Niimg-like objects See Input and output: neuroimaging data representation. Images to be masked. list of lists of 3D images are also accepted.
- mask_imgNiimg-like object
See Input and output: neuroimaging data representation. 3D mask array: True where a voxel should be used.
- dtypenumpy dtype or ‘f’, default=”f”
The dtype of the output, if ‘f’, any float output is acceptable and if the data is stored on the disk as floats the data type will not be changed.
- smoothing_fwhm
float
, optional. If smoothing_fwhm is not None, it gives the full-width at half maximum in millimeters of the spatial smoothing to apply to the signal.
Note
Implies ensure_finite=True.
- ensure_finite
bool
, default=True If ensure_finite is True, the non-finite values (NaNs and infs) found in the images will be replaced by zeros.
- imgs
- Returns:
- run_series
numpy.ndarray
2D array of series with shape (image number, voxel number)
- run_series
Notes
When using smoothing,
ensure_finite
is set to True, as non-finite values would spread across the image.
Examples using nilearn.masking.apply_mask
¶
NeuroImaging volumes visualization