[Insight-users] NormalizedMutualInformationMetric

Luis Ibanez luis.ibanez at kitware.com
Fri May 30 11:11:55 EDT 2008


Hi Giorgos,


Thanks for the update.


Here are some suggestions:


1) If the optimizer is using all the iterations alloted in
    your "maximum", then you should consider

     a) increasing the step of the optimizer  and/or
     b) improving the transform initialization


2) 3 seconds per iterations looks like a really long
    time for a pair of 2D images.

    How big are these images ?
    (#pixels in X and Y ?)


3) If the optimizer passed over the correct solution
    and continued iterating, this may indicate that

    a) The metric is not configured appropriately

    b) The optimizer is not relaxing on time
       What optimizer are you using ?

    You can tell (a) from (b) by looking a the
    metric values at every iteration. If they
    were changing monotonically as the optimizer
    crosses the optimal transform values, then
    the problem is (a). If the values when up
    and down as the optimizer crossed the optimal
    value, then the problem is (b).




   Regards,


      Luis



-----------------------
Giorgos Pichis wrote:
> Hi Luis
> 
> I changed the transform to Similarity2DTransform as you proposed and had 
> much better results.
> The changes were ...
> ////  METRIC SCALES
> 
> typedef MetricType::ScalesType ScalesType;
> ScalesType scales( numberOfParameters );
> scales[0] =  10.0; //scale
> scales[1] =  1.0; //angle
> scales[2] =  0.01; //Translation X
> scales[3] =  0.01; //Translation Y
>  metric->SetDerivativeStepLengt
> hScales(scales);
> .......
> ///// OPTIMIZER SCALES
> 
>    FixedImageType::RegionType region = 
> fixedImage->GetLargestPossibleRegion();
>   FixedImageType::SizeType size = region.GetSize();
>   FixedImageType::SpacingType spacing = fixedImage->GetSpacing();
> 
> 
>   typedef OptimizerType::ScalesType       OptimizerScalesType;
>   OptimizerScalesType optimizerScales( transform->GetNumberOfParameters() );
>   optimizerScales[0] = 10.0;
>   optimizerScales[1] =  10.0;
>   optimizerScales[2] =   1.0 / ( 0.1 * size[0] * spacing[0] );
>   optimizerScales[3] =   1.0 / ( 0.1 * size[1] * spacing[1] );
>   optimizer->SetScales( optimizerScales );
> ...............
> 
> 
> results (5000 
> iterations)                                                                     
> 
> scale 0.833371,  angle -0.175554,  TrX      7.3605,  TrY      7.89029, 
> Metric 1.31231,MSDafter 204.473, CCafter    0.984774
> 
> MSD=MeanSquareDifference after registration, CC=CorrelationCoefficient 
> after registration
> 
> results (7000 iterations)
> scale 0.833493, angle -0.175483,   TrX      7.21419,TrY      7.7625,   
> Metric 1.33357,MSDafter 153.119,  CCafter    0.988688
> 
> results (15000 iterations)
> scale 0.833746, angle -0.174136,   TrX      6.86705,TrY      
> 7.43349,Metric 1.31354, MSDafter 182.968,  CCafter    0.986441
> 
> The "optimum" results taken from mattes metric where
> 
> results
> scale 0.832628 angle -0.174455  TrX   7.37987    TrY      8.52768  
> Metric -1.42415  MSDafter 77.9344    CCafter    0.994369
> 
> 
> The problem with the results I got, and which are presented above are:
> 1) NMI metric reached the maximum number of iterations, (and took a 
> rather long time (approx 3sec/iteration.) although that was expected) 
> Should I set the number of iterations, approx in that number, that I 
> take the better results?
> 2) With the parameters I set the optimizer,  and metric scales, the 
> algorithm was pretty close to the optimum results. But when it reached 
> some of them, it kept running in a steady mode, not converging towards them.
> 
> Is there any possible solution to these problems?
> Thanks,
> Giorgos
> 
> 
> On Mon, May 12, 2008 at 6:49 PM, Luis Ibanez <luis.ibanez at kitware.com 
> <mailto:luis.ibanez at kitware.com>> wrote:
> 
> 
>     Hi Giorgos,
> 
>     Thanks for posting your progress on this problem.
> 
>     Here are some comments:
> 
>     1) Yes, when using Normalized Mutual Information
>       you should set the optimizer to "maximize".
>       You are doing this right by calling
>       "optimizer->MaximizeOn();"
> 
>       see for example
> 
>       Insight/Examples/Registration/ImageRegistration14.cxx
> 
> 
>     2) The Optimizer scales are definitely a good place
>       to look for a culprit.
> 
>       With your current scale selection you are actually
>       telling the optimizer to avoid changing the values
>       of the Transform's center of rotation, which is a
>       good thing.
> 
>       One thing you should try is replacing the
> 
>            itkCenteredSimilarity2DTransform
> 
>       with the
> 
>            itkSimilarity2DTransform
> 
>       The second one still offers the user the possibility
>       of setting a customized a center of rotation, but
>       as opposed to the first one, it doesn't include the
>       center coordinates in the list of parameters to be
>       optimized. In other words, with the second transform
>       the optimizer will not try to change the center of
>       rotation.
> 
>       Historical note: initially ITK transforms didn't
>       provided a SetCenter() method. E.g. by default,
>       all rotations and scalings were performed with
>       respect to the origin (0,0).
> 
>       Later on we introduced the variants of Transform with
>       center of rotation, and we called "Centered" transforms,
>       however, we made the mistake of including the coordinate
>       of the center of rotation in the list of parameters to
>       optimize.
> 
>       Later on it was decided that almost all transforms
>       needed a customizable center of rotation, and the
>       functionality was added to the basic transform, but
>       without inserting the coordinates of the center of
>       rotation in to the parameters array.
> 
>       Allowing the optimizer to move the center of rotation
>       makes the Transform to behave very unstably, and therefore
>       should only be done by allowing the optimizer to make
>       very small changes in the center of rotation (as you
>       already discovered).
> 
>       Switching to the itkSimilarity2DTransform may alleviate
>       some of the stability problems that you are facing.
> 
>       Please note that the Similarity2DTransform have *less*
>       parameters. Only four, instead of the six parameters
>       in the CenteredSimilarity2DTransform.
> 
>       Note also that the "Scale" and "Angle" parameters are
>       still critical in this transforms and you should apply
>       the same approach that you have used for the Centered
>       transform. (e.g. using different optimizer scalings
>       for these two first parameters of the Transform).
> 
> 
> 
>     Please give it a try at this modification and
>     let us know how it works for you.
> 
> 
> 
>       Thanks
> 
> 
>          Luis
> 
> 
>     ---------------------
>     Giorgos Pichis wrote:
> 
>         Hi,
>         I made some changes to the code,
>         and it seems as it is having better results,
>         but they are still far from the optimum.
> 
>         I am using the BrainProtonDensitySlice.png  and
>         BrainProtonDensitySliceR10X13Y17S12.png from
>         the examples data to test the algorithm.
> 
>         As far as the metric parameters are concerned , I did the
>         following changes:
>         //////////////////////
>          const unsigned int numberOfParameters =
>         transform->GetNumberOfParameters();
> 
>          typedef MetricType::ScalesType ScalesType;
>          ScalesType scales( numberOfParameters );
>         double t_scale;
>         double center_scale;
>          //scales.Fill( 1.0 );
>            std::cout<<" enter center_scale : ";
>          std::cin>>center_scale;
>          std::cout<<" enter t_scale : ";
>          std::cin>>t_scale;
>          std::cout<<" enter scales[0] : "; //scaling
>          std::cin>>scales[0];
>            std::cout<<" enter scales[1] : "; //angle
>          std::cin>>scales[1];
>            //const double t_scale=0.1; //translation scale
>          //scales[0] =  10.0;
>          //scales[1] =  1.0;
>          scales[2] =  center_scale;
>          scales[3] =  center_scale;
>          scales[4] =  t_scale;
>          scales[5] =  t_scale;
> 
>            metric->SetDerivativeStepLengthScales(scales);
>          metric->SetDerivativeStepLength(1.0);
> 
>         /////////
>         ... and had some relatively (to the previous ones) good results,
>         using:
>         center_scale :10000,
>         t_scale: 0.1
>         scale[0] :0.1  //for scaling
>         scale[1] :1  //for the angle
> 
>         Also the optimizer setting where changes to:
> 
> 
>          typedef OptimizerType::ScalesType       OptimizerScalesType;
>          OptimizerScalesType optimizerScales(
>         transform->GetNumberOfParameters() );
>          const double translationScale = 1.0 / 100.0;
>          const double centerScale =1.0/100.0;
> 
>          optimizerScales[0] = 10.0;
>          optimizerScales[1] =  1.0;
>          optimizerScales[2] =  centerScale;
>          optimizerScales[3] =  centerScale;
>          optimizerScales[4] =  translationScale;
>          optimizerScales[5] =  translationScale;
> 
>          optimizer->SetScales( optimizerScales );
> 
>          double steplength = 1.0;
>            if( argc > 9 )
>            {
>            steplength = atof( argv[9] );
>            }
>          optimizer->SetMaximumStepLength( steplength );
>          optimizer->SetMinimumStepLength( 0.00001 );
>          optimizer->SetNumberOfIterations( 500 );
>          optimizer->MaximizeOn(); //change
>         .... using step lenght=0.5
>         The algorithm exited, at iteration number 70,
>         with
>         Scale 1.00275
>         Angle (radians) -0.160493
>         Angle (degrees) -9.19556
>         Center X = 90.318
>         Center Y = 108.849
>         Translation X=15.2579
>         Translation Y= 15.4322
>         Metric Value= 1.07114
> 
>         Can I get some help , on what further changes should I do,
>         in order to get better results?
>         I had almost optimum results working with Mattes MI,
>         Scale 0.832628
>         Angle (radians) -0.174455
>         Angle (degrees) -9.99554
>         Center X = 87.1628
>         Center Y = 107.813
>         Translation X=7.37987
>         Translation Y= 8.52768
>         Metric Value= -1.42415,
>         but I want to get familiar and work with NMI.
>         What changes to the scales parameters, should I do?
> 
>         Thanks in advance,
>         Giorgos
> 
> 
> 
> 
> 
>         ------------------------------------------------------------------------
> 
>         _______________________________________________
>         Insight-users mailing list
>         Insight-users at itk.org <mailto:Insight-users at itk.org>
>         http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list