ANTsX / ANTsPy

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.
https://antspyx.readthedocs.io
Apache License 2.0
586 stars 161 forks source link

`SyNOnly` registration returns non-identity .mat #615

Closed koegl closed 2 months ago

koegl commented 2 months ago

Describe the bug I have affinely registered images that I want to further register using SyN - the output I am looking for is the warped image and the corresponding displacement field in .nii.gz.

For type_of_transform I chose SyNOnly, because, according to the documentation

“SyNOnly” [...] no initial transformation [...] Assumes images are aligned by an initial transformation

However, when I run the registration, the resulting .mat is not an identity, it has a non-zero translation component.

To reproduce I uploaded the two .nii.gz images that I was using and the resulting affine and displacement field to dropbox.

This is the snippet to run the registration:

import ants

fixed_image = ants.image_read("tumor1.nii.gz")
moving_image = ants.image_read("tumor2.nii.gz")

registration = ants.registration(
    fixed=fixed_image,
    moving=moving_image,
    type_of_transform='SyNOnly',
    write_composite_transform=False)

Expected behavior The documentation suggests that the images should be already aligned, so I would expect the translation component to be 0 (and the entire .mat to be identity).

Screenshots

ANTsPy installation (please complete the following information):

Additional context My goal is to get a .nii.gz displacement field - so I would also be content with a way of transforming the composite .h5 transform (with write_composite_transform=True to .nii.gz)

stnava commented 2 months ago

see #466

cookpa commented 2 months ago

I see I was supposed to fix this, will document.

cookpa commented 2 months ago

Closed by the PR, but please re-open if needed @koegl