Giving credit

4.4.1.4. nilearn.masking.apply_mask

nilearn.masking.apply_mask(niimgs, mask_img, dtype=<type 'numpy.float32'>, smoothing_fwhm=None, ensure_finite=True)

Extract signals from images using specified mask.

Read the time series from the given nifti images or filepaths, using the mask.

Parameters :

niimgs: list of 4D nifti images :

Images to be masked. list of lists of 3D images are also accepted.

mask_img: niimg :

3D mask array: True where a voxel should be used.

smoothing_fwhm: float :

(optional) Gives the size of the spatial smoothing to apply to the signal, in voxels. Implies ensure_finite=True.

ensure_finite: bool :

If ensure_finite is True (default), the non-finite values (NaNs and infs) found in the images will be replaced by zeros.

Returns :

session_series: numpy.ndarray :

2D array of series with shape (image number, voxel number)

Notes

When using smoothing, ensure_finite is set to True, as non-finite values would spread accross the image.