[Insight-users] How to limit rotations when registering in ITK?

Luis Ibanez luis.ibanez at kitware.com
Tue Oct 12 08:53:00 EDT 2004


Hi Robert,

The optimizer does not crash...
it throws an Exception.

You must put all the invocations for optimizers
iterations inside a try/catch block.  Please
look at the ITK Software Guide

   http://www.itk.org/ItkSoftwareGuide.pdf

for examples on how to set try/catch blocks.
They are abundant in the Registration chapter.


About the fact that the optimizer is not running
any iterations, this may be related to the tolerances
that you define. It may be possible that the cost
function is satisfying the stopping criterion at the
first evaluation.

BTW: What lead you to think that the optimizer
      is not doing any iterations ?



Regards,


    Luis



-----------------------
Robert Maroon wrote:

>     Hi Edi,
>      
>     I actually went ahead and installed ITK 1.8.0 and tried to integrate
>     the new optimizer. However the program just runs through without
>     doing anything (not even going through any iterations) if I have the
>     following code:
>      
>       typedef itk::LBFGSBOptimizer       OptimizerType;
>      
>       typedef itk::MeanSquaresImageToImageMetric<
>                                         FixedImageType,
>                                         MovingImageType >    MetricType;
>      
>       MetricType::Pointer         metric        = MetricType::New();
>       OptimizerType::Pointer      optimizer     = OptimizerType::New();
>      
>      // optimizer->SetCostFunction( metric.GetPointer() );
>      
>       const double F_Convergence_Factor  = 1e+7;      // Function value
>     tolerance
>       const double Projected_G_Tolerance = 1e-5;      // Proj gradient
>     tolerance
>       const int    Max_Iterations   =   100; // Maximum number of iterations
>       optimizer->SetCostFunctionConvergenceFactor( F_Convergence_Factor );
>       optimizer->SetProjectedGradientTolerance( Projected_G_Tolerance );
>       optimizer->SetMaximumNumberOfIterations( Max_Iterations );
>       optimizer->SetMaximumNumberOfEvaluations( Max_Iterations );
> 
>       const unsigned int SpaceDimension = 5;
> 
>       OptimizerType::BoundValueType lower(SpaceDimension);
>       OptimizerType::BoundValueType upper(SpaceDimension);
>       OptimizerType::BoundSelectionType select(SpaceDimension);
> 
>       lower.Fill( -5 );
>       upper.Fill( 5 );
>       select.Fill( SpaceDimension );
>       optimizer->SetLowerBound( lower );
>       optimizer->SetUpperBound( upper );
>       optimizer->SetBoundSelection( select );
> 
>     However if I uncomment the line: optimizer->SetCostFunction(
>     metric.GetPointer() );
>     then it crashes when it tries to access m_transform within
>     itk::MeanSquaresImageToImageMetric. I am wondering how I can include
>     the cost function (since it doesn't seem to do anything
>     otherwise) and am I doing something else wrong that is causing the
>     optimizer to have no effect.
>      
>     Thanks again and sorry for the repeated questions but I have been
>     trying to get this thing to run for a long time!
>     Robert
> 
>     */Eduard Schreibmann <eduards at stanford.edu>/* wrote:
> 
>         Hi Robert.
>          
>         I think it is a fairlly new adition to ITK, even newer than 1.8
>         maybe. it appeared suddenly in the latest manual documentation.
>          
>         Attached is the code from my computer, maybe you can get along
>         without compiling, by just adding itkLBFGSB files to your
>         project (that is compiling it in your oproject rather than in
>         the ITK library). It is not an elegant solution but I think
>         it may work, and anyway it is not a big deal to try this before
>         recompiling ITK. There is also an example of how to set limits.
>         With my images, I had problems with LBFGSB because it was not
>         making many iterations. it took days to find out it is important
>         to use a good BSpline interpolator, so if you have problems with
>         LBFGSB not converging, it may be that you need a good interpolator  
>          
>         Cheers and good luck with the code.
>         Edi
>          
>         Edi
> 
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete 
> <http://us.rd.yahoo.com/mail_us/taglines/aac/*http://promotions.yahoo.com/new_mail/static/ease.html> 
> - You start. We finish.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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