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.
Resample a Niimg-like object
img: Niimg-like object
target_affine: numpy.ndarray, optional
target_shape: tuple or list, optional
interpolation: str, optional
copy: bool, optional
order: “F” or “C”
BoundingBoxError If a 4x4 transformation matrix (target_affine) is given and all of the transformed data points have a negative voxel index along one of the axis, then none of the data will be visible in the transformed image and a BoundingBoxError will be raised.
If a 4x4 transformation matrix (target_affine) is given and no target shape is provided, the resulting image will have voxel coordinate (0, 0, 0) in the affine offset (4th column of target affine) and will extend far enough to contain all the visible data and a margin of one voxel.
3x3 transformation matrices If a 3x3 transformation matrix is given as target_affine, it will be assumed to represent the three coordinate axes of the target space. In this case the affine offset (4th column of a 4x4 transformation matrix) as well as the target_shape will be inferred by resample_img, such that the resulting field of view is the closest possible (with a margin of 1 voxel) bounding box around the transformed data.
In certain cases one may want to obtain a transformed image with the closest bounding box around the data, which at the same time respects a voxel grid defined by a 4x4 affine transformation matrix. In this case, one resamples the image using this function given the target affine and no target shape. One then uses crop_img on the result.
NaNs and infinite values This function handles gracefully NaNs and infinite values in the input data, however they make the execution of the function much slower.