Skip to content
Snippets Groups Projects
Commit 588f2bf8 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: applyDeformation supports input image with different FOV to original

source image
parent b41c630c
No related branches found
No related tags found
No related merge requests found
......@@ -745,6 +745,8 @@ def applyDeformation(image, field, ref=None, order=1, mode=None, cval=None):
# truncation at the field boundaries,
# but there's nothing we can do about
# that.
src = field.src
if not field.sameSpace(ref):
field = resample.resampleToReference(field,
ref,
......@@ -755,6 +757,21 @@ def applyDeformation(image, field, ref=None, order=1, mode=None, cval=None):
else:
field = field.data
# If the input image is in a
# different space to the field
# source space, we need to
# adjust the resampling matrix.
# We assume world-world alignment
# between the original source
# and the image to be resampled
if not image.sameSpace(src):
post = affine.concat(image.getAffine('world', 'voxel'),
src .getAffine('voxel', 'world'))
shape = field.shape
field = field.reshape((-1, 3))
field = affine.transform(field, post)
field = field.reshape(shape)
field = field.transpose((3, 0, 1, 2))
return ndinterp.map_coordinates(image.data,
field,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment