19 template <
class TRegistration,
class TPixel>
30 typedef itk::MultiResolutionImageRegistrationMethod<itk::Image<float, 3>, itk::Image<float, 3>>
RegistrationType;
35 typedef itk::ImageMaskSpatialObject<3>
MaskType;
42 void Execute(itk::Object *
object,
const itk::EventObject &event)
override
44 if (!(itk::IterationEvent().CheckEvent(&event)))
49 RegistrationPointer registration =
dynamic_cast<RegistrationPointer
>(object);
54 std::cout <<
"-------------------------------------" << std::endl;
55 std::cout <<
"MultiResolution Level : " << registration->GetCurrentLevel() << std::endl << std::endl;
57 if (registration->GetCurrentLevel() == 0)
68 itk::Array<double> optimizerValues = preset->
getOptimizerValues(m_Presets[registration->GetCurrentLevel()]);
70 optimizerParameters->SetOptimizer(optimizerValues[0]);
71 optimizerParameters->SetMaximize(
76 optimizerParameters->SetLearningRateGradientDescent(optimizerValues[2]);
77 optimizerParameters->SetNumberOfIterationsGradientDescent(optimizerValues[3]);
82 cout <<
"use regularstepgradientdescent" << endl;
83 optimizerParameters->SetGradientMagnitudeToleranceRegularStepGradientDescent(optimizerValues[2]);
84 optimizerParameters->SetMinimumStepLengthRegularStepGradientDescent(optimizerValues[3]);
85 optimizerParameters->SetMaximumStepLengthRegularStepGradientDescent(optimizerValues[4]);
86 optimizerParameters->SetRelaxationFactorRegularStepGradientDescent(optimizerValues[5]);
87 optimizerParameters->SetNumberOfIterationsRegularStepGradientDescent(optimizerValues[6]);
92 optFac->SetOptimizerParameters(optimizerParameters);
93 optFac->SetNumberOfTransformParameters(registration->GetTransform()->GetNumberOfParameters());
96 if (observer.IsNotNull())
98 optimizer->AddObserver(itk::AnyEvent(), observer);
101 itk::Array<double> transformValues = preset->
getTransformValues(m_Presets[registration->GetCurrentLevel()]);
103 itk::Array<double> scales;
107 transformParameters->SetTransform(transformValues[0]);
109 for (
unsigned int i = 0; i < scales.size(); i++)
111 scales[i] = transformValues[i + 2];
112 std::cout <<
"scale " << i <<
": " << scales[i] << std::endl;
115 transformParameters->SetScales(scales);
119 if (transformValues[1] == 1)
121 transformParameters->SetUseOptimizerScales(
true);
124 if (transformParameters->GetUseOptimizerScales())
126 itk::Array<double> optimizerScales = transformParameters->GetScales();
127 typename OptimizerType::ScalesType scales(registration->GetTransform()->GetNumberOfParameters());
128 for (
unsigned int i = 0; i < scales.Size(); i++)
130 scales[i] = optimizerScales[i];
132 optimizer->SetScales(scales);
135 registration->SetOptimizer(optimizer);
140 registration->Print(std::cout, 0);
141 std::cout << std::endl;
142 std::cout <<
"METRIC" << std::endl;
143 registration->GetMetric()->Print(std::cout, 0);
144 std::cout << std::endl;
145 std::cout <<
"OPTIMIZER" << std::endl;
146 registration->GetOptimizer()->Print(std::cout, 0);
147 std::cout << std::endl;
148 std::cout <<
"TRANSFORM" << std::endl;
149 registration->GetTransform()->Print(std::cout, 0);
152 void Execute(
const itk::Object *,
const itk::EventObject &)
override {
return; }
std::vector< std::string > m_Presets
mitk::RigidRegistrationObserver::Pointer observer
Class to load and save parameter presets for rigid registration.
itk::SmartPointer< Self > Pointer
bool LoadPreset()
Tries to find mitkRigidRegistrationPresets.xml in /mitk/Config and loads all presets stored in this f...
itk::SmartPointer< Self > Pointer
MaskType::Pointer m_BrainMask
DataCollection - Class to facilitate loading/accessing structured data.
RegistrationType * RegistrationPointer
void Execute(itk::Object *object, const itk::EventObject &event) override
itk::SingleValuedNonLinearOptimizer OptimizerType
itk::ImageMaskSpatialObject< 3 > MaskType
RegistrationInterfaceCommand Self
itk::Array< double > getTransformValues(std::string name)
Returns an array including all all transform values belonging to preset name.
itk::MultiResolutionImageRegistrationMethod< itk::Image< float, 3 >, itk::Image< float, 3 > > RegistrationType
OptimizerType * OptimizerPointer
itk::Array< double > getOptimizerValues(std::string name)
Returns an array including all all optimizer values belonging to preset name.
void Execute(const itk::Object *, const itk::EventObject &) override