selxElastixComponent.h 4.13 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
22
#ifndef selxElastixComponent_h
#define selxElastixComponent_h

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

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

#include <string.h>
Floris Berendsen's avatar
Floris Berendsen committed
33

34
35
namespace selx
{
36
37
38
template< int Dimensionality, class TPixel >
class ElastixComponent :
  public SuperElastixComponent<
39
40
41
42
43
44
  Accepting<
  itkImageFixedInterface< Dimensionality, TPixel >,
  itkImageMovingInterface< Dimensionality, TPixel >
  >,
  Providing<
  itkImageInterface< Dimensionality, TPixel >,
45
  UpdateInterface
46
  >
47
48
49
  >
{
public:
50

51
  /** Standard ITK typedefs. */
52
53
54
  typedef ElastixComponent<
    Dimensionality, TPixel
    >                                     Self;
Kasper Marstal's avatar
Kasper Marstal committed
55
56
  typedef SuperElastixComponent<
    Accepting<
57
58
    itkImageFixedInterface< Dimensionality, TPixel >,
    itkImageMovingInterface< Dimensionality, TPixel >
Kasper Marstal's avatar
Kasper Marstal committed
59
60
    >,
    Providing<
61
    itkImageInterface< Dimensionality, TPixel >,
62
    UpdateInterface
Kasper Marstal's avatar
Kasper Marstal committed
63
    >
64
    >                                   Superclass;
Floris Berendsen's avatar
Floris Berendsen committed
65
66
  typedef std::shared_ptr< Self >       Pointer;
  typedef std::shared_ptr< const Self > ConstPointer;
67

68
  ElastixComponent( const std::string & name, LoggerImpl & logger );
69
  virtual ~ElastixComponent();
70

71
72
  typedef typename ComponentBase::CriterionType CriterionType;
  typedef TPixel                                PixelType;
73

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

77
78
79
  // 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;
80

81
82
83
84
85
86
87
88
  typedef typename ConnectionImageType::Pointer ItkImagePointer;

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

  typedef elastix::TransformixFilter< FixedImageType > TransformixFilterType;

89
  virtual int Accept( typename itkImageFixedInterface< Dimensionality, TPixel >::Pointer ) override;
90

91
  virtual int Accept( typename itkImageMovingInterface< Dimensionality, TPixel >::Pointer ) override;
92
93
94

  virtual ItkImagePointer GetItkImage() override;

95
  virtual void Update() override;
96
97
98
99
100
101
102
103
104
105
106
107
108
109

  virtual bool MeetsCriterion( const CriterionType & criterion ) override;

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

private:

  typename ElastixFilterType::Pointer m_elastixFilter;
  typename TransformixFilterType::Pointer m_transformixFilter;
  //selxParameterObjectPointer m_ParameterObject;

  ItkImagePointer m_OutputImage;

protected:
110

111
  // return the class name and the template arguments to uniquely identify this component.
Floris Berendsen's avatar
Floris Berendsen committed
112
  static inline const std::map< std::string, std::string > TemplateProperties()
113
  {
Floris Berendsen's avatar
Floris Berendsen committed
114
    return { { keys::NameOfClass, "ElastixComponent" }, { keys::PixelType, PodString< TPixel >::Get() }, { keys::Dimensionality, std::to_string( Dimensionality ) } };
115
  }
116
};
117
118
119
120
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxElastixComponent.hxx"
#endif
121
#endif // #define GDOptimizer3rdPartyComponent_h