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.image.mean_img

nilearn.image.mean_img(imgs, target_affine=None, target_shape=None, verbose=0, n_jobs=1, copy_header=False)[source]

Compute the mean of the images over time or the 4th dimension.

Note that if list of 4D images are given, the mean of each 4D image is computed separately, and the resulting mean is computed after.

Parameters:
imgsNiimg-like object or iterable of Niimg-like objects

Images to be averaged over time (see Input and output: neuroimaging data representation for a detailed description of the valid input types).

target_affinenumpy.ndarray, optional

If specified, the image is resampled corresponding to this new affine. target_affine can be a 3x3 or a 4x4 matrix.

target_shapetuple or list, optional

If specified, the image will be resized to match this new shape. len(target_shape) must be equal to 3. A target_affine has to be specified jointly with target_shape.

verboseint, default=0

Controls the amount of verbosity: higher numbers give more messages (0 means no messages).

n_jobsint, default=1

The number of CPUs to use to do the computation (-1 means ‘all CPUs’).

copy_headerbool, default=False

Whether to copy the header of the input image to the output.

Added in version 0.11.0.

This parameter will be set to True by default in 0.13.0.

Returns:
Nifti1Image

Mean image.

See also

nilearn.image.math_img

For more general operations on images.

Examples using nilearn.image.mean_img

A introduction tutorial to fMRI decoding

A introduction tutorial to fMRI decoding

Intro to GLM Analysis: a single-run, single-subject fMRI dataset

Intro to GLM Analysis: a single-run, single-subject fMRI dataset

NeuroImaging volumes visualization

NeuroImaging volumes visualization

Plot Haxby masks

Plot Haxby masks

Plotting tools in nilearn

Plotting tools in nilearn

More plotting tools from nilearn

More plotting tools from nilearn

Decoding with FREM: face vs house vs chair object recognition

Decoding with FREM: face vs house vs chair object recognition

Searchlight analysis of face vs house recognition

Searchlight analysis of face vs house recognition

Decoding of a dataset after GLM fit for signal extraction

Decoding of a dataset after GLM fit for signal extraction

Different classifiers in decoding the Haxby dataset

Different classifiers in decoding the Haxby dataset

Clustering methods to learn a brain parcellation from fMRI

Clustering methods to learn a brain parcellation from fMRI

Single-subject data (two runs) in native space

Single-subject data (two runs) in native space

Predicted time series and residuals

Predicted time series and residuals

Simple example of two-runs fMRI model fitting

Simple example of two-runs fMRI model fitting

Comparing the means of 2 images

Comparing the means of 2 images

Smoothing an image

Smoothing an image

Simple example of NiftiMasker use

Simple example of NiftiMasker use

Understanding NiftiMasker and mask computation

Understanding NiftiMasker and mask computation

Computing a Region of Interest (ROI) mask manually

Computing a Region of Interest (ROI) mask manually

Multivariate decompositions: Independent component analysis of fMRI

Multivariate decompositions: Independent component analysis of fMRI

Massively univariate analysis of face vs house recognition

Massively univariate analysis of face vs house recognition