Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkRegularStepGradientDescentOptimizerView.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 #include "mitkImageAccessByItk.h"
19 #include <itkRegularStepGradientDescentOptimizer.h>
20 
22  Qt::WindowFlags f)
23  : QmitkRigidRegistrationOptimizerGUIBase(parent, f), m_NumberTransformParameters(16)
24 {
25 }
26 
28 {
29 }
30 
32 {
34 }
35 
37 {
39  OptimizerPointer->SetMaximize(m_Controls.m_Maximize->isChecked());
40  OptimizerPointer->SetGradientMagnitudeTolerance(
41  m_Controls.m_GradientMagnitudeToleranceRegularStepGradientDescent->text().toFloat());
42  OptimizerPointer->SetMinimumStepLength(m_Controls.m_MinimumStepLengthRegularStepGradientDescent->text().toFloat());
43  OptimizerPointer->SetMaximumStepLength(m_Controls.m_MaximumStepLengthRegularStepGradientDescent->text().toFloat());
44  OptimizerPointer->SetRelaxationFactor(m_Controls.m_RelaxationFactorRegularStepGradientDescent->text().toFloat());
45  OptimizerPointer->SetNumberOfIterations(m_Controls.m_IterationsRegularStepGradientDescent->text().toInt());
46  return OptimizerPointer.GetPointer();
47 }
48 
50 {
51  itk::Array<double> optimizerValues;
52  optimizerValues.SetSize(6);
53  optimizerValues.fill(0);
54  optimizerValues[0] = m_Controls.m_Maximize->isChecked();
55  optimizerValues[1] = m_Controls.m_GradientMagnitudeToleranceRegularStepGradientDescent->text().toFloat();
56  optimizerValues[2] = m_Controls.m_MinimumStepLengthRegularStepGradientDescent->text().toFloat();
57  optimizerValues[3] = m_Controls.m_MaximumStepLengthRegularStepGradientDescent->text().toFloat();
58  optimizerValues[4] = m_Controls.m_RelaxationFactorRegularStepGradientDescent->text().toFloat();
59  optimizerValues[5] = m_Controls.m_IterationsRegularStepGradientDescent->text().toInt();
60  return optimizerValues;
61 }
62 
64 {
65  m_Controls.m_Maximize->setChecked(optimizerValues[0]);
66  m_Controls.m_GradientMagnitudeToleranceRegularStepGradientDescent->setText(QString::number(optimizerValues[1]));
67  m_Controls.m_MinimumStepLengthRegularStepGradientDescent->setText(QString::number(optimizerValues[2]));
68  m_Controls.m_MaximumStepLengthRegularStepGradientDescent->setText(QString::number(optimizerValues[3]));
69  m_Controls.m_RelaxationFactorRegularStepGradientDescent->setText(QString::number(optimizerValues[4]));
70  m_Controls.m_IterationsRegularStepGradientDescent->setText(QString::number(optimizerValues[5]));
71 }
72 
74 {
75  m_NumberTransformParameters = transformParameters;
76 }
77 
79 {
80  return "RegularStepGradientDescent";
81 }
82 
84 {
85  m_Controls.setupUi(parent);
86  QValidator *validatorLineEditInput = new QIntValidator(0, 20000000, this);
87  m_Controls.m_IterationsRegularStepGradientDescent->setValidator(validatorLineEditInput);
88  QValidator *validatorLineEditInputFloat = new QDoubleValidator(0, 20000000, 8, this);
89  m_Controls.m_GradientMagnitudeToleranceRegularStepGradientDescent->setValidator(validatorLineEditInputFloat);
90  m_Controls.m_MinimumStepLengthRegularStepGradientDescent->setValidator(validatorLineEditInputFloat);
91  m_Controls.m_MaximumStepLengthRegularStepGradientDescent->setValidator(validatorLineEditInputFloat);
92  QValidator *validatorLineEditInputFloat0to1 = new QDoubleValidator(0.000001, 0.999999, 8, this);
93  m_Controls.m_RelaxationFactorRegularStepGradientDescent->setValidator(validatorLineEditInputFloat0to1);
94 }
QmitkRegularStepGradientDescentOptimizerView(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
itk::SmartPointer< Self > Pointer
Ui::QmitkRegularStepGradientDescentOptimizerControls m_Controls
virtual mitk::OptimizerParameters::OptimizerType GetOptimizerType() override
virtual void SetOptimizerParameters(itk::Array< double > metricValues) override
virtual void SetNumberOfTransformParameters(int transformParameters) override
OptimizerType
Unique integer value for every optimizer.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.