[MINC-users] mincresample - what is the expected behavior

Matthijs van Eede matthijs at phenogenomics.ca
Fri Jan 1 22:55:19 EST 2010


Hi Andrew,

Thank you very much! I am trying to debug a minctracc error I am getting and got confused when minctracc said the following:

after parameter optimization
-center      -508.71222    0.90644   -5.98667
-translation  508.09448    0.51216   -1.63015
-rotation      -3.84787    1.13791  -13.16369
-scale          1.00000    1.00000    1.00000
-shear          0.00000    0.00000    0.00000

and xfm2param gave me the following on the transformation that was created by minctracc:

-center         0.00000    0.00000    0.00000
-translation  494.63181 -114.92624  -11.68648
-rotation      -3.84787    1.13791  -13.16369
-scale          1.00000    1.00000    1.00000
-shear          0.00000   -0.00000   -0.00000

When I saw that large difference in the translation, I tried to simulate the problem by using param2xfm and specifying the translation and rotation at the same time with the output of minctracc, but given your response I now found that this is indeed not where things go wrong. Things go wrong when I now use this transformation as input for a sequential minctracc call in order to refine the initial registration. That second transformation I get from minctracc is:

-center         0.00000    0.00000    0.00000
-translation  495.03180 -114.52625  -11.28648
-rotation      -2.84787    2.13791  -16.16369
-scale          1.00000    1.00000    1.00000
-shear          0.00000   -0.00000    0.00000

So minctracc seems to have mainly improved on the rotation side with respect to the input transformation, but the translation part looks mostly unchanged. Could it be that now there is a problem in terms of concatenating transforms? I.e., does minctracc concatenate the input transformation with the transformation it finds after the optimization? Because when I use this second transformation on my source image it is lost/gone.

Thanks,
Matthijs

----- Original Message -----
From: Andrew Janke <a.janke at gmail.com>
Sent: Fri, 1/1/2010 9:18am
To: MINC users mailing list <minc-users at bic.mni.mcgill.ca>
Subject: Re: [MINC-users] mincresample - what is the expected behavior

Hi Matthijs,

On Fri, Jan 1, 2010 at 07:42, Matthijs van Eede
<matthijs at phenogenomics.ca> wrote:
> 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?


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 4x4 matrix (well, really a 3x3 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.


--
Andrew Janke
(a.janke at gmail.com || http://a.janke.googlepages.com/)
Canberra->Australia    +61 (402) 700 883
_______________________________________________
MINC-users at bic.mni.mcgill.ca
http://www2.bic.mni.mcgill.ca/mailman/listinfo/minc-users


More information about the MINC-users mailing list