Commit 5aa2612e authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

BF: resample should resample if shapes are different

parent 3647f196
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment