Giving credit

4.2.1.3. nilearn.image.resample_img

nilearn.image.resample_img(niimg, target_affine=None, target_shape=None, interpolation='continuous', copy=True, order='F')

Resample a Nifti Image

Parameters :

niimg: nilearn nifti image :

Path to a nifti file or nifti-like object

target_affine: numpy.ndarray, optional :

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

target_shape: tuple 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.

interpolation: str, optional :

Can be continuous’ (default) or ‘nearest’. Indicate the resample method

copy: bool, optional :

If True, guarantees that output array has no memory in common with input array. In all cases, input images are never modified by this function.

order: “F” or “C” :

Data ordering in output array. This function is slightly faster with Fortran ordering.

Returns :

resampled: nibabel.Nifti1Image :

input image, resampled to have respectively target_shape and target_affine as shape and affine.