[Insight-users] Error using Registration - Mutual Information + AffineTransform

Luis Ibanez luis.ibanez at kitware.com
Tue Jun 30 15:33:57 EDT 2009


Hi Sharath,

0) Whenever you get the exception saying that too many points
    mapped outside of the moving image, it means that the
    current Transform is such that when mapping the moving image
    into the Fixed image coordinate system the overlap between
    the two image is so small that it is unlikely that the
    registration will recover in further iterations.

    This is typically due to:


        A) Poor initilization of the Transform

        B) Poor selection of Scaling parameters
           (the array that normalizes the dynamic
            range of the different Transform parameters,
            e.g. radians versus millimeters)

        C) Optimizers that are set to perform jumps
           that are too large, and bring the Transform
           out of the range of the image.

1) You want to check this potential suspects in order.

    That is.

    First, verify that the initial transform
    is reasonably placing the Moving image on top of the
    Fixed image. You can do this by using the Resample
    image filter, passing the moving image as input,
    using the initial transform as Transform, and using
    the Fixed image as reference. Then compare the
    fixed image to the resampled moving image.

    If the initial image looks ok,
    then you want to check the values of the ParameterScaling.
    It should be such that when you look at the Transform
    parameters at ever iteration (using an Observer), the
    values should change from iteration to iteration, according
    to the expected dynamic range.

    For example, transform parameters that correspond to rotations
    should change by increments smaller than 0.01 (since they are
    measured in Radians).  While transform parameters that correspond
    to translations should change at increments of 1 ~ 10


    Finally, you should identify the parameter of the optimzer
    that is responsible for selecting the size of jumps that
    are performed in the parameteric space.  (e.g. as you have
    done for the learning rate in the GradientDescent optimizer).

    You want to reduce the size of that jump, until you get the
    Transform to have small increments at every iteration.


2) These parameters must be set up for every "family" of
    registration problems.  That is, the parameters that may be
    good for registering a T1 to T2 MRI brain images, may not be
    appropriate for registering a confocal microscopy image to
    another.

    However, once you fine tune the paramters for a pair of
    T1-T2 images, it is likely that the same set of parameters
    will work for another pair of the same type.

    There is a need for a "smart layer" above the registration
    framework, that could take away from the user the burden
    of finding proper parameter settings....

    any ideas are welcome  :-)


3) Visual monitoring of the registraiton process
    will help to make the fine-tunning process less
    frustrating.

    You may want to give it a try at the VTK helper
    classes:

       InsightApplications/Auxiliary/vtk/
                      vtkRegistrationMonitor.h
                      vtkRegistrationMonitor.cxx

     they will display renderings from iso-surfaces
     at every iteration of the registration process.

     This is usually very informative...



   Regards,


      Luis


