Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMultiModalRigid_default.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 
17 #include "mapDeploymentDLLHelper.h"
18 #include "mapDiscreteElements.h"
19 #include "mapITKEuler3DMattesMIMultiResRegistrationAlgorithmTemplate.h"
20 #include "mapConfigure.h"
21 
23 
24 namespace mitk
25 {
26  typedef map::core::discrete::Elements<3>::InternalImageType ImageType;
27 
32  class MultiModalRigidDefaultRegistrationAlgorithm :
33  public map::algorithm::boxed::ITKEuler3DMattesMIMultiResRegistrationAlgorithm<ImageType, ImageType, ::map::algorithm::MITK_MultiModal_rigid_defaultUIDPolicy, SealedFixedInterpolatorPolicyMacro< ::itk::LinearInterpolateImageFunction<ImageType, map::core::continuous::ScalarType> >, map::algorithm::itk::NoComponentInitializationPolicy>
34  {
35  public:
36  typedef MultiModalRigidDefaultRegistrationAlgorithm Self;
37 
38  typedef ITKEuler3DMattesMIMultiResRegistrationAlgorithm<ImageType, ImageType, ::map::algorithm::MITK_MultiModal_rigid_defaultUIDPolicy, SealedFixedInterpolatorPolicyMacro< ::itk::LinearInterpolateImageFunction<ImageType, map::core::continuous::ScalarType> >, map::algorithm::itk::NoComponentInitializationPolicy>
39  Superclass;
40 
41  typedef ::itk::SmartPointer<Self> Pointer;
42  typedef ::itk::SmartPointer<const Self> ConstPointer;
43 
44  itkTypeMacro(MultiModalRigidDefaultRegistrationAlgorithm,
45  ITKEuler3DMattesMIMultiResRegistrationAlgorithm);
46  mapNewAlgorithmMacro(Self);
47 
48  protected:
49  MultiModalRigidDefaultRegistrationAlgorithm()
50  {
51  };
52 
53  virtual ~MultiModalRigidDefaultRegistrationAlgorithm()
54  {
55  };
56 
57  void configureAlgorithm()
58  {
59  Superclass::configureAlgorithm();
60 
61  this->setResolutionLevels(3);
62  this->_preInitialize = true;
63  this->_useCenterOfGravity = false;
64 
65  //optimizer
66  ConcreteOptimizerType::ScalesType scales(6);
67  scales[0] = 1.0;
68  scales[1] = 1.0;
69  scales[2] = 1.0;
70  scales[3] = 1.0 / 1000;
71  scales[4] = 1.0 / 1000;
72  scales[5] = 1.0 / 1000;
73 
74  this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetScales(scales);
75  this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetMaximumStepLength(3.00);
76  this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetMinimumStepLength(0.5);
77  this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetNumberOfIterations(200);
78  this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetRelaxationFactor(0.8);
79  this->getConcreteOptimizerControl()->getConcreteOptimizer()->SetGradientMagnitudeTolerance(1e-4);
80 
81  //metric
82  this->getConcreteMetricControl()->getConcreteMetric()->SetNumberOfHistogramBins(30);
83  this->getConcreteMetricControl()->getConcreteMetric()->SetUseAllPixels(true);
84  this->getConcreteMetricControl()->getConcreteMetric()->ReinitializeSeed();
85  this->getConcreteMetricControl()->getConcreteMetric()->UseExplicitPDFDerivativesOn();
86  }
87 
88  void
89  doInterLevelSetup()
90  {
91  Superclass::doInterLevelSetup();
92 
93  if (this->getCurrentLevel() == 0)
94  {
95  OptimizerBaseType::SVNLOptimizerBaseType::ScalesType scales(6);
96  scales[0] = 10.0;
97  scales[1] = 10.0;
98  scales[2] = 10.0;
99  scales[3] = 1.0 / 10000;
100  scales[4] = 1.0 / 10000;
101  scales[5] = 1.0 / 10000;
102  getConcreteOptimizerControl()->getConcreteOptimizer()->SetScales(scales);
103  }
104  else
105  {
106  getConcreteMetricControl()->getConcreteMetric()->SetUseAllPixels(false);
107 
108  OptimizerBaseType::SVNLOptimizerBaseType::ScalesType scales(6);
109  scales[0] = 1.0;
110  scales[1] = 1.0;
111  scales[2] = 1.0;
112  scales[3] = 1.0 / 1000;
113  scales[4] = 1.0 / 1000;
114  scales[5] = 1.0 / 1000;
115 
116  getConcreteOptimizerControl()->getConcreteOptimizer()->SetScales(scales);
117 
118  unsigned int nrOfSmpl = ::itk::Math::Round<unsigned int, double>
119  (this->getMovingImage()->GetLargestPossibleRegion().GetNumberOfPixels() * 0.15);
120 
121  getConcreteMetricControl()->getConcreteMetric()->SetNumberOfSpatialSamples(nrOfSmpl);
122  }
123  };
124 
125  private:
126 
127  MultiModalRigidDefaultRegistrationAlgorithm(const Self& source); //purposely not implemented
128  void operator=(const Self&); //purposely not implemented
129  };
130 
131 }
132 
133 mapDeployAlgorithmMacro(mitk::MultiModalRigidDefaultRegistrationAlgorithm);
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
itkEventMacroDeclaration(FocusChangedEvent, itk::AnyEvent) class MITKCORE_EXPORT TestingRenderingManager typedef RenderingManager Superclass
itk::SmartPointer< const Self > ConstPointer
map::core::discrete::Elements< 3 >::InternalImageType ImageType
mapDeployAlgorithmMacro(mitk::MultiModalRigidDefaultRegistrationAlgorithm)