Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to reproduce transform with ANTsTransform.apply_to_image #351

Open
rueberger opened this issue Apr 14, 2022 · 2 comments
Open

unable to reproduce transform with ANTsTransform.apply_to_image #351

rueberger opened this issue Apr 14, 2022 · 2 comments

Comments

@rueberger
Copy link
Contributor

rueberger commented Apr 14, 2022

not sure if I'm missing something or if there is a bug here

# f: image with shape (200, 200, 200)
# aff: nonzero affine 
w = ants.transform_from_displacement_field(
         ants.from_numpy(
              np.ones(200, 200, 200, 3) * 25,
              has_components=True,
          )
     )
m1 = w.apply_to_image(aff.invert().apply_to_image(f, reference=f), reference=f)
m2 = ants.apply_transforms(f,f, transformlist=["/path/to/w.nii.gz", "/path/to/aff.mat"],)

result:

Screen Shot 2022-04-14 at 2 40 46 PM

@rueberger
Copy link
Contributor Author

of note: the boundary of the discontinuity in the left image is at 200 in physical coordinates

@rueberger
Copy link
Contributor Author

rueberger commented Apr 14, 2022

I was able to substantially reproduce apply_transforms by setting the warp metadata to match f, as is the case for warps returned by ants.registration. This was not the case for the previous example.

Notable, the affine transform couldn't be inverted for the method to work: w.apply_to_image(aff.apply_to_image(f, reference=f), reference=f)

Furthermore, the resulting images were not identical up to float tolerance. The mean square error was 4e-4, the maximum absolute difference was 0.02. Images were normalized to [0, 1], both methods used linear interpolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant