nilearn.image: Image Processing and Resampling Utilities#

Mathematical operations working on Niimg-like objects like a (3+)D block of data, and an affine.


binarize_img(img[, threshold, mask_img])

Binarize an image such that its values are either 0 or 1.

clean_img(imgs[, runs, detrend, ...])

Improve SNR on masked fMRI signals.

concat_imgs(niimgs[, dtype, ensure_ndim, ...])

Concatenate a list of 3D/4D niimgs of varying lengths.

coord_transform(x, y, z, affine)

Convert the x, y, z coordinates from one image space to another


Copy an image to a nibabel.Nifti1Image.

crop_img(img[, rtol, copy, pad, return_offset])

Crops an image as much as possible.


Get the image data as a numpy.ndarray.

high_variance_confounds(imgs[, n_confounds, ...])

Return confounds signals extracted from input signals with highest variance.

index_img(imgs, index)

Indexes into a 4D Niimg-like object in the fourth dimension.


Iterates over a 4D Niimg-like object in the fourth dimension.


Return the largest connected component of an image or list of images.

load_img(img[, wildcards, dtype])

Load a Niimg-like object from filenames or list of filenames.

math_img(formula, **imgs)

Interpret a numpy based string formula using niimg in named parameters.

mean_img(imgs[, target_affine, ...])

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

new_img_like(ref_niimg, data[, affine, ...])

Create a new image of the same class as the reference image

resample_img(img[, target_affine, ...])

Resample a Niimg-like object

resample_to_img(source_img, target_img[, ...])

Resample a Niimg-like source image on a target Niimg-like image (no registration is performed: the image should already be aligned).

reorder_img(img[, resample])

Returns an image with the affine diagonal (by permuting axes).

smooth_img(imgs, fwhm)

Smooth images by applying a Gaussian filter.


Performs swapping of hemispheres in the indicated NIfTI image.

threshold_img(img, threshold[, ...])

Threshold the given input image, mostly statistical or atlas images.