[Insight-users] Help needed on Metric values !!!!

Luis Ibanez luis.ibanez@kitware.com
Tue, 04 Feb 2003 15:03:18 -0500


Hi Sateesh,

During the optimization process of registration,
the parameters of the transform are changed at each
iteration.  The metric compares the fixed image
against the transformed moving image.

If the transform happens to be too far off, it is
possible that the overlap between the fixed image
and the transformed moving image becames null, or
at least so small that it is impossible to compute
a metric with it.  The exception that you are
observing is thrown in this case.

In practice, that may indicate one of the following

1) that the scale parameters are not well tunned yet.
2) the step length of the optimizer is too large.
3) the optimize is minimizing when it should be
    maximizing (or vice versa).

These options are not exclusive, so maybe more
than one of them is happening in your case.


It is a good practice to plot the the parameters
against the number of iterations. This will give
you a better idea of how the optimizer's behavior.

If you look closely at the two last parameters of
your run. They show clearly how the transform
diverges in a sudden jump. These two parameters
are the components of the 2D translation.

Iteration      Translation X, Y

0           -12.3928,  10.1024
1           -27.7252,  14.6468
2           -43.2917,  18.2904
3           -46.1814,  34.0002
4            (Exception thrown)

Now, if you look at the second parameter (among
the 6 of the affine transform in 2D), this is the
[0][1] component of the matrix, you can usually
associate it with:  sin(angle)  (assuming that
no scaling is involved...)

So, trackin the run you have

Iteration  Rotation (degrees)

0          20
1          57
2          ..
3          ..

For iterations 2 and 3 of your run the
matrix is not antisymmetric anymore
so it is clear that is not applying
a rotation but rather some sharing
and scaling.


So....

First you may want to verify that
you are selecting the right direction
for the optimizer to walk (minimize
or maximize) This depends on the
metric.  The SoftwareGuide.pdf
describes these characteristics for
each metric.

Second, you may want to reduce the
step of the optimizer. It is definetly
too large. The modifications of the
transform are too drastic at each
iteration of this run and make the
process very unstable.


Third make sure that you set up
the scale for translation parameters
different from the rotation parameters.

In your code you are doing :

 > optimizerScales[0] = 1.0;
 > optimizerScales[1] = 1.0 / 342;
 > optimizerScales[2] = 1.0 / 392;
 > optimizerScales[3] = 1.0;
 > optimizerScales[4] = 1.0 / 1000000.0;
 > optimizerScales[5] = 1.0 / 1000000.0;

The four first scales should be the
same since they are the four components
of the rotation matrix.  By seting 2 and 3
to a differnent scale you are forciing the
matrix to become a shearing instead of a
rotation.

The translation scales are too extreme.
they should be in the order of 1/imagesize
where imagesize is the width or height of
the image measured in millimeters =
number of pixels X spacing.

Probably 1/1000 is a better value.


As a suggestion,

Please play first with the images
provided in Examples/Data, until you
get a feeling on the sensitivity of
the parameters. That will probably
help you find your way when dealing
with your own images.


Please let us know if you continue
experiencing any problems.


    Thanks


       Luis


--------------------------------------------------
boggarapu sateesh kumar wrote:
> Hi Luis,
> 
>     Thanks for ur response. I could understand some
> thing about metric.
> 
> Now, I was trying with different range of parameters
> values for optimizer scales to tune the matrix values.
> But in that process it got the following exception
> from itk. What this error mean?? 
> 
>  Set :: Optimizer, interpolator, metric
>  Set :: Transform
>  First file :
> D:\WINNT\Profiles\sateesh\Desktop\registration\normal.raw
> Second file :
> D:\WINNT\Profiles\sateesh\Desktop\registration\newrotated.raw
> 
>  SetFixedImageRegion
> Get No of Params : 6
> 
> 
>  Before Registration
> 0   -1.01713   [0.998721, -0.344105, 0.491016,
> 1.00097, -12.3928, 10.1024]
> 1   -0.233272   [0.996606, -0.848237, 0.605383,
> 1.00131, -27.7252, 14.6468]
> 2   -0.41475   [0.993991, -1.28511, 0.138891, 1.00088,
> -43.2917, 18.2904]
> 3   -0.349179   [0.996105, -0.635882, 0.793781,
> 0.998765, -46.1814, 34.0002]
> ExceptionObject caught !
> 
> itk::ExceptionObject (0012FCCC)
> Location: "Unknown"
> File:
> G:\NEWITKFILES\NewVersionITK28_1_2003\itksrcs\Code\Algorithms\itkMattesMutualInformationImageToImageMetric.txx
> Line: 531
> 
> Description: itk::ERROR:
> MattesMutualInformationImageToImageMetric(003030C0):
> Too many samples map outside moving image buffer: 189
> / 1000
> 
> 
> These are the input parameters for metric and
> optimizer::
> ---------------------------------------------------------
> 
> optimizerScales[0] = 1.0; 
> optimizerScales[1] = 1.0 / 342; 
> optimizerScales[2] = 1.0 / 392; 
> optimizerScales[3] = 1.0; 
> optimizerScales[4] = 1.0 / 1000000.0; 
> optimizerScales[5] = 1.0 / 1000000.0; 
> 
> metric->SetNumberOfHistogramBins( 15 );
> metric->SetNumberOfSpatialSamples( 1000 );
> optimizer->SetNumberOfIterations(    300   );
> registration->SetNumberOfLevels( 5 );
> 
> My Input images are of 256x256x1 sets with moving
> rotated in 10 degrees in z-axis with spacing
> {0.859390, 0.859375, 1.60000 }
> 
> What is the reason for getting the above error and how
> to elminate that error. What could be the input for
> above inputs to get the desired matrix.
> 
> Please help me in this regard.
> 
> Thanks in advance.
> 
> -Regards,
>    Sateesh.
> 
> 
> 
> 
> 
> --- Luis Ibanez <luis.ibanez@kitware.com> wrote:
> 
>>Hi Sateesh,
>>
>>The output of this example has by columns
>>
>>1)   Iteration number
>>2)   Metric value
>>3-6) Matrix Coefficients of the 2D AffineTransform
>>7-8) Values of translation on X and Y.
>>
>>The value of the metric tells how similar the fixed
>>image is to the transformed version of the moving
>>image. The purpose of registration is to optimize
>>this matching.
>>
>>This particular example is using the
>>"MattesMutualInformation" metric. Which is an
>>enhanced version of the Mutual Information measure
>>developed by Viola and Wells.
>>
>>You may find a description of the Metrics
>>characteristics
>>in the softwareGuide:
>>
>>    http://www.itk.org/ItkSoftwareGuide.pdf
>>
>>Metrics are discussed under section 7.8. 
>>MutualInformation
>>is treated in section 7.8.4, pdf-page 215.
>>
>>Mattes implementataion is discussed in pdf-page 217.
>>
>>The discussion of the MultiResImageRegistration2.cxx
>>example
>>can be found in  the SoftwareGuide in section 7.5.2,
>>pdf-page 202.
>>
>>All the Examples in the Insight/Examples directory
>>are
>>associated to sections in the SoftwareGuide. You may
>>find
>>easier to start reading from the document and then
>>moving
>>on to try the examples and modify their code.
>>
>>
>>Please let us know if you have further questions,
>>
>>
>>Thanks
>>
>>
>>     Luis
>>
>>
>>
>>---------------------------------------------------
>>
>>boggarapu sateesh kumar wrote:
>>
>>>Hi All,
>>>
>>>    I am using MultiResImageRegistration2.cxx
>>>
>>example
>>
>>>and could run the  example with proper
>>>
>>inputs(2d-MRI
>>
>>>images with 256x256x1 as data sets). It displays
>>>
>>the
>>
>>>metric value and the corresponding final
>>>
>>parameters in
>>
>>>each iterations in each level. It displays some
>>>
>>value
>>
>>>for metric...What this value tells??? How come
>>>
>>this
>>
>>>value will be understandable to user to fine tune
>>>
>>the
>>
>>>registrations parameters. How to tune the input
>>>parameters depending on the fimal parameters of
>>>
>>the
>>
>>>previous interval in previous level??? Please help
>>>
>>in
>>
>>>this regard. 
>>>
>>>    Thanks in advance.
>>>
>>>-Regards,
>>>   Sateesh.
>>>
>>>
>>>=====
>>>
>>>
>>>__________________________________________________
>>>Do you Yahoo!?
>>>Yahoo! Mail Plus - Powerful. Affordable. Sign up
>>>
>>now.
>>
>>>http://mailplus.yahoo.com
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users@public.kitware.com
>>>
>>>
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>>>
>>
>>
>>
>>
> 
> 
> =====
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> 
>