ANIMA  4.0
animaPyramidalBlockMatchingBridge.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <itkImage.h>
6 #include <itkCommand.h>
7 #include <itkAffineTransform.h>
10 
11 namespace anima
12 {
13 
14 template <unsigned int ImageDimension = 3>
15 class PyramidalBlockMatchingBridge : public itk::ProcessObject
16 {
17 public:
18  typedef itk::Image <double,ImageDimension> InputImageType;
19  typedef typename InputImageType::IOPixelType InputPixelType;
20  typedef typename InputImageType::Pointer InputImagePointer;
21  typedef typename InputImageType::ConstPointer InputImageConstPointer;
22 
23  typedef typename InputImageType::PointType PointType;
24 
25  typedef itk::Image <unsigned char, ImageDimension> MaskImageType;
26  typedef typename MaskImageType::Pointer MaskImagePointer;
29 
32  typedef typename BaseTransformType::Pointer BaseTransformPointer;
33 
34  typedef itk::AffineTransform<typename AgregatorType::ScalarType,ImageDimension> AffineTransformType;
35  typedef typename AffineTransformType::Pointer AffineTransformPointer;
36 
39 
42 
45  typedef itk::ProcessObject Superclass;
46 
47  typedef itk::SmartPointer<Self> Pointer;
48  typedef itk::SmartPointer<const Self> ConstPointer;
49 
50  itkNewMacro(Self)
51  itkTypeMacro(PyramidalBlockMatchingBridge,itk::ProcessObject)
52 
54  {
55  Identity = 0,
58  };
59 
61  {
65  };
66 
67  enum Transform
68  {
73  };
74 
75  enum Metric
76  {
80  };
81 
82  enum Optimizer
83  {
86  };
87 
88  enum Agregator
89  {
93  };
94 
96  {
97  outRigid = 0,
101  };
102 
103  void Update() ITK_OVERRIDE;
104  void Abort();
105  void WriteOutputs();
106 
110  void SetReferenceImage(InputImagePointer referenceImage) {m_ReferenceImage = referenceImage;}
111  void SetFloatingImage(InputImagePointer FloatingImage) {m_FloatingImage = FloatingImage;}
112 
113  InputImagePointer GetOutputImage() {return m_OutputImage;}
114 
118  void SetInitialTransform(AffineTransformPointer initialTransform) {m_InitialTransform=initialTransform;}
119  void SetInitialTransform(std::string initialTransformFile);
120 
121  void SetDirectionTransform(AffineTransformPointer directionTransform) { m_DirectionTransform = directionTransform;}
122  void SetDirectionTransform(std::string directionTransformFile);
123 
124  BaseTransformPointer GetOutputTransform() {return m_OutputTransform;}
125  void SetOutputTransform(BaseTransformPointer outputTransform) {m_OutputTransform=outputTransform;}
126 
127  void SetProgressCallback(itk::CStyleCommand::Pointer callback) {m_progressCallback = callback;}
128 
133  std::string GetResultFile() {return m_resultFile;}
134  void SetResultFile(std::string resultFile) {m_resultFile=resultFile;}
135 
136  std::string GetOutputTransformFile() {return m_outputTransformFile;}
137  void SetOutputTransformFile(std::string outputTransformFile) {m_outputTransformFile=outputTransformFile;}
138 
139  std::string GetOutputNearestRigidTransformFile() {return m_outputNearestRigidTransformFile;}
140  void SetOutputNearestRigidTransformFile(std::string outputNRTransformFile) {m_outputNearestRigidTransformFile = outputNRTransformFile;}
141 
142  std::string GetOutputNearestSimilarityTransformFile() {return m_outputNearestSimilarityTransformFile;}
143  void SetOutputNearestSimilarityTransformFile(std::string outputNearestSimilarityTransformFile) {m_outputNearestSimilarityTransformFile = outputNearestSimilarityTransformFile;}
144 
145  unsigned int GetBlockSize() {return m_BlockSize;}
146  void SetBlockSize(int blockSize) {m_BlockSize=blockSize;}
147 
148  unsigned int GetBlockSpacing() {return m_BlockSpacing;}
149  void SetBlockSpacing(unsigned int blockSpacing) {m_BlockSpacing=blockSpacing;}
150 
151  double GetStDevThreshold() {return m_StDevThreshold;}
152  void SetStDevThreshold(double StDevThreshold) {m_StDevThreshold=StDevThreshold;}
153 
154  SymmetryType GetSymmetryType() {return m_SymmetryType;}
155  void SetSymmetryType(SymmetryType sym) {m_SymmetryType=sym;}
156 
157  Transform GetTransform() {return m_Transform;}
158  void SetTransform(Transform transform) {m_Transform=transform;}
159 
160  unsigned int GetAffineDirection() {return m_AffineDirection;}
161  void SetAffineDirection(unsigned int val) {m_AffineDirection = val;}
162 
163  Metric GetMetric() {return m_Metric;}
164  void SetMetric(Metric metric) {m_Metric=metric;}
165 
166  Optimizer GetOptimizer() {return m_Optimizer;}
167  void SetOptimizer(Optimizer optimizer) {m_Optimizer=optimizer;}
168 
169  unsigned int GetMaximumIterations() {return m_MaximumIterations;}
170  void SetMaximumIterations(unsigned int MaximumIterations) {m_MaximumIterations=MaximumIterations;}
171 
172  double GetMinimalTransformError() {return m_MinimalTransformError;}
173  void SetMinimalTransformError(double MinimalTransformError) {m_MinimalTransformError=MinimalTransformError;}
174 
175  unsigned int GetOptimizerMaximumIterations() {return m_OptimizerMaximumIterations;}
176  void SetOptimizerMaximumIterations(unsigned int OptimizerMaximumIterations) {m_OptimizerMaximumIterations=OptimizerMaximumIterations;}
177 
178  double GetSearchRadius() {return m_SearchRadius;}
179  void SetSearchRadius(double SearchRadius) {m_SearchRadius=SearchRadius;}
180 
181  double GetSearchAngleRadius() {return m_SearchAngleRadius;}
182  void SetSearchAngleRadius(double SearchAngleRadius) {m_SearchAngleRadius=SearchAngleRadius;}
183 
184  double GetSearchScaleRadius() {return m_SearchScaleRadius;}
185  void SetSearchScaleRadius(double SearchScaleRadius) {m_SearchScaleRadius=SearchScaleRadius;}
186 
187  double GetFinalRadius() {return m_FinalRadius;}
188  void SetFinalRadius(double FinalRadius) {m_FinalRadius=FinalRadius;}
189 
190  double GetStepSize() {return m_StepSize;}
191  void SetStepSize(double StepSize) {m_StepSize=StepSize;}
192 
193  double GetTranslateUpperBound() {return m_TranslateUpperBound;}
194  void SetTranslateUpperBound(double TranslateUpperBound) {m_TranslateUpperBound=TranslateUpperBound;}
195 
196  double GetAngleUpperBound() {return m_AngleUpperBound;}
197  void SetAngleUpperBound(double AngleUpperBound) {m_AngleUpperBound=AngleUpperBound;}
198 
199  double GetScaleUpperBound() {return m_ScaleUpperBound;}
200  void SetScaleUpperBound(double ScaleUpperBound) {m_ScaleUpperBound=ScaleUpperBound;}
201 
202  Agregator GetAgregator() {return m_Agregator;}
203  void SetAgregator(Agregator agregator) {m_Agregator=agregator;}
204 
205  OutputTransform GetOutputTransformType() {return m_OutputTransformType;}
206  void SetOutputTransformType(OutputTransform outputTransform) {m_OutputTransformType=outputTransform;}
207 
208  double GetAgregThreshold() {return m_AgregThreshold;}
209  void SetAgregThreshold(double AgregThreshold) {m_AgregThreshold=AgregThreshold;}
210 
211  double GetSeStoppingThreshold() {return m_SeStoppingThreshold;}
212  void SetSeStoppingThreshold(double SeStoppingThreshold) {m_SeStoppingThreshold=SeStoppingThreshold;}
213 
214  unsigned int GetNumberOfPyramidLevels() {return m_NumberOfPyramidLevels;}
215  void SetNumberOfPyramidLevels(unsigned int NumberOfPyramidLevels) {m_NumberOfPyramidLevels=NumberOfPyramidLevels;}
216 
217  unsigned int GetLastPyramidLevel() {return m_LastPyramidLevel;}
218  void SetLastPyramidLevel(unsigned int LastPyramidLevel) {m_LastPyramidLevel=LastPyramidLevel;}
219 
220  double GetPercentageKept() {return m_PercentageKept;}
221  void SetPercentageKept(double PercentageKept) {m_PercentageKept=PercentageKept;}
222 
223  InitializationType GetTransformInitializationType() {return m_TransformInitializationType;}
224  void SetTransformInitializationType (InitializationType transformInitializationType) {m_TransformInitializationType = transformInitializationType;}
225 
226  void SetBlockGenerationMask(MaskImageType *mask) {m_BlockGenerationMask = mask;}
227 
228  void SetVerbose(bool value) {m_Verbose = value;}
229 
230 protected:
233 
234  void SetupPyramids();
235  void EmitProgress(int prog);
236 
237  static void ManageProgress( itk::Object* caller, const itk::EventObject& event, void* clientData );
238 
239 private:
240  ITK_DISALLOW_COPY_AND_ASSIGN(PyramidalBlockMatchingBridge);
241 
242  AffineTransformPointer m_InitialTransform;
243  AffineTransformPointer m_DirectionTransform;
244  BaseTransformPointer m_OutputTransform;
245  InputImagePointer m_OutputImage;
246 
247  MaskImagePointer m_BlockGenerationMask;
248 
249  InputImagePointer m_ReferenceImage, m_FloatingImage;
250  PyramidPointer m_ReferencePyramid, m_FloatingPyramid;
251  MaskPyramidPointer m_BlockGenerationPyramid;
252 
253  std::string m_outputTransformFile;
254  std::string m_resultFile;
255 
256  // Nearest rigid and anisotropic similarity specific variables
257  itk::Point<double, ImageDimension> m_EstimationBarycenter;
258  std::string m_outputNearestRigidTransformFile;
259  std::string m_outputNearestSimilarityTransformFile;
260 
261  unsigned int m_BlockSize;
262  unsigned int m_BlockSpacing;
263  double m_StDevThreshold;
264 
265  SymmetryType m_SymmetryType;
266  Transform m_Transform;
267  unsigned int m_AffineDirection;
268  Metric m_Metric;
269  Optimizer m_Optimizer;
270 
271  double m_ReferenceMinimalValue, m_FloatingMinimalValue;
272  unsigned int m_MaximumIterations;
273  double m_MinimalTransformError;
274  unsigned int m_OptimizerMaximumIterations;
275  double m_SearchRadius;
276  double m_SearchAngleRadius;
277  double m_SearchScaleRadius;
278  double m_FinalRadius;
279  double m_StepSize;
280  double m_TranslateUpperBound;
281  double m_AngleUpperBound;
282  double m_ScaleUpperBound;
283  Agregator m_Agregator;
284  OutputTransform m_OutputTransformType;
285  double m_AgregThreshold;
286  double m_SeStoppingThreshold;
287  unsigned int m_NumberOfPyramidLevels;
288  unsigned int m_LastPyramidLevel;
289  double m_PercentageKept;
290  InitializationType m_TransformInitializationType;
291 
292  bool m_Abort;
293  bool m_Verbose;
294 
295  itk::ProgressReporter *m_progressReporter;
296  itk::CStyleCommand::Pointer m_progressCallback;
297  itk::CStyleCommand::Pointer m_callback;
298 
299  BaseBlockMatchRegistrationPointer m_bmreg;
300 };
301 
302 } // end of namespace anima
303 
void SetDirectionTransform(AffineTransformPointer directionTransform)
void SetLastPyramidLevel(unsigned int LastPyramidLevel)
void SetTranslateUpperBound(double TranslateUpperBound)
void SetOutputTransform(BaseTransformPointer outputTransform)
anima::PyramidImageFilter< MaskImageType, MaskImageType > MaskPyramidType
anima::BaseBMRegistrationMethod< InputImageType > BaseBlockMatchRegistrationType
void SetOutputNearestRigidTransformFile(std::string outputNRTransformFile)
Computes a pyramid of images using the provided resampler to perform resampling.
anima::BaseTransformAgregator< ImageDimension > AgregatorType
void SetOutputTransformType(OutputTransform outputTransform)
static void ManageProgress(itk::Object *caller, const itk::EventObject &event, void *clientData)
void SetSeStoppingThreshold(double SeStoppingThreshold)
AgregatorType::BaseOutputTransformType BaseTransformType
itk::AffineTransform< typename AgregatorType::ScalarType, ImageDimension > AffineTransformType
itk::Transform< ScalarType, NDimensions, NDimensions > BaseOutputTransformType
void SetReferenceImage(InputImagePointer referenceImage)
void SetFloatingImage(InputImagePointer FloatingImage)
void SetMinimalTransformError(double MinimalTransformError)
void SetOptimizerMaximumIterations(unsigned int OptimizerMaximumIterations)
BaseBlockMatchRegistrationType::Pointer BaseBlockMatchRegistrationPointer
void SetNumberOfPyramidLevels(unsigned int NumberOfPyramidLevels)
void SetOutputTransformFile(std::string outputTransformFile)
void SetMaximumIterations(unsigned int MaximumIterations)
void SetTransformInitializationType(InitializationType transformInitializationType)
void SetProgressCallback(itk::CStyleCommand::Pointer callback)
itk::Image< unsigned char, ImageDimension > MaskImageType
itk::SmartPointer< Self > Pointer
itk::Image< double, ImageDimension > InputImageType
anima::PyramidImageFilter< InputImageType, InputImageType > PyramidType
void SetInitialTransform(AffineTransformPointer initialTransform)
void SetOutputNearestSimilarityTransformFile(std::string outputNearestSimilarityTransformFile)