[Insight-users] Improving the metric value significantly!

Luis Ibanez luis.ibanez at kitware.com
Sat Aug 15 20:23:46 EDT 2009


Hi Motes,

Another reason why running 10 times 10 iterations may give
your better results is that the RegularStepGradientDescent
optimizer decreases the size of the step length at ever occasion
in which the gradient changes direction. As a consequence is
very likely that when you run 100 iterations in a single run, the
steps of the final 20 to 40 iterations are not doing much at all.

Karthik's explanation is also a very likely reason. Reinitializing
the collection of sample points may have something to do with
the result difference in the results.

You could identify they source by adding to your command
observer a print out of the optimizer step length, and by running
a second registration using All the pixels in the image, instead
of a sub-sampled collection.


      Regards,


            Luis


---------------------------------------------------------------------------------------
On Wed, Aug 12, 2009 at 4:29 AM, motes motes <mort.motes at gmail.com> wrote:

>
>
> On Wed, Aug 12, 2009 at 7:16 AM, Karthik Krishnan <
> karthik.krishnan at kitware.com> wrote:
>
>> What metric ?
>>
>> There could be several reasons. Perhaps you should print out the transform
>> at each iteration.
>>
>> Re-initializing a mattes metric in the latter case means that before each
>> sub-registration step, a fresh random set of samples are picked. This is not
>> the case in the former. (You can set the samples yourself to avoid this).
>>
>> Also some examples may use a linear interpolator during the registration,
>> but a slower and better interpolator (BSplineInterpolator) at the final
>> resampling step. Re-running the example would then "smooth" the image at the
>> end of each registration.
>>
>>
>
> Sorry here is some more info on the components that I use:
>
>
>   typedef double
>
> CoordinateRepType;
>   static const unsigned int SpaceDimension = 2;
>   static const unsigned int SplineOrder = 3;
>   typedef itk::BSplineDeformableTransform<CoordinateRepType,
> SpaceDimension, SplineOrder >      TransformType;
>   typedef itk::RegularStepGradientDescentOptimizer
>                                                OptimizerType;
>   typedef itk::MeanSquaresImageToImageMetric<FixedImageType,
> MovingImageType>                      MetricType;
>   typedef itk:: LinearInterpolateImageFunction<MovingImageType,
> double>                                        InterpolatorType;
>
>
>
> So each time 10 iterations has been made the below 'run' method is called
> where the transform is updated with the 'finalParameters' from the previous
> execution:
>
>
>
> // Setting up the BSpline transform.
>
> ParametersType parameters(numberOfBSplineParameters);
> parameters.Fill(0.0);
>
> // Setting up the optimizer.
> ...
>
> ...
> // Starting the 10*10 iterations
>     for (int i=0; i<runs; i++) {
>       // Run the registration for 'iteration_interval' iterations.
>       run(parameters);
>       writeRegisteredImage(parameters, i);
>     }
> ....
>
>
>   int run(ParametersType & parameters) {
>         transform->SetParameters(parameters);
>
> registration->SetInitialTransformParameters(transform->GetParameters());
>
>     // Add time and memory probes
>     itkProbesCreate();
>     std::cout << std::endl << "[INFO]::Starting Registration" << std::endl;
>     try {
>       itkProbesStart("Registration");
>       registration->Update();
>       itkProbesStop("Registration");
>     }
>     catch( itk::ExceptionObject & err ) {
>       std::cerr << "ExceptionObject caught !" << std::endl;
>       std::cerr << err << std::endl;
>       return EXIT_FAILURE;
>     }
>
>     // Update the finalParameters.
>     parameters = registration->GetLastTransformParameters();
>
>     // Write the final parameters to disk
>     //writeFinalTransformParameters(finalParameters);
>
>     // Report the time and memory taken by the registration
>     itkProbesReport(std::cout);
>     return EXIT_SUCCESS;
>
>   }
>
>
> I never change the optimizer during these runs, only the transform.
>
>
>
>
>
>
>
>
>>
>>
>>
>> On Tue, Aug 11, 2009 at 6:52 PM, motes motes <mort.motes at gmail.com>wrote:
>>
>>>  I am running a modified version of the 2D BSplineDeformableTransform
>>> registration example.
>>>
>>> If I run it for 100 iterations straight I get the following final metric
>>> value and time:
>>>
>>> ...
>>> ...
>>> Current iteration = 99
>>> Metric value = 523.29
>>>
>>> [INFO]::Write last Transform Parameters
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           760.658
>>>
>>>
>>>
>>>
>>>
>>>
>>> Now If I run it as 10*10 iterations where I pass the
>>> finalTransformParameters as input to the transform after each of the 10
>>> iterations I get:
>>>
>>>
>>>
>>> Current iteration = 9
>>> Metric value = 330.641
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           72.7789
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> The total time for the 10*10 approach is:
>>>
>>>         Registration           1            1            71.379
>>>         Registration           1            1           71.2781
>>>         Registration           1            1           71.3366
>>>         Registration           1            1           71.0148
>>>         Registration           1            1           71.0298
>>>         Registration           1            1           71.2541
>>>         Registration           1            1           71.8186
>>>         Registration           1            1           71.0167
>>>         Registration           1            1           73.3319
>>>         Registration           1            1           72.7789
>>>
>>> total:                                                         716,2085
>>>
>>>
>>> So the quality is about a factor 523.29/330.641 = 1.583 better and about
>>> 44 seconds faster.
>>>
>>> Any ideas on why performing 10*10 iterations give such a better result
>>> than performing 100 iterations straight?
>>>
>>>
>>> Below is the complete print of both test. First the 100 iterations
>>> straight and then the 10*10 iterations:
>>>
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 1250.41
>>>
>>> Current iteration = 1
>>> Metric value = 1052.62
>>>
>>> Current iteration = 2
>>> Metric value = 998.251
>>>
>>> Current iteration = 3
>>> Metric value = 988.934
>>>
>>> Current iteration = 4
>>> Metric value = 939.29
>>>
>>> Current iteration = 5
>>> Metric value = 928.959
>>>
>>> Current iteration = 6
>>> Metric value = 886.587
>>>
>>> Current iteration = 7
>>> Metric value = 878.586
>>>
>>> Current iteration = 8
>>> Metric value = 839.342
>>>
>>> Current iteration = 9
>>> Metric value = 836.203
>>>
>>> Current iteration = 10
>>> Metric value = 817.779
>>>
>>> Current iteration = 11
>>> Metric value = 802.519
>>>
>>> Current iteration = 12
>>> Metric value = 785.766
>>>
>>> Current iteration = 13
>>> Metric value = 774.242
>>>
>>> Current iteration = 14
>>> Metric value = 754.812
>>>
>>> Current iteration = 15
>>> Metric value = 743.522
>>>
>>> Current iteration = 16
>>> Metric value = 737.235
>>>
>>> Current iteration = 17
>>> Metric value = 728.559
>>>
>>> Current iteration = 18
>>> Metric value = 717.322
>>>
>>> Current iteration = 19
>>> Metric value = 705.742
>>>
>>> Current iteration = 20
>>> Metric value = 700.79
>>>
>>> Current iteration = 21
>>> Metric value = 700.665
>>>
>>> Current iteration = 22
>>> Metric value = 690.481
>>>
>>> Current iteration = 23
>>> Metric value = 689.587
>>>
>>> Current iteration = 24
>>> Metric value = 682.805
>>>
>>> Current iteration = 25
>>> Metric value = 681.994
>>>
>>> Current iteration = 26
>>> Metric value = 677.302
>>>
>>> Current iteration = 27
>>> Metric value = 675.799
>>>
>>> Current iteration = 28
>>> Metric value = 670.539
>>>
>>> Current iteration = 29
>>> Metric value = 669.862
>>>
>>> Current iteration = 30
>>> Metric value = 665.488
>>>
>>> Current iteration = 31
>>> Metric value = 664.107
>>>
>>> Current iteration = 32
>>> Metric value = 659.459
>>>
>>> Current iteration = 33
>>> Metric value = 658.766
>>>
>>> Current iteration = 34
>>> Metric value = 655.056
>>>
>>> Current iteration = 35
>>> Metric value = 653.779
>>>
>>> Current iteration = 36
>>> Metric value = 649.939
>>>
>>> Current iteration = 37
>>> Metric value = 648.844
>>>
>>> Current iteration = 38
>>> Metric value = 645.275
>>>
>>> Current iteration = 39
>>> Metric value = 644.185
>>>
>>> Current iteration = 40
>>> Metric value = 640.996
>>>
>>> Current iteration = 41
>>> Metric value = 639.828
>>>
>>> Current iteration = 42
>>> Metric value = 636.705
>>>
>>> Current iteration = 43
>>> Metric value = 635.562
>>>
>>> Current iteration = 44
>>> Metric value = 632.591
>>>
>>> Current iteration = 45
>>> Metric value = 631.601
>>>
>>> Current iteration = 46
>>> Metric value = 628.668
>>>
>>> Current iteration = 47
>>> Metric value = 627.825
>>>
>>> Current iteration = 48
>>> Metric value = 625.127
>>>
>>> Current iteration = 49
>>> Metric value = 624.047
>>>
>>> Current iteration = 50
>>> Metric value = 621.346
>>>
>>> Current iteration = 51
>>> Metric value = 620.275
>>>
>>> Current iteration = 52
>>> Metric value = 617.845
>>>
>>> Current iteration = 53
>>> Metric value = 616.837
>>>
>>> Current iteration = 54
>>> Metric value = 614.049
>>>
>>> Current iteration = 55
>>> Metric value = 612.977
>>>
>>> Current iteration = 56
>>> Metric value = 610.341
>>>
>>> Current iteration = 57
>>> Metric value = 609.481
>>>
>>> Current iteration = 58
>>> Metric value = 606.853
>>>
>>> Current iteration = 59
>>> Metric value = 605.766
>>>
>>> Current iteration = 60
>>> Metric value = 602.988
>>>
>>> Current iteration = 61
>>> Metric value = 601.962
>>>
>>> Current iteration = 62
>>> Metric value = 599.225
>>>
>>> Current iteration = 63
>>> Metric value = 598.164
>>>
>>> Current iteration = 64
>>> Metric value = 595.356
>>>
>>> Current iteration = 65
>>> Metric value = 594.261
>>>
>>> Current iteration = 66
>>> Metric value = 591.51
>>>
>>> Current iteration = 67
>>> Metric value = 590.453
>>>
>>> Current iteration = 68
>>> Metric value = 587.536
>>>
>>> Current iteration = 69
>>> Metric value = 586.469
>>>
>>> Current iteration = 70
>>> Metric value = 583.695
>>>
>>> Current iteration = 71
>>> Metric value = 582.713
>>>
>>> Current iteration = 72
>>> Metric value = 579.95
>>>
>>> Current iteration = 73
>>> Metric value = 578.899
>>>
>>> Current iteration = 74
>>> Metric value = 576.22
>>>
>>> Current iteration = 75
>>> Metric value = 575.275
>>>
>>> Current iteration = 76
>>> Metric value = 572.503
>>>
>>> Current iteration = 77
>>> Metric value = 571.669
>>>
>>> Current iteration = 78
>>> Metric value = 568.888
>>>
>>> Current iteration = 79
>>> Metric value = 568.318
>>>
>>> Current iteration = 80
>>> Metric value = 565.322
>>>
>>> Current iteration = 81
>>> Metric value = 564.652
>>>
>>> Current iteration = 82
>>> Metric value = 561.529
>>>
>>> Current iteration = 83
>>> Metric value = 561.349
>>>
>>> Current iteration = 84
>>> Metric value = 558.059
>>>
>>> Current iteration = 85
>>> Metric value = 557.616
>>>
>>> Current iteration = 86
>>> Metric value = 554.179
>>>
>>> Current iteration = 87
>>> Metric value = 553.638
>>>
>>> Current iteration = 88
>>> Metric value = 550.255
>>>
>>> Current iteration = 89
>>> Metric value = 549.459
>>>
>>> Current iteration = 90
>>> Metric value = 545.765
>>>
>>> Current iteration = 91
>>> Metric value = 544.212
>>>
>>> Current iteration = 92
>>> Metric value = 540.783
>>>
>>> Current iteration = 93
>>> Metric value = 538.406
>>>
>>> Current iteration = 94
>>> Metric value = 535.319
>>>
>>> Current iteration = 95
>>> Metric value = 532.849
>>>
>>> Current iteration = 96
>>> Metric value = 530.019
>>>
>>> Current iteration = 97
>>> Metric value = 527.351
>>>
>>> Current iteration = 98
>>> Metric value = 525.077
>>>
>>> Current iteration = 99
>>> Metric value = 523.29
>>>
>>> [INFO]::Write last Transform Parameters
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           760.658
>>> [INFO]::Registration completed!
>>>
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>>
>>>
>>>
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 1250.41
>>>
>>> Current iteration = 1
>>> Metric value = 1052.62
>>>
>>> Current iteration = 2
>>> Metric value = 998.251
>>>
>>> Current iteration = 3
>>> Metric value = 988.934
>>>
>>> Current iteration = 4
>>> Metric value = 939.29
>>>
>>> Current iteration = 5
>>> Metric value = 928.959
>>>
>>> Current iteration = 6
>>> Metric value = 886.587
>>>
>>> Current iteration = 7
>>> Metric value = 878.586
>>>
>>> Current iteration = 8
>>> Metric value = 839.342
>>>
>>> Current iteration = 9
>>> Metric value = 836.203
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1            71.379
>>> [INFO]::Registered image saved!
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 817.779
>>>
>>> Current iteration = 1
>>> Metric value = 911.784
>>>
>>> Current iteration = 2
>>> Metric value = 786.9
>>>
>>> Current iteration = 3
>>> Metric value = 823.547
>>>
>>> Current iteration = 4
>>> Metric value = 764.919
>>>
>>> Current iteration = 5
>>> Metric value = 787.627
>>>
>>> Current iteration = 6
>>> Metric value = 735.425
>>>
>>> Current iteration = 7
>>> Metric value = 753.176
>>>
>>> Current iteration = 8
>>> Metric value = 713.713
>>>
>>> Current iteration = 9
>>> Metric value = 725.794
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           71.2781
>>> [INFO]::Registered image saved!
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 694.506
>>>
>>> Current iteration = 1
>>> Metric value = 844.985
>>>
>>> Current iteration = 2
>>> Metric value = 695.623
>>>
>>> Current iteration = 3
>>> Metric value = 725.924
>>>
>>> Current iteration = 4
>>> Metric value = 678.204
>>>
>>> Current iteration = 5
>>> Metric value = 717.822
>>>
>>> Current iteration = 6
>>> Metric value = 667.199
>>>
>>> Current iteration = 7
>>> Metric value = 694.74
>>>
>>> Current iteration = 8
>>> Metric value = 649.602
>>>
>>> Current iteration = 9
>>> Metric value = 672.77
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           71.3366
>>> [INFO]::Registered image saved!
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 637.146
>>>
>>> Current iteration = 1
>>> Metric value = 816.554
>>>
>>> Current iteration = 2
>>> Metric value = 659.315
>>>
>>> Current iteration = 3
>>> Metric value = 684.975
>>>
>>> Current iteration = 4
>>> Metric value = 645.472
>>>
>>> Current iteration = 5
>>> Metric value = 674.427
>>>
>>> Current iteration = 6
>>> Metric value = 627.892
>>>
>>> Current iteration = 7
>>> Metric value = 651.59
>>>
>>> Current iteration = 8
>>> Metric value = 611.565
>>>
>>> Current iteration = 9
>>> Metric value = 630.496
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           71.0148
>>> [INFO]::Registered image saved!
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 597.433
>>>
>>> Current iteration = 1
>>> Metric value = 778.622
>>>
>>> Current iteration = 2
>>> Metric value = 610.481
>>>
>>> Current iteration = 3
>>> Metric value = 653.762
>>>
>>> Current iteration = 4
>>> Metric value = 588.401
>>>
>>> Current iteration = 5
>>> Metric value = 641.37
>>>
>>> Current iteration = 6
>>> Metric value = 566.543
>>>
>>> Current iteration = 7
>>> Metric value = 604.455
>>>
>>> Current iteration = 8
>>> Metric value = 551.011
>>>
>>> Current iteration = 9
>>> Metric value = 574.794
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           71.0298
>>> [INFO]::Registered image saved!
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 531.244
>>>
>>> Current iteration = 1
>>> Metric value = 674.44
>>>
>>> Current iteration = 2
>>> Metric value = 526.883
>>>
>>> Current iteration = 3
>>> Metric value = 553.249
>>>
>>> Current iteration = 4
>>> Metric value = 490.66
>>>
>>> Current iteration = 5
>>> Metric value = 522.099
>>>
>>> Current iteration = 6
>>> Metric value = 482.033
>>>
>>> Current iteration = 7
>>> Metric value = 505.727
>>>
>>> Current iteration = 8
>>> Metric value = 461.877
>>>
>>> Current iteration = 9
>>> Metric value = 480.441
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           71.2541
>>> [INFO]::Registered image saved!
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 445.601
>>>
>>> Current iteration = 1
>>> Metric value = 610.837
>>>
>>> Current iteration = 2
>>> Metric value = 462.224
>>>
>>> Current iteration = 3
>>> Metric value = 485.76
>>>
>>> Current iteration = 4
>>> Metric value = 434.521
>>>
>>> Current iteration = 5
>>> Metric value = 464.248
>>>
>>> Current iteration = 6
>>> Metric value = 426.544
>>>
>>> Current iteration = 7
>>> Metric value = 441.414
>>>
>>> Current iteration = 8
>>> Metric value = 408.767
>>>
>>> Current iteration = 9
>>> Metric value = 414.533
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           71.8186
>>> [INFO]::Registered image saved!
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 393.686
>>>
>>> Current iteration = 1
>>> Metric value = 594.624
>>>
>>> Current iteration = 2
>>> Metric value = 395.791
>>>
>>> Current iteration = 3
>>> Metric value = 442.752
>>>
>>> Current iteration = 4
>>> Metric value = 371.636
>>>
>>> Current iteration = 5
>>> Metric value = 400.695
>>>
>>> Current iteration = 6
>>> Metric value = 357.976
>>>
>>> Current iteration = 7
>>> Metric value = 390.926
>>>
>>> Current iteration = 8
>>> Metric value = 357.633
>>>
>>> Current iteration = 9
>>> Metric value = 373.616
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           71.0167
>>> [INFO]::Registered image saved!
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 345.033
>>>
>>> Current iteration = 1
>>> Metric value = 566.574
>>>
>>> Current iteration = 2
>>> Metric value = 349.902
>>>
>>> Current iteration = 3
>>> Metric value = 412.93
>>>
>>> Current iteration = 4
>>> Metric value = 329.867
>>>
>>> Current iteration = 5
>>> Metric value = 394.653
>>>
>>> Current iteration = 6
>>> Metric value = 321.353
>>>
>>> Current iteration = 7
>>> Metric value = 376.426
>>>
>>> Current iteration = 8
>>> Metric value = 309.734
>>>
>>> Current iteration = 9
>>> Metric value = 354.27
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           73.3319
>>> [INFO]::Registered image saved!
>>>
>>> [INFO]::Starting Registration
>>> Current iteration = 0
>>> Metric value = 300.254
>>>
>>> Current iteration = 1
>>> Metric value = 522.97
>>>
>>> Current iteration = 2
>>> Metric value = 318.137
>>>
>>> Current iteration = 3
>>> Metric value = 386.045
>>>
>>> Current iteration = 4
>>> Metric value = 316.046
>>>
>>> Current iteration = 5
>>> Metric value = 381.835
>>>
>>> Current iteration = 6
>>> Metric value = 300.562
>>>
>>> Current iteration = 7
>>> Metric value = 354.384
>>>
>>> Current iteration = 8
>>> Metric value = 286.474
>>>
>>> Current iteration = 9
>>> Metric value = 330.641
>>>
>>>           Probe Tag    Starts    Stops             Time (s)
>>>         Registration           1            1           72.7789
>>>
>>>
>>>
>>>
>>>
>>>
>>> _____________________________________
>>> 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
>>>
>>>
>>
>>
>> --
>> Karthik Krishnan
>> R&D Engineer,
>> Kitware Inc.
>> Ph: 518 881 4919
>> Fax: 518 371 4573
>>
>
>
> _____________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090815/822bcf88/attachment-0001.htm>


More information about the Insight-users mailing list