From 15ddfed96d2dd833a710388aea5a069247735017 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Sun, 21 Jul 2019 17:02:43 +0100 Subject: [PATCH] BF: Can't short-cut convertDeformationType, as it causes inf recursion between DefField.deformationType and detectDeformationType. Also fix applyDeformation where not using altref --- fsl/transform/nonlinear.py | 6 +++--- fsl/utils/image/resample.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fsl/transform/nonlinear.py b/fsl/transform/nonlinear.py index 062514700..ab1a9641f 100644 --- a/fsl/transform/nonlinear.py +++ b/fsl/transform/nonlinear.py @@ -582,9 +582,6 @@ def convertDeformationType(field, defType=None): if field.deformationType == 'absolute': defType = 'relative' else: defType = 'absolute' - if field.deformationType == defType: - return field.data - # Regardless of the conversion direction, # we need the coordinates of every voxel # in the reference coordinate system. @@ -743,6 +740,9 @@ def applyDeformation(image, field, ref=None, order=1, mode=None, cval=None): mode='constant', cval=-1)[0] + else: + field = field.data + field = field.transpose((3, 0, 1, 2)) return ndinterp.map_coordinates(image.data, field, diff --git a/fsl/utils/image/resample.py b/fsl/utils/image/resample.py index 1aa52b9d2..50dc0c402 100644 --- a/fsl/utils/image/resample.py +++ b/fsl/utils/image/resample.py @@ -67,7 +67,9 @@ def resampleToReference(image, reference, matrix=None, **kwargs): newShape = newShape + oldShape[len(newShape):] # Align the two images together - # via their vox-to-world affines. + # via their vox-to-world affines, + # and the world-to-world affine + # if provided matrix = affine.concat(image.worldToVoxMat, affine.invert(matrix), reference.voxToWorldMat) -- GitLab