selxMonolithicElastix.h 3.99 KB
Newer Older
Floris Berendsen's avatar
Floris Berendsen committed
1
2
/*=========================================================================
 *
3
 *  Copyright Leiden University Medical Center, Erasmus University Medical
Floris Berendsen's avatar
Floris Berendsen committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *  Center and contributors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/

20
21
#ifndef selxMonolithicElastixComponent_h
#define selxMonolithicElastixComponent_h
22

23
#include "selxSuperElastixComponent.h"
24
25
#include "selxElastixInterfaces.h"
#include "selxSinksAndSourcesInterfaces.h"
26
27
#include "itkImageSource.h"

28
29
30
#include "elxElastixFilter.h"
#include "elxParameterObject.h"
#include "elxTransformixFilter.h"
31
32

#include <string.h>
33
#include "selxMacro.h"
34
35
namespace selx
{
36
37
38
39
40
41
42
43
template< int Dimensionality, class TPixel >
class MonolithicElastixComponent :
  public SuperElastixComponent<
  Accepting<
  itkImageFixedInterface< Dimensionality, TPixel >,
  itkImageMovingInterface< Dimensionality, TPixel >
  >,
  Providing<
44
  elastixTransformParameterObjectInterface< itk::Image< TPixel, Dimensionality >, itk::Image< TPixel, Dimensionality > >,
45
46
47
48
49
50
  itkImageInterface< Dimensionality, TPixel >,
  RunRegistrationInterface
  >
  >
{
public:
51

52
  selxNewMacro( MonolithicElastixComponent, ComponentBase );
53

54
  //itkStaticConstMacro(Dimensionality, unsigned int, Dimensionality);
55

56
57
  MonolithicElastixComponent();
  virtual ~MonolithicElastixComponent();
58

59
60
  typedef typename ComponentBase::CriterionType CriterionType;
  typedef TPixel                                PixelType;
61

62
63
  // the in and output image type of the component are chosen to be the same
  typedef itk::Image< PixelType, Dimensionality > ConnectionImageType;
64

65
66
67
  // fixed and moving image types are all the same, these aliases can be used to be explicit.
  typedef itk::Image< PixelType, Dimensionality > FixedImageType;
  typedef itk::Image< PixelType, Dimensionality > MovingImageType;
68

69
70
71
72
73
74
75
  typedef typename ConnectionImageType::Pointer ItkImagePointer;

  typedef elastix::ElastixFilter< FixedImageType, MovingImageType > ElastixFilterType;
  typedef elastix::ParameterObject                                  elxParameterObjectType;
  typedef elxParameterObjectType::Pointer                           elxParameterObjectPointer;

  typedef typename elastixTransformParameterObjectInterface< itk::Image< TPixel, Dimensionality >,
76
    itk::Image< TPixel, Dimensionality > >::elastixTransformParameterObject elastixTransformParameterObject;
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

  // Accepting Interfaces:
  virtual int Set( itkImageFixedInterface< Dimensionality, TPixel > * ) override;

  virtual int Set( itkImageMovingInterface< Dimensionality, TPixel > * ) override;

  // Providing Interfaces:
  virtual elastixTransformParameterObject * GetTransformParameterObject() override;

  virtual ItkImagePointer GetItkImage() override;

  virtual void RunRegistration() override;

  virtual bool MeetsCriterion( const CriterionType & criterion ) override;

  static const char * GetDescription() { return "MonolithicElastix Component"; }

private:

  typename ElastixFilterType::Pointer m_elastixFilter;

protected:

100
  // return the class name and the template arguments to uniquely identify this component.
Floris Berendsen's avatar
Floris Berendsen committed
101
  static inline const std::map< std::string, std::string > TemplateProperties()
102
  {
Floris Berendsen's avatar
Floris Berendsen committed
103
    return { { keys::NameOfClass, "MonolithicElastixComponent" }, { keys::PixelType, PodString< TPixel >::Get() }, { keys::Dimensionality, std::to_string( Dimensionality ) } };
104
  }
105
};
106
107
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
108
#include "selxMonolithicElastix.hxx"
109
#endif
110
#endif // #define selxMonolithicElastix_h