I already use ITK-snap to process an affine registration : 3D volume image A to B.

Then I get a matrix:

0.97464 0.0364447 0.00781475 1.95549

0.00375859 0.922498 0.0297265 -8.87417

-0.00727863 -0.0145295 0.961844 -1.10425

0 0 0 1

I think it’s incompatibal in F.affine_grid theta.

The shape of affine_grid shape is (N, 3, 4)

likes: R | T

[

[a, b, c, t0],

[e, f, g, t1],

[h, i, j, t2]

]

I think the anterior three rows of the matrix is theta, but it’s wrong.

the R is likely equal to theta[:3, :3],(I am not sure)

but the T (t0, t1, t2) must be incompatible.

How can I get a right theta?

By the way, how can I know what does the torch.nn.functioal.affine_grid really do ?