[MINC-users] Affine transformation matrix

Alex Zijdenbos zijdenbos at gmail.com
Tue Jun 21 23:24:28 EDT 2011


My guess would be that if the source and the target are in fact
different in scale (such as the infamous Talairach brain), that you
may have trouble fining a good fit this way (but I suspect Aaryani
does have the same scale brains so this may very well work).

Alternatively, I have removed scale from an xfm by concatenating it
with an xfm with the inverse scale, see the snippet of perl code
below.

-- A

Here

&Run() is a glorified system() call
&TmpFile() generates a temporary filename
&CoM() calculates the center of mass of the source volume

---

my @params;
&Run(['xfm2param', $tempxfm], \@params) && die;
chomp @params;

my @scale = (1.0, 1.0, 1.0);
foreach my $param (@params) {
    if ($param =~ /-scale\s+(\S+)\s+(\S+)\s+(\S+)/) {
	 $scale[0] *= $1;
	 $scale[1] *= $2;
	 $scale[2] *= $3;
    }
}

@scale = map { 1.0/$_ } @scale;

my $unscalexfm = &TmpFile('unscale.xfm');
&Run(['param2xfm', '-clobber', '-center', &CoM($CurSource), '-scales',
@scale, $unscalexfm]) && die;




On Tue, Jun 21, 2011 at 10:48 PM, Claude LEPAGE
<claude at bic.mni.mcgill.ca> wrote:
>
> Andrew,
>
> Why not do a -lsq12 transform while disabling scales via the
> -w_scales parameter to minctracc?
>
> Claude
>
>
>>
>> Hi Aaryani,
>>
>> You are asking a pretty loaded question here. If the scaling is small
>> (say 1.001) then I wouldn't expect removing it will make much
>> difference, of course there will still be a difference but it probably
>> will be tolerable.
>>
>> Remember also that an .xfm is really just an affine transformation
>> matrix that can be expressed in a many different combinations of
>> rotations, translations, scales and shears. xfm2param just gives you
>> one of these solutions based upon a set of assumptions (rotations all
>> less than 90deg, etc).
>>
>> As for changing the rotations and translations accordingly, the answer
>> is definitely yes, but the matrix algebra involved in this is going to
>> get pretty ugly pretty quick and in any case will not be the same as
>> the original transformation once the scaling is removed. My suggestion
>> if you really want to do this is to recover the transformation type
>> you want using minctracc from the outset. In your case this would be
>> done via the -lsq6 argument, or perhaps lsq7.
>>
>> a
>>
>>
>>
>> On Wed, Jun 22, 2011 at 10:22, Aaryani Tipirneni <atipirne at stanford.edu> wr=
>> ote:
>> > =A0I have a basic question - As we know, If we do affine registration usi=
>> ng mritotal to the atlas, we will get a .xfm file with the translations, ro=
>> tations, scaling and shearing. If I now want to remove the scaling from the=
>>  .xfm matrix so that the coregistered data has the same scaling as the orig=
>> inal data (to avoid stretching and shrinking), do you expect to still coreg=
>> ister well? Do I have to change even the rotations and translations accordi=
>> ngly?
>> _______________________________________________
>> MINC-users at bic.mni.mcgill.ca
>> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>>
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>


More information about the MINC-users mailing list