selxItkANTSNeighborhoodCorrelationImageToImageMetricv4.h 5.84 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 selxItkANTSNeighborhoodCorrelationImageToImageMetricv4Component_h
#define selxItkANTSNeighborhoodCorrelationImageToImageMetricv4Component_h

23
24
#include "selxComponentBase.h"
#include "selxInterfaces.h"
25
26
#include "itkANTSNeighborhoodCorrelationImageToImageMetricv4.h"
#include <string.h>
27
#include "selxMacro.h"
28
29
namespace selx
{
30
31
32
33
template< int Dimensionality, class TPixel >
class ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component :
  public SuperElastixComponent<
  Accepting< >,
34
  Providing< itkMetricv4Interface< Dimensionality, TPixel > >
35
36
37
  >
{
public:
38

39
  selxNewMacro( ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component, ComponentBase );
40

41
  //itkStaticConstMacro(Dimensionality, unsigned int, Dimensionality);
42

43
44
  ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component();
  virtual ~ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component();
45

46
  typedef TPixel PixelType;
47

48
49
50
  // 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;
51

52
53
54
55
  typedef typename itk::ImageToImageMetricv4< FixedImageType, MovingImageType > ImageToImageMetricv4Type;
  //typedef typename ItkMetricv4Interface<Dimensionality, TPixel>::ImageToImageMetricv4Type ImageToImageMetricv4Type;
  //typedef ItkMetricv4Interface<Dimensionality, TPixel>::ImageToImageMetricv4Type ItkMetricv4Pointer
  typedef typename ImageToImageMetricv4Type::Pointer ItkMetricv4Pointer;
56

57
58
59
60
61
62
63
64
65
66
  typedef typename itk::ANTSNeighborhoodCorrelationImageToImageMetricv4< FixedImageType, MovingImageType > TheItkFilterType;

  virtual ItkMetricv4Pointer GetItkMetricv4() override;

  virtual bool MeetsCriterion( const ComponentBase::CriterionType & criterion ) override;

  //static const char * GetName() { return "ItkANTSNeighborhoodCorrelationImageToImageMetricv4"; } ;
  static const char * GetDescription() { return "ItkANTSNeighborhoodCorrelationImageToImageMetricv4 Component"; }

private:
67

68
69
70
71
72
73
74
75
  typename TheItkFilterType::Pointer m_theItkFilter;

protected:

  /* The following struct returns the string name of computation type */
  /* default implementation */

  static inline const std::string GetTypeNameString()
76
  {
77
78
79
    itkGenericExceptionMacro( << "Unknown ScalarType" << typeid( TPixel ).name() );
    // TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
    // We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
80
  }
81
82
83


  static inline const std::string GetPixelTypeNameString()
84
  {
85
86
87
    itkGenericExceptionMacro( << "Unknown PixelType" << typeid( TPixel ).name() );
    // TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
    // We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
88
  }
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
};

// unfortunately partial specialization of member functions is not allowed, without partially specializing the entire class.

/*
template <int Dimensionality>
class ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component < Dimensionality, double >
{
  static inline const std::string GetPixelTypeNameString();
};

template <int Dimensionality>
inline const std::string
  ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component<Dimensionality, double>
  ::GetPixelTypeNameString()
{
  return std::string("double");
}
*/

template< >
inline const std::string
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< 2, float >
::GetPixelTypeNameString()
{
  return std::string( "float" );
}


template< >
inline const std::string
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< 2, double >
::GetPixelTypeNameString()
{
  return std::string( "double" );
}


template< >
inline const std::string
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< 3, float >
::GetPixelTypeNameString()
{
  return std::string( "float" );
}


template< >
inline const std::string
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< 3, double >
::GetPixelTypeNameString()
{
  return std::string( "double" );
}


template< >
inline const std::string
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< 2, float >
::GetTypeNameString()
{
  return std::string( "2_float" );
}


template< >
inline const std::string
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< 2, double >
::GetTypeNameString()
{
  return std::string( "2_double" );
}


template< >
inline const std::string
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< 3, float >
::GetTypeNameString()
{
  return std::string( "3_float" );
}


template< >
inline const std::string
ItkANTSNeighborhoodCorrelationImageToImageMetricv4Component< 3, double >
::GetTypeNameString()
{
  return std::string( "3_double" );
}
179
180
} //end namespace selx
#ifndef ITK_MANUAL_INSTANTIATION
181
#include "selxItkANTSNeighborhoodCorrelationImageToImageMetricv4.hxx"
182
#endif
183
#endif // #define GDOptimizer3rdPartyComponent_h