MantisBT - ITK
View Issue Details
0004893ITKpublic2007-04-17 07:212007-09-10 12:33
Ralf Floca 
Luis Ibanez 
lowfeaturealways
closedfixed 
 
 
0004893: itk::RegularStepGradientDescentBaseOptimizer doesn't check validity of m_GradientMagnitudeTolerance
The itk::RegularStepGradientDescentBaseOptimizer doesn't check validity of the member m_GradientMagnitudeTolerance before starting the optimization. If an invalid (negative) tolerance is set, it is possible that the optimizer will have a gradientMagnitude of 0.0 but won’t stop. This causes the itk::RegularStepGradientDescentOptimizer to compute a factor of -1.#INF in itk::RegularStepGradientDescentOptimizer::AdvanceOneStep and therefore undefined transformation parameters as a step result. This causes e.g. an application to crash when the resulting transformation is used by a metric (like in image registration), because transformed points are undefined too (see also Bug 0004892).

I would suggest that itk::RegularStepGradientDescentBaseOptimizer implements a validity check in
itk::RegularStepGradientDescentBaseOptimizer::StartOptimization() like:
if( m_GradientMagnitudeTolerance < 0.0 )
    {
    itkExceptionMacro(<< "Gradient magnitude tolerance must be greater or equal 0.0. Current value is " << m_GradientMagnitudeTolerance );
No tags attached.
Issue History
2007-09-10 12:23Luis IbanezNote Added: 0008906
2007-09-10 12:32Luis IbanezNote Added: 0008907
2007-09-10 12:33Luis IbanezStatusassigned => closed
2007-09-10 12:33Luis IbanezNote Added: 0008908
2007-09-10 12:33Luis IbanezResolutionopen => fixed

Notes
(0007338)
Ralf Floca   
2007-04-17 07:25   
Forgot an brace on the suggested solution. Correct version:
if( m_GradientMagnitudeTolerance < 0.0 )
    {
    itkExceptionMacro(<< "Gradient magnitude tolerance must be greater or equal 0.0. Current value is " << m_GradientMagnitudeTolerance );
    }
(0008906)
Luis Ibanez   
2007-09-10 12:23   
The validity check has been added to the StartOptimization() method:

http://www.itk.org/cgi-bin/viewcvs.cgi/Code/Numerics/itkRegularStepGradientDescentBaseOptimizer.cxx?root=Insight&sortby=date&r2=1.24&r1=1.23 [^]
(0008907)
Luis Ibanez   
2007-09-10 12:32   
A test for the exception was also added to

Insight/Testing/Code/Numerics/
   itkRegularStepGradientDescentOptimizerTest.cxx

http://www.itk.org/cgi-bin/viewcvs.cgi/Testing/Code/Numerics/itkRegularStepGradientDescentOptimizerTest.cxx?root=Insight&sortby=date&r2=1.23&r1=1.22 [^]
(0008908)
Luis Ibanez   
2007-09-10 12:33   
The modifications were committed and the tests are passing.