Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.

8.6.2. nilearn.input_data.MultiNiftiMasker

class nilearn.input_data.MultiNiftiMasker(mask_img=None, smoothing_fwhm=None, standardize=False, detrend=False, low_pass=None, high_pass=None, t_r=None, target_affine=None, target_shape=None, mask_strategy='background', mask_args=None, dtype=None, memory=Memory(location=None), memory_level=0, n_jobs=1, verbose=0)

Class for masking of Niimg-like objects.

MultiNiftiMasker is useful when dealing with image sets from multiple subjects. Use case: integrates well with decomposition by MultiPCA and CanICA (multi-subject models)

Parameters:

mask_img: Niimg-like object

See http://nilearn.github.io/manipulating_images/input_output.html Mask of the data. If not given, a mask is computed in the fit step. Optional parameters can be set using mask_args and mask_strategy to fine tune the mask extraction.

smoothing_fwhm: float, optional

If smoothing_fwhm is not None, it gives the size in millimeters of the spatial smoothing to apply to the signal.

standardize: {‘zscore’, ‘psc’, True, False}, default is ‘zscore’

Strategy to standardize the signal. ‘zscore’: the signal is z-scored. Timeseries are shifted to zero mean and scaled to unit variance. ‘psc’: Timeseries are shifted to zero mean value and scaled to percent signal change (as compared to original mean signal). True : the signal is z-scored. Timeseries are shifted to zero mean and scaled to unit variance. False : Do not standardize the data.

detrend: boolean, optional

This parameter is passed to signal.clean. Please see the related documentation for details

low_pass: None or float, optional

This parameter is passed to signal.clean. Please see the related documentation for details

high_pass: None or float, optional

This parameter is passed to signal.clean. Please see the related documentation for details

t_r: float, optional

This parameter is passed to signal.clean. Please see the related documentation for details

target_affine: 3x3 or 4x4 matrix, optional

This parameter is passed to image.resample_img. Please see the related documentation for details.

target_shape: 3-tuple of integers, optional

This parameter is passed to image.resample_img. Please see the related documentation for details.

mask_strategy: {‘background’, ‘epi’ or ‘template’}, optional

The strategy used to compute the mask: use ‘background’ if your images present a clear homogeneous background, ‘epi’ if they are raw EPI images, or you could use ‘template’ which will extract the gray matter part of your data by resampling the MNI152 brain mask for your data’s field of view. Depending on this value, the mask will be computed from masking.compute_background_mask, masking.compute_epi_mask or masking.compute_brain_mask. Default is ‘background’.

mask_args : dict, optional

If mask is None, these are additional parameters passed to masking.compute_background_mask or masking.compute_epi_mask to fine-tune mask computation. Please see the related documentation for details.

dtype: {dtype, “auto”}

Data type toward which the data should be converted. If “auto”, the data will be converted to int32 if dtype is discrete and float32 if it is continuous.

memory: instance of joblib.Memory or string

Used to cache the masking process. By default, no caching is done. If a string is given, it is the path to the caching directory.

memory_level: integer, optional

Rough estimator of the amount of memory used by caching. Higher value means more memory for caching.

n_jobs: integer, optional

The number of CPUs to use to do the computation. -1 means ‘all CPUs’, -2 ‘all CPUs but one’, and so on.

verbose: integer, optional

Indicate the level of verbosity. By default, nothing is printed

See also

nilearn.image.resample_img
image resampling
nilearn.masking.compute_epi_mask
mask computation
nilearn.masking.apply_mask
mask application on image
nilearn.signal.clean
confounds removal and general filtering of signals

Attributes

`mask_img_`(nibabel.Nifti1Image object) The mask of the data.
`affine_`(4x4 numpy.ndarray) Affine of the transformed image.
__init__(mask_img=None, smoothing_fwhm=None, standardize=False, detrend=False, low_pass=None, high_pass=None, t_r=None, target_affine=None, target_shape=None, mask_strategy='background', mask_args=None, dtype=None, memory=Memory(location=None), memory_level=0, n_jobs=1, verbose=0)

Initialize self. See help(type(self)) for accurate signature.

fit(imgs=None, y=None)

Compute the mask corresponding to the data

Parameters:

imgs: list of Niimg-like objects

See http://nilearn.github.io/manipulating_images/input_output.html Data on which the mask must be calculated. If this is a list, the affine is considered the same for all.

fit_transform(X, y=None, confounds=None, **fit_params)

Fit to data, then transform it

Parameters:

X : Niimg-like object

y : numpy array of shape [n_samples]

Target values.

confounds: list of confounds, optional

List of confounds (2D arrays or filenames pointing to CSV files). Must be of same length than imgs_list.

Returns:

X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.

generate_report()
get_params(deep=True)

Get parameters for this estimator.

Parameters:

deep : bool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params : mapping of string to any

Parameter names mapped to their values.

inverse_transform(X)

Transform the 2D data matrix back to an image in brain space.

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params : dict

Estimator parameters.

Returns:

self : object

Estimator instance.

transform(imgs, confounds=None)

Apply mask, spatial and temporal preprocessing

Parameters:

imgs: list of Niimg-like objects

confounds: CSV file path or 2D array or pandas DataFrame

This parameter is passed to signal.clean. Please see the corresponding documentation for details.

Returns:

data: {list of numpy arrays}

preprocessed images

transform_imgs(imgs_list, confounds=None, copy=True, n_jobs=1)

Prepare multi subject data in parallel

Parameters:

imgs_list: list of Niimg-like objects

See http://nilearn.github.io/manipulating_images/input_output.html List of imgs file to prepare. One item per subject.

confounds: list of confounds, optional

List of confounds (2D arrays or filenames pointing to CSV files or pandas DataFrames). Must be of same length than imgs_list.

copy: boolean, optional

If True, guarantees that output array has no memory in common with input array.

n_jobs: integer, optional

The number of cpus to use to do the computation. -1 means ‘all cpus’.

Returns:

region_signals: list of 2D numpy.ndarray

List of signal for each element per subject. shape: list of (number of scans, number of elements)

transform_single_imgs(imgs, confounds=None, copy=True)

Apply mask, spatial and temporal preprocessing

Parameters:

imgs: 3D/4D Niimg-like object

See http://nilearn.github.io/manipulating_images/input_output.html Images to process. It must boil down to a 4D image with scans number as last dimension.

confounds: CSV file or array-like or pandas DataFrame, optional

This parameter is passed to signal.clean. Please see the related documentation for details: nilearn.signal.clean. shape: (number of scans, number of confounds)

Returns:

region_signals: 2D numpy.ndarray

Signal for each voxel inside the mask. shape: (number of scans, number of voxels)