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

nilearn.image.check_niimg_3d(niimg, dtype=None)[source]

Check that niimg is a proper 3D niimg-like object and load it.

Parameters:
niimgNiimg-like object

See Input and output: neuroimaging data representation. If niimg is a string, consider it as a path to Nifti image and call nibabel.load on it. If it is an object, check if the affine attribute present and that nilearn.image.get_data returns a result, raise TypeError otherwise.

dtypedtype like, “auto” or None, default=None

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. If None, data will not be converted to a new data type.

Returns:
result3D Niimg-like object

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

Notes

In nilearn, special care has been taken to make image manipulation easy. This method is a kind of pre-requisite for any data processing method in Nilearn because it checks if data have a correct format and loads them if necessary.

Its application is idempotent.