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

How can I transform two CTs with a known affine transformation matrix? #499

Open
angolin22 opened this issue Aug 5, 2023 · 6 comments
Open

Comments

@angolin22
Copy link

hello, thanks for your excellent work! I have a problem:
I have two 3D CT images, and I know the affine transformation matrix between them. e. g.
[[ 9.92477011e-01 -8.45505280e-02 8.85471061e-02 5.05205949e+01] [ 8.73986445e-02 9.95757283e-01 -2.87907932e-02 -5.85686522e+00] [-8.57371490e-02 3.63130975e-02 9.95655814e-01 -4.96898369e+01] [-0.00000000e+00 -0.00000000e+00 -0.00000000e+00 1.00000000e+00]]
How can I transform CT with antspy?
Thanks

@ntustison
Copy link
Member

help(ants.create_ants_transform)

@angolin22
Copy link
Author

Thanks for your reply! But the result is not right, my code is

matrix = affine_mat[0:3,0:3]
translation = affine_mat[0:3,3:].squeeze()
tx_affine = ants.create_ants_transform("AffineTransform", precision="float", dimension=3, matrix=matrix, translation=translation)
reg_moving = tx_affine.apply_to_image(moving, fixed, 'linear')

In addtion, I don't know these parameters offset , cernter in this function ants.create_ants_transform(), can you see what's wrong?

@ntustison
Copy link
Member

How did you derive the original transform parameters?

@angolin22
Copy link
Author

angolin22 commented Aug 9, 2023

I use the point cloud corresponding to CT to generate the transform parameters. I use the fast global registration in the open3d library. The result of the point cloud is correct, but the CT image is wrong. I guess the order of the transform parameters generated by ants.create_ants_transform is wrong, so I printed out the transformation parameters and it looks like this, this is not the same order as my original transform parameters.

[ 9.92477000e-01 -8.45505297e-02  8.85471031e-02  8.73986408e-02
  9.95757282e-01 -2.87907925e-02 -8.57371464e-02  3.63130979e-02
  9.95655835e-01  5.05205956e+01 -5.85686541e+00 -4.96898384e+01]

my original transform parameters
image

SO May I ask what the parameters of the matrix generated by ants.create_ants_transform represent?

@ntustison
Copy link
Member

My guess is that the open3d affine parameters aren't directly portable into the ANTs/ITK transformation framework. I would ask over on the ITK discourse forum if anybody has any experience with what you're wanting to do.

@angolin22
Copy link
Author

Ok, thanks! I think it's related to this link

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

2 participants