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

Robert Maroon robertmaroon at yahoo.com
Mon Oct 11 17:11:40 EDT 2004


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 - You start. We finish.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20041011/f478e646/attachment-0001.html


More information about the Insight-users mailing list