[Insight-users] Re: AffineTransform

Luis Ibanez luis.ibanez@kitware.com
Tue, 17 Sep 2002 12:12:04 -0400


This is a multi-part message in MIME format.
--------------050304020303000106020100
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit


Hi Suresh,

When the registration is finished, the results are obtained
as an array of transform parameters. Like:

ParametersType parameters = registration->GetLastTransformParameters();

Not in the actual transform used by the Registration (although
this will be even more convenient... I'm going to add this set up
of the last transform...)

You may feed these last parameters into a transform. For example,
instead of reconstructing the affine transform from the matrix and
offset, you can do something like:

   AffineTransformType::Pointer transform = AffineTransformType::New();
   transform->SetParameters( parameters );

Once you have this transform, you can plug it in the Resample image
filter and connect the SPECT image as the input of this filter.

   ResampleFilterType::Pointer filter = ResampleFilterType::New();
   filter->SetTransform( transform );
   filter->SetInput( spectImage );

Note that the ResampleFilter also requires you to specify the
size and spacing of the output image. You may want to use here
the size and spacing of the MRI image.

http://www.itk.org/Insight/Doxygen/html/classitk_1_1ResampleImageFilter.html

For example:

   filter->SetSize( mriImage->GetLargestPossibleRegion().GetSize() );
   filter->SetOutputOrigin( mriImage->GetOrigin() );
   filter->SetOutputSpacing( mriImage->GetSpacing() );

and finally:

   filter->Update();


---

The attached diagrams may help to illustrate the setup of the Transform.

During the registration process, (registration1.png) the points of the
FixedImageRegion (on the fixed image) are visited in order. For each
one, the transform is applied. (e.g. point "Pf" of the fixed image in
the diagram is transformed into "Pm" on the moving image). For this
point, the value of the moving image is interpolated and used for the
computation of the metric.

By the end of the registration. The transform represents how to map
a point of the Fixed image space into a point of the Moving image space.

If you need to specify how to map a point of the moving image onto
the fixed image, then the Inverse of the transform is required.

However, in the way Resampling is done, (see diagram registration2.png)
you actually use the direct transform.

Here is why: in order to resample the SPECT image and get
it mapped on the format of the MRI image, you take an "empty" image
with the size and spacing of the MRI image, visit every pixel one by
one and for each pixel you take its coordinate in the Fixed image and
map it to the moving image. Once having the point coordinates on the
moving image an image value is interpolated.  This value is stored in
the corresponding pixel on the MRI-like empty image.


Could you please post the values (12 parameters) of the final transform
you are obtaining ?
We should be able to figure out from this values is the registration
is producing a reasonable result. That will help to identify if the
problem is with the registration or with the final resampling.


   Thanks


    Luis



===========



suresh wrote:

> Hi Luis,
> 
> Thanks for your help.
> I'm a little confused with the third point in your reply.
> What i understood is ...
> fixedImage=MRI, movingImage=SPECT and dont do any inverse in Transform.
> This is my registration code.
> /**************************************************
....

....


> 
> **********************************************/
> But after applying transform the SPECT image did not GROW to the MRI size.
> 
> Your help with this is very much needed for me.
> 
> Thankyou,
> 
> -suresh
> 



--------------050304020303000106020100
Content-Type: image/png;
 name="registration1.png"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="registration1.png"

iVBORw0KGgoAAAANSUhEUgAAAcQAAADaAQAAAAAQjw/tAAAACXBIWXMAAAxMAAAMTAEAiU+q
AAAEQUlEQVR42u3azYscRRQA8A0bWC+yeDE5iI05eFa8CEEn/4DgzYMeEkQ8ZT1JEDLUSoJ6
EL8O4ge4R8E/YBETplwXdy+BDYjCOm5qwqAb3dn0hBVqQm3Xs2dme/qjPvrV2xyCdMFM17zu
31a9N93bTffMgbe1nGuGc271IwMdAZwIl91UpouL4VLFUgOHmCD/eebqU98tUGS8+s0f1y5R
5N3VjVs0OVhdvUGSo78ef+/Cp6f64dLfGtlIjOzNzTGS7EUAyxFBHk7QbYK8MnnXUbAcHaXY
C5abWScKlLqV9fqB8l5eqUC5lXejIJlP1jFdp7xf6B8Gyd0ii0LkyuSL1PPXT18C66nFJTUD
GKSLbvtrCXAQIMdp3k1fot1V9kRdcpzm4Obzi6L9SSptp26XTNOE210O4vLZsRRoOU4T4rFs
K1WsdK1MYCK/XzyS99FyUsz+Bxw2L7+jsjmgZDzrcZDTBVKKqtzCylY1IJFSGxGFlGYpE6Q0
52YW1y7NepjFtUtuhgROMjO0i5LaElMomWBiVqksMY2S0hIzcrfK2CY5RgpABIdz1haVNlq2
b8TMP88qA3Bb8j2LPASbVAiprDIhS42Q0iqrX6hNxnbJ66WwS1EvuV3GZCnrJaNKDXapamXi
kEmtVA6pa6V84LKyE1lk7JK8TooHL0Wd5C4Z10nmktIr07MdUZ5saXBJ5ZVvgFsmXvn2dD1B
nmfKKbVXPgpU2Yb3nbK845py3i3f9MkntEd+65OgT7jzrJHuMfUrXunL8xSs+aSntldg2yfB
Lddhhyy3z9FkH9aXaHLIBFW2qLLX2jhDlFEhGDgmVQ7JcsSostQaGSIZWbZQUppSc5Tcs0iB
kvumTOgyRslbplQ4KZgpJU5yQ0q6VCjJhSFjpIxNmeCkNKTASWaRGieVITlSJqYsHGZuqbOL
m4Jkx5AcJY8GyKUGrOSmFAiZZCtzmRxHxjgZV6TCSZX9DytJiZOqIuVxpMLJpCJjnJTZtXVJ
Jjg53YlyKY4jNULG2edccrwUhswPsyDJcFIc6YrkOClLUgNeKlMKikyQkmfblmWMk7okVYCc
VLMsZb1khpQhkhtSIaUoyhgn9WzjskwoUoRIaUiNlKooOU5OZqUXDDk7zPzyXShKhpdDZpG8
To4fni1CUerprecWQk4f/wZfxyvoMZqUowiIcgGIcghUCY1sZCMb2chGPnSS/lQaiO3h+61d
I//HcnMrPRD6FLm7AsXbHAGyv5Je3ZLk3mtPf3Fentt4hIXKv1/9rPuSXPr3ZkUuA1xnXjno
bncvyqXffqnMlgN0/GMOtr/svi6XPn+Ohco/b7zQvTA889PpypjLa1dfvPPY2qJfj9LXxxX5
w8F8Z3/nqxq5k99Cn8nOwdnO/q+/+4s03oWyn2Pmcu/Zzv7PG28Bts3kR3c+fPLky+tRuJy2
e2hYldfIcpMsA9rwP4Mg1YuJccYnAAAAHXRFWHRTb2Z0d2FyZQBHTlUgR2hvc3RzY3JpcHQg
Ni41MYBJFOwAAAAqdEVYdFNpZ25hdHVyZQAwM2RkYTk4MzBiZjVkYWNmMzMxNDQ0Yzk4ZDY0
ZDdiNw1u49EAAAAASUVORK5CYII=
--------------050304020303000106020100
Content-Type: image/png;
 name="registration2.png"
Content-Transfer-Encoding: base64
Content-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