--------------
sharath v wrote:
> Hi,
> 
> Thanks for the help. Changing the learning parameter worked...
> 
> For Viola MI + Affine and with learning rate of 0.01 and 100 iterations, I get good results on BrainProtonDensitySliceR10X13Y17 image. Whereas on the BrainProtonDensitySliceR10X13Y17S12 image, it requires atleast 200 iterations to give correct results.
> 
> I want to use an optimizer which has a stopping value (i.e not fixed number of iterations) like Amoeba/Evolutionary/GradientDescentStep
> 
> I tried using the Amoeba optimizer with the following
> 
>     OptimizerType::ParametersType simplexDelta( transform->GetNumberOfParameters() );
>     simplexDelta.Fill( 5.0 );
>     optimizer->AutomaticInitialSimplexOff();
>     optimizer->SetInitialSimplexDelta( simplexDelta );
>     optimizer->SetParametersConvergenceTolerance( 0.01 ); // quarter pixel
>     optimizer->SetFunctionConvergenceTolerance(0.001); // 0.1%
>     optimizer->SetMaximumNumberOfIterations( 200 );
> 
> but I get an exception that sampled point mapped  to outside of the moving image, after 6-7 iterations. Similar issue happens for OnePlusOne optimizer with 
> 
>     typedef itk::Statistics::NormalVariateGenerator  GeneratorType;
>     GeneratorType::Pointer generator = GeneratorType::New();
>     generator->Initialize(12345);
>     optimizer->SetNormalVariateGenerator( generator );
>     optimizer->Initialize( 10 );
>     optimizer->SetEpsilon( 1.0 );
>     optimizer->SetMaximumIteration( 4000 );
> 
> Can you please let me know what values need to be used? 
> 
> And is there a way to make the registration process partially independent of these parameters?
> 
> Thanks,
> Sharath
> 
> 
> 
> ----- Original Message ----
> From: Bill Lorensen <bill.lorensen at gmail.com>
> To: sharath v <sharath20284 at yahoo.com>
> Cc: insight-users at itk.org
> Sent: Wednesday, June 24, 2009 9:39:40 AM
> Subject: Re: [Insight-users] Error using Registration - Mutual Information +  AffineTransform
> 
> I think your learning rate is way too high for Viola-Wells MI. Try
> something like .001.
> 
> On Wed, Jun 24, 2009 at 12:18 PM, sharath v<sharath20284 at yahoo.com> wrote:
> 
>>Hi Luis,
>>
>>Thanks for the reply.
>>
>>I have already done the task that you have mentioned. I studied the example
>>ImageRegistration9.cxx, and it worked for me with RTS images (from
>>BrianProtonDensity set).
>>
>>Below are the set of things I added to ImageRegistration9.cxx for Mutual
>>Information + Affine
>>
>>-  changed the metric from MeanSquare to Mutual Information, and set the
>>required parameters
>>-  changed RegularStepGradientDescentOptimizer to GradientDescentOptimizer
>>(as said in example 2)
>>-  enabled optimizer->MaximizeOn()
>>-  started with a low value of learning rate (5.0) as it gave an exception
>>when 15.0 was used.
>>-  used NormalizeImageFilter and DiscreteGaussianImageFilter on both the
>>images as in example 2
>>-  used CenteredTransformInitializer as explained in the manual
>>
>>- And as you have mentioned I have used the Parameter scaling i.e
>>optimizer->SetScales( optimizerScales ) with translation scale value = 0.001
>>
>>** I got an exception when I tried to give the output of fixedSmoother and
>>movingSmoother (from Example 2) to the initializer code below.
>>
>>initializer->SetFixedImage( fixedImageReader->GetOutput() );
>>initializer->SetMovingImage( movingImageReader->GetOutput() );
>>
>>Hence I retained it to the outputs from fixedImageReader and
>>movingImageReader, as in the code snippet above. *****PLEASE LET ME KNOW IF
>>THIS IS CORRECT ?
>>
>>If I removed the Normalizing and Smoothing filters, I got an exception that
>>the standard deviation of the metric is very low. It works when sigma = 1.5,
>>but the output is wrong . Hence I retained these filters, with sigma = 0.4.
>>
>>I followed your reply at a thread at nabble.com to download the
>>imageregistration.exe and tried to overlay the output of the initializer
>>(moving image warped with the initializer params) and this step is correct
>>for BrainProtonDensitySliceShifted13x17y.png .
>>
>>My current code fails for both BrainProtonDensitySliceShifted13x17y.png
>>image and BrainProtonDensitySliceR10X13Y17.png image. It gives correct
>>values for translation, but fails for rotation angle, and in both cases,
>>gives high value for scaling ( Sx = ~4 and Sy= ~2) which are completely
>>wrong.
>>
>>I also tried working with MultiResImageRegistration2.cxx code which uses
>>Matte + Affine. The output parameters obtained were WRONG when I tried with
>>BrainProtonDensitySliceR10X13Y17.png image, instead of the example mentioned
>>in the code.
>>
>>I also tried with other optimizers such as Amoeba and OnePlusOne optimizers,
>>with Viola MI + Affine. For Amoeba, the code gives correct result for
>>translation for BrainProtonDensitySliceShifted13x17y.png only if the
>>Parameter scaling is DISABLED. In other cases, the affine angle obtained
>>starts with -83 degrees (where the expected value is R  = 10 ) i.e in few
>>cases code runs to completion, but the answer is wrong OR exception occurs,
>>that sampled point mapped  to outside of the moving image.
>>
>>I am totally confused with the results . I have planned to use Mutual
>>Information registration from ITK for non-medical images.
>>
>>Can you please give me pointers, where I might be going wrong?
>>
>>Thanks for the help,
>>
>>Sharath Venkatesha
>>
>>
>>
>>
>>________________________________
>>From: Luis Ibanez <luis.ibanez at kitware.com>
>>To: sharath v <sharath20284 at yahoo.com>
>>Cc: insight-users at itk.org
>>Sent: Tuesday, June 23, 2009 9:21:42 PM
>>Subject: Re: [Insight-users] Error using Registration - Mutual Information +
>>AffineTransform
>>
>>
>>Hi Sharath,
>>
>>If you are interested in Affine registration you should probably
>>start with ImageRegistration9.cxx instead of modifying
>>ImageRegisration2.cxx.
>>
>>In particular, you are probably missing to set up the
>>ParameterScaling array, which is critical for normalizing the
>>dynamic range of the different Transform parameters.
>>
>>This was not critical for the case of the Translation Transform,
>>but it becomes very important in Rigid and Affine transforms.
>>
>>
>>Please study the ImageRegistration9.cxx example and
>>let us know if you have any questions.
>>
>>
>>       Thanks
>>
>>
>>             Luis
>>
>>
>>----------------------------------------------------
>>On Tue, Jun 23, 2009 at 7:44 PM, sharath v <sharath20284 at yahoo.com> wrote:
>>
>>>Hi,
>>>
>>>I am trying to run example ImageRegistration2 with Affine Transform. This
>>>example uses originally used Mutual Information based registration with
>>>Translation.
>>>
>>>I extended by using AffineTransform, and used the
>>> CenteredTransformInitializer for initialization ( according to example
>>>ImageRegistration9, which uses Affine with MeanSquares optimizer)
>>>
>>>But, I do run into errors.
>>>
>>>For the CenteredTransformInitializer, I use the following piece of code
>>>
>>>typedef itk::CenteredTransformInitializer< TransformType,  FixedImageType,
>>> MovingImageType >  TransformInitializerType;
>>>   TransformInitializerType::Pointer initializer =
>>>TransformInitializerType::New();
>>>   initializer->SetTransform(   transform );
>>>   initializer->SetFixedImage(  fixedImageReader->GetOutput() ); //*******
>>>   initializer->SetMovingImage( movingImageReader->GetOutput() );
>>>//*******
>>>   initializer->MomentsOn();
>>>
>>>   initializer->InitializeTransform();
>>>   registration->SetInitialTransformParameters(transform->GetParameters()
>>>);
>>>
>>>The program runs into completion, but gives WRONG values for scale and
>>>rotation parameters. The translation parameters obtained are correct.
>>>
>>>If I change the starred lines (above in the code) to the take the output
>>>of the  fixedSmoother and movingSmoother respectively ( which I think is
>>>correct, as they are output of the smoothing function in example2) , I get
>>>an exception
>>>
>>>***** Description: itk::ERROR:
>>>MutualInformationImageToImageMetric(012D3058): All the sampled point mapped
>>> to outside of the moving image
>>>
>>>I have tried the same with Mattes Mutual Information example, to get the
>>>same exception.
>>>
>>>I have also used the appropriate scale setting code as in example 9.
>>>
>>>
>>>
>>>Thanks in advance for the help,
>>>
>>>Sharath Venkatesha
>>>
>>>
>>>
>>>
>>>_____________________________________
>>>Powered by www.kitware.com
>>>
>>>Visit other Kitware open-source projects at
>>>http://www.kitware.com/opensource/opensource.html
>>>
>>>Please keep messages on-topic and check the ITK FAQ at:
>>>http://www.itk.org/Wiki/ITK_FAQ
>>>
>>>Follow this link to subscribe/unsubscribe:
>>>http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>>
>>
>>_____________________________________
>>Powered by www.kitware.com
>>
>>Visit other Kitware open-source projects at
>>http://www.kitware.com/opensource/opensource.html
>>
>>Please keep messages on-topic and check the ITK FAQ at:
>>http://www.itk.org/Wiki/ITK_FAQ
>>
>>Follow this link to subscribe/unsubscribe:
>>http://www.itk.org/mailman/listinfo/insight-users
>>
>>
> 
> 
> 
> 
>       
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
> 


More information about the Insight-users mailing list