selxElastixComponent.h 3.74 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
26
#include "itkImageSource.h"

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

#include <string.h>
32
#include "selxMacro.h"
Kasper Marstal's avatar
Kasper Marstal committed
33
 
34
35
namespace selx
{
36
37
38
39
40
41
42
43
44
45
46
47
48
49
template< int Dimensionality, class TPixel >
class ElastixComponent :
  public SuperElastixComponent<
  Accepting<
  itkImageFixedInterface< Dimensionality, TPixel >,
  itkImageMovingInterface< Dimensionality, TPixel >
  >,
  Providing<
  itkImageInterface< Dimensionality, TPixel >,
  RunRegistrationInterface
  >
  >
{
public:
50

51
  selxNewMacro( ElastixComponent, ComponentBase );
52

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

55
56
  ElastixComponent();
  virtual ~ElastixComponent();
57

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

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

64
65
66
  // 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;
67

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  typedef typename ConnectionImageType::Pointer ItkImagePointer;

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

  typedef elastix::TransformixFilter< FixedImageType > TransformixFilterType;

  typedef itk::ResampleImageFilter< MovingImageType, ConnectionImageType > ResampleFilterType;

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

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

  virtual ItkImagePointer GetItkImage() override;

  virtual void RunRegistration() override;

  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:
99

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, "ElastixComponent" }, { keys::PixelType, PodString< TPixel >::Get() }, { keys::Dimensionality, std::to_string( Dimensionality ) } };
104
  }
105
};
106
107
108
109
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxElastixComponent.hxx"
#endif
110
#endif // #define GDOptimizer3rdPartyComponent_h