Q: I have a question about the expected behavior of mincresample when using a transformation file with a combination of rotations and translations. The problem is as follows. There is a source file which has its center of gravity in −510,0,0 and a target file which has its center of gravity in 0,0,0. The source image should be translated to the target image and then rotated by −4,1,−13. If I specify two transformation (xfm) files, one for the translation and one for the rotation and apply these sequentially, the resulting transformation is correct., i.e., it has its center of gravity in the origin and rotated around that. However, if I create one transformation file which contains both transformations, I “loose” my file; its new center of gravity is not in 0,0,0 but in 14,118,2 suggesting that the rotation was applied before the transformation. Is this the expected behavior for mincresample?

http://www.bic.mni.mcgill.ca/pipermail/minc-users/2010-January/002613.html

A: Mincresample doesn’t know about translations and rotations as these are just one way of decomposing a affine matrix transformation. Note that for each affine transformation matrix there are often multiple ways of decomposing it into rotations and translations. In order to avoid this problem mincresample treats all such transformations as affine as defined by a 4×4 matrix (well, really a 3×3 with a column matrix tacked onto the end for translations and 0,0,0,1 in the last row but I digress).

You would be better of thinking of this as a problem in setting up your affine transformation matrices. You would typically define/create these using param2xfm and it is here that the order of operations is important. So first lets define the transformation matrix:

spencer:~$ param2xfm -translation 510 0 0 trans.xfm

spencer:~$ cat trans.xfm MNI Transform File %Sat Jan 2 01:14:17 2010>>> param2xfm -translation 510 0 0 trans.xfm %(Package mni_autoreg 0.99.6, compiled by @murdoch (x86_64-unknown-linux-gnu) on Thu Oct 22 12:03:54 EST 2009)

Transform_Type = Linear; Linear_Transform =

1 0 0 510
0 1 0 0
0 0 1 0;

Now our rotations matrix:

spencer:~$ param2xfm -rotations −3 1 −13 rot.xfm

spencer:~$ cat rot.xfm MNI Transform File %Sat Jan 2 01:14:35 2010>>> param2xfm -rotations −3 1 −13 rot.xfm %(Package mni_autoreg 0.99.6, compiled by @murdoch (x86_64-unknown-linux-gnu) on Thu Oct 22 12:03:54 EST 2009)

Transform_Type = Linear; Linear_Transform =

0.974221646785736 0.223752781748772 0.0287548266351223 0
−0.224916785955429 0.97324013710022 0.0470740348100662 0
−0.0174524057656527 −0.0523279905319214 0.998477458953857 0;

Now add them together:

spencer:~$ xfmconcat trans.xfm rot.xfm out.xfm

And have a look at the result:

spencer:~$ cat out.xfm MNI Transform File %Sat Jan 2 01:14:44 2010>>> xfmconcat trans.xfm rot.xfm out.xfm

Transform_Type = Linear; Linear_Transform =

0.974221646785736 0.223752781748772 0.0287548266351223 496.853039860725
−0.224916785955429 0.97324013710022 0.0470740348100662 −114.707560837269
−0.0174524057656527 −0.0523279905319214 0.998477458953857 −8.90072694048288;

Note that the 4th column probably isn’t what you’d expect.

Hope this helps.