diff --git a/fsl/utils/image/resample.py b/fsl/utils/image/resample.py index 7679c56b02a4b31ff91e4fd3b499f63015d38792..02a946f39186d0fefe7bab8f227b0d8c14f77945 100644 --- a/fsl/utils/image/resample.py +++ b/fsl/utils/image/resample.py @@ -47,9 +47,9 @@ def resampleToReference(image, reference, matrix=None, **kwargs): along the spatial (first three) dimensions. :arg image: :class:`.Image` to resample - :arg matrix: Optional world-to-world affine alignment matrix :arg reference: :class:`.Nifti` defining the space to resample ``image`` into + :arg matrix: Optional world-to-world affine alignment matrix """ oldShape = list(image.shape) @@ -204,9 +204,10 @@ def resample(image, if matrix is None: matrix = affine.rescale(data.shape, newShape, origin) - # identity matrix? the image - # doesn't need to be resampled - if np.all(np.isclose(matrix, np.eye(len(newShape) + 1))): + # same shape and identity matrix? the + # image doesn't need to be resampled + if np.all(np.isclose(image.shape, newShape)) and \ + np.all(np.isclose(matrix, np.eye(len(newShape) + 1))): return data, image.voxToWorldMat newShape = np.array(np.round(newShape), dtype=np.int)