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.load_img

nilearn.image.load_img(img, wildcards=True, dtype=None)[source]

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

Added in version 0.2.5.

Parameters:
imgNiimg-like object

If string, consider it as a path to NIfTI image and call nibabel.load()`on it. The ‘~’ symbol is expanded to the user home folder. If it is an object, check if affine attribute is present, raise `TypeError otherwise. See Input and output: neuroimaging data representation.

wildcardsbool, default=True

Use img as a regular expression to get a list of matching input filenames. If multiple files match, the returned list is sorted using an ascending order. If no file matches the regular expression, a ValueError exception is raised.

dtype{dtype, “auto”}, optional

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.

Returns:
3D/4D Niimg-like object

Result can be Nifti1Image or the input, as-is. It is guaranteed that the returned object has an affine attributes and that nilearn.image.get_data returns its data.

Examples using nilearn.image.load_img

3D and 4D niimgs: handling and visualizing

3D and 4D niimgs: handling and visualizing

Searchlight analysis of face vs house recognition

Searchlight analysis of face vs house recognition

Understanding nilearn.decoding.Decoder

Understanding nilearn.decoding.Decoder

Resample an image to a template

Resample an image to a template

Computing a Region of Interest (ROI) mask manually

Computing a Region of Interest (ROI) mask manually

Copying headers from input images with math_img

Copying headers from input images with math_img

NeuroVault meta-analysis of stop-go paradigm studies

NeuroVault meta-analysis of stop-go paradigm studies