26 unsigned int iteration = 0;
28 itk::RegularStepGradientDescentBaseOptimizer *rsgdbase =
29 dynamic_cast<itk::RegularStepGradientDescentBaseOptimizer *
>(optimizer);
30 if (rsgdbase !=
nullptr)
32 m_OptimizerValue = rsgdbase->GetValue();
33 m_Params = rsgdbase->GetCurrentPosition();
34 iteration = rsgdbase->GetCurrentIteration();
36 MITK_INFO <<
"(" << iteration <<
") " << m_OptimizerValue <<
" :: " << m_Params << std::endl;
38 if (this->m_StopOptimization)
40 rsgdbase->StopOptimization();
41 m_StopOptimization =
false;
46 itk::GradientDescentOptimizer *gdbase =
dynamic_cast<itk::GradientDescentOptimizer *
>(optimizer);
47 if (gdbase !=
nullptr)
49 m_OptimizerValue = gdbase->GetValue();
50 m_Params = gdbase->GetCurrentPosition();
51 iteration = gdbase->GetCurrentIteration();
53 MITK_INFO <<
"(" << iteration <<
") " << m_OptimizerValue <<
" :: " << m_Params << std::endl;
55 if (this->m_StopOptimization)
57 gdbase->StopOptimization();
58 m_StopOptimization =
false;
63 itk::PowellOptimizer *powbase =
dynamic_cast<itk::PowellOptimizer *
>(optimizer);
64 if (powbase !=
nullptr)
66 m_OptimizerValue = powbase->GetValue();
67 m_Params = powbase->GetCurrentPosition();
68 iteration = powbase->GetCurrentIteration();
70 MITK_INFO <<
"(" << iteration <<
") " << m_OptimizerValue <<
" :: " << m_Params << std::endl;
72 if (this->m_StopOptimization)
74 powbase->StopOptimization();
75 m_StopOptimization =
false;
80 itk::OnePlusOneEvolutionaryOptimizer *opluso =
dynamic_cast<itk::OnePlusOneEvolutionaryOptimizer *
>(optimizer);
81 if (opluso !=
nullptr)
83 m_OptimizerValue = opluso->GetValue();
84 m_Params = opluso->GetCurrentPosition();
85 iteration = opluso->GetCurrentIteration();
87 MITK_INFO <<
"(" << iteration <<
") " << m_OptimizerValue <<
" :: " << m_Params << std::endl;
89 if (this->m_StopOptimization)
91 powbase->StopOptimization();
92 m_StopOptimization =
false;
100 if (
typeid(event) ==
typeid(itk::IterationEvent))
104 if (optimizer !=
nullptr)
106 this->HandleOptimizationIterationEvent(optimizer);
108 InvokeEvent(itk::ModifiedEvent());
111 else if (
typeid(event) ==
typeid(itk::FunctionEvaluationIterationEvent))
114 itk::AmoebaOptimizer *AmoebaOptimizer =
dynamic_cast<itk::AmoebaOptimizer *
>(optimizer);
115 if (AmoebaOptimizer !=
nullptr)
117 m_OptimizerValue = AmoebaOptimizer->GetCachedValue();
118 MITK_INFO << AmoebaOptimizer->GetCachedValue() <<
" " << AmoebaOptimizer->GetCachedCurrentPosition()
120 m_Params = AmoebaOptimizer->GetCachedCurrentPosition();
121 if (m_StopOptimization)
124 m_StopOptimization =
false;
126 InvokeEvent(itk::ModifiedEvent());
149 return m_OptimizerValue;
162 m_StopOptimization = stopOptimization;
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
void AddStepsToDo(int steps)
Add new steps to the progress bar.
void HandleOptimizationIterationEvent(OptimizerType *optimizer)
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
void SetRemainingProgress(int steps)
Sets the remaining progress to the progress bar when the optimization process is done.
OptimizerType * OptimizerPointer
RigidRegistrationObserver()
void SetStopOptimization(bool stopOptimization)
Sets the stop optimization flag, which is used to call the StopOptimization() method of the optimizer...
double GetCurrentOptimizerValue()
Returns the current optimizer value. This value is calculated by the used metric and shows...
void AddStepsToDo(unsigned int steps)
Adds steps to totalSteps.
itk::SingleValuedNonLinearOptimizer OptimizerType
itk::Array< double > GetCurrentTranslation()
Returns the current transformation parameters for the moving image to this iteration step...
void Execute(itk::Object *caller, const itk::EventObject &event) override
Reacts on events from ITK optimizers.