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.

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

New in version 0.2.5.

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

wildcardsbool, optional

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. Default=True.

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.

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.