go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkPCAMetric.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkPCAMetric_h
19 #define __itkPCAMetric_h
20 
22 
23 #include "itkSmoothingRecursiveGaussianImageFilter.h"
25 #include "itkNearestNeighborInterpolateImageFunction.h"
26 #include "itkExtractImageFilter.h"
27 
28 using namespace std;
29 
30 namespace itk
31 {
32 template< class TFixedImage, class TMovingImage >
33 class PCAMetric :
34  public AdvancedImageToImageMetric< TFixedImage, TMovingImage >
35 {
36 public:
37 
39  typedef PCAMetric Self;
41  TFixedImage, TMovingImage > Superclass;
42  typedef SmartPointer< Self > Pointer;
43  typedef SmartPointer< const Self > ConstPointer;
44 
45  typedef typename Superclass::FixedImageRegionType FixedImageRegionType;
46  typedef typename FixedImageRegionType::SizeType FixedImageSizeType;
47 
49  itkNewMacro( Self );
50 
53 
55  itkSetMacro( SampleLastDimensionRandomly, bool );
56  itkSetMacro( NumSamplesLastDimension, unsigned int );
57  itkSetMacro( NumAdditionalSamplesFixed, unsigned int );
58  itkSetMacro( ReducedDimensionIndex, unsigned int );
59  itkSetMacro( SubtractMean, bool );
60  itkSetMacro( GridSize, FixedImageSizeType );
61  itkSetMacro( TransformIsStackTransform, bool );
62  itkSetMacro( NumEigenValues, unsigned int );
63  itkSetMacro( UseDerivativeOfMean, bool );
64  itkSetMacro( DeNoise, bool );
65  itkSetMacro( VarNoise, double );
66 
68  itkGetConstMacro( SampleLastDimensionRandomly, bool );
69  itkGetConstMacro( NumSamplesLastDimension, int );
70 
72  typedef typename
73  Superclass::CoordinateRepresentationType CoordinateRepresentationType;
74  typedef typename Superclass::MovingImageType MovingImageType;
75  typedef typename Superclass::MovingImagePixelType MovingImagePixelType;
76  typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
77  typedef typename Superclass::FixedImageType FixedImageType;
78  typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
79  typedef typename Superclass::TransformType TransformType;
80  typedef typename Superclass::TransformPointer TransformPointer;
81  typedef typename Superclass::InputPointType InputPointType;
82  typedef typename Superclass::OutputPointType OutputPointType;
83  typedef typename Superclass::TransformParametersType TransformParametersType;
84  typedef typename Superclass::TransformJacobianType TransformJacobianType;
85  typedef typename Superclass::InterpolatorType InterpolatorType;
86  typedef typename Superclass::InterpolatorPointer InterpolatorPointer;
87  typedef typename Superclass::RealType RealType;
88  typedef typename Superclass::GradientPixelType GradientPixelType;
89  typedef typename Superclass::GradientImageType GradientImageType;
90  typedef typename Superclass::GradientImagePointer GradientImagePointer;
91  typedef typename Superclass::GradientImageFilterType GradientImageFilterType;
92  typedef typename Superclass::GradientImageFilterPointer GradientImageFilterPointer;
93  typedef typename Superclass::FixedImageMaskType FixedImageMaskType;
94  typedef typename Superclass::FixedImageMaskPointer FixedImageMaskPointer;
95  typedef typename Superclass::MovingImageMaskType MovingImageMaskType;
96  typedef typename Superclass::MovingImageMaskPointer MovingImageMaskPointer;
97  typedef typename Superclass::MeasureType MeasureType;
98  typedef typename Superclass::DerivativeType DerivativeType;
99  typedef typename Superclass::ParametersType ParametersType;
100  typedef typename Superclass::FixedImagePixelType FixedImagePixelType;
101  typedef typename Superclass::MovingImageRegionType MovingImageRegionType;
102  typedef typename Superclass::ImageSamplerType ImageSamplerType;
103  typedef typename Superclass::ImageSamplerPointer ImageSamplerPointer;
104  typedef typename Superclass::ImageSampleContainerType ImageSampleContainerType;
105  typedef typename
106  Superclass::ImageSampleContainerPointer ImageSampleContainerPointer;
107  typedef typename Superclass::FixedImageLimiterType FixedImageLimiterType;
108  typedef typename Superclass::MovingImageLimiterType MovingImageLimiterType;
109  typedef typename
110  Superclass::FixedImageLimiterOutputType FixedImageLimiterOutputType;
111  typedef typename
112  Superclass::MovingImageLimiterOutputType MovingImageLimiterOutputType;
113  typedef typename
114  Superclass::MovingImageDerivativeScalesType MovingImageDerivativeScalesType;
115 
117  itkStaticConstMacro( FixedImageDimension, unsigned int,
118  FixedImageType::ImageDimension );
119 
121  itkStaticConstMacro( MovingImageDimension, unsigned int,
122  MovingImageType::ImageDimension );
123 
125  virtual MeasureType GetValue( const TransformParametersType & parameters ) const;
126 
128  virtual void GetDerivative( const TransformParametersType & parameters,
129  DerivativeType & derivative ) const;
130 
132  virtual void GetValueAndDerivative( const TransformParametersType & parameters,
133  MeasureType & Value, DerivativeType & Derivative ) const;
134 
139  virtual void Initialize( void );
140 
141 protected:
142 
144  virtual ~PCAMetric() {}
145  void PrintSelf( std::ostream & os, Indent indent ) const;
146 
150  typedef typename Superclass::FixedImageIndexType FixedImageIndexType;
151  typedef typename Superclass::FixedImageIndexValueType FixedImageIndexValueType;
152  typedef typename Superclass::MovingImageIndexType MovingImageIndexType;
153  typedef typename Superclass::FixedImagePointType FixedImagePointType;
154  typedef typename itk::ContinuousIndex< CoordinateRepresentationType, FixedImageDimension >
156  typedef typename Superclass::MovingImagePointType MovingImagePointType;
157  typedef typename Superclass::MovingImageContinuousIndexType MovingImageContinuousIndexType;
158  typedef typename Superclass::BSplineInterpolatorType BSplineInterpolatorType;
159  typedef typename Superclass::CentralDifferenceGradientFilterType CentralDifferenceGradientFilterType;
160  typedef typename Superclass::MovingImageDerivativeType MovingImageDerivativeType;
161  typedef typename Superclass::NonZeroJacobianIndicesType NonZeroJacobianIndicesType;
162 
167  const TransformJacobianType & jacobian,
168  const MovingImageDerivativeType & movingImageDerivative,
169  DerivativeType & imageJacobian ) const;
170 
180  mutable int m_NumberOfSamples;
181 
182 private:
183 
184  PCAMetric( const Self & ); // purposely not implemented
185  void operator=( const Self & ); // purposely not implemented
186 
188  void SampleRandom( const int n, const int m, std::vector< int > & numbers ) const;
189 
195 
196  bool m_DeNoise;
197 
198  double m_VarNoise;
199 
202 
205 
208 
210  unsigned int m_NumEigenValues;
211 
213 
214 };
215 
216 } // end namespace itk
217 
218 #ifndef ITK_MANUAL_INSTANTIATION
219 #include "itkPCAMetric.hxx"
220 #endif
221 
222 #endif // end #ifndef __itkPCAMetric_h
An extension of the ITK ImageToImageMetric. It is the intended base class for all elastix metrics.
Superclass::TransformParametersType TransformParametersType
Superclass::TransformJacobianType TransformJacobianType
BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
Superclass::TransformPointer TransformPointer
Definition: itkPCAMetric.h:80
Superclass::FixedImageLimiterType FixedImageLimiterType
Definition: itkPCAMetric.h:107
unsigned int m_NumSamplesLastDimension
Definition: itkPCAMetric.h:192
Superclass::MovingImagePointType MovingImagePointType
Definition: itkPCAMetric.h:156
unsigned int m_NumEigenValues
Definition: itkPCAMetric.h:210
Superclass::InterpolatorPointer InterpolatorPointer
Definition: itkPCAMetric.h:86
vnl_vector< double > m_fourthEigenVector
Definition: itkPCAMetric.h:174
Superclass::DerivativeType DerivativeType
Definition: itkPCAMetric.h:98
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
vnl_vector< double > m_thirdEigenVector
Definition: itkPCAMetric.h:173
Superclass::MovingImageLimiterOutputType MovingImageLimiterOutputType
Definition: itkPCAMetric.h:112
void PrintSelf(std::ostream &os, Indent indent) const
Superclass::ImageSamplerType ImageSamplerType
Definition: itkPCAMetric.h:102
virtual void Initialize(void)
Superclass::MovingImageContinuousIndexType MovingImageContinuousIndexType
Definition: itkPCAMetric.h:157
Superclass::GradientImagePointer GradientImagePointer
Definition: itkPCAMetric.h:90
Superclass::GradientImageFilterPointer GradientImageFilterPointer
Definition: itkPCAMetric.h:92
Superclass::ImageSamplerPointer ImageSamplerPointer
Definition: itkPCAMetric.h:103
bool m_SampleLastDimensionRandomly
Definition: itkPCAMetric.h:191
itk::ContinuousIndex< CoordinateRepresentationType, FixedImageDimension > FixedImageContinuousIndexType
Definition: itkPCAMetric.h:155
Superclass::MovingImageType MovingImageType
Definition: itkPCAMetric.h:74
vnl_vector< double > m_secondEigenVector
Definition: itkPCAMetric.h:172
Superclass::MovingImagePixelType MovingImagePixelType
Definition: itkPCAMetric.h:75
vnl_vector< double > m_normdCdmu
Definition: itkPCAMetric.h:179
Superclass::FixedImageConstPointer FixedImageConstPointer
Definition: itkPCAMetric.h:78
vnl_vector< double > m_sixthEigenVector
Definition: itkPCAMetric.h:176
Superclass::CentralDifferenceGradientFilterType CentralDifferenceGradientFilterType
Definition: itkPCAMetric.h:159
FixedImageSizeType m_GridSize
Definition: itkPCAMetric.h:204
Superclass::MovingImageIndexType MovingImageIndexType
Definition: itkPCAMetric.h:152
Superclass::OutputPointType OutputPointType
Definition: itkPCAMetric.h:82
Superclass::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Definition: itkPCAMetric.h:161
Superclass::MeasureType MeasureType
Definition: itkPCAMetric.h:97
void EvaluateTransformJacobianInnerProduct(const TransformJacobianType &jacobian, const MovingImageDerivativeType &movingImageDerivative, DerivativeType &imageJacobian) const
Superclass::InputPointType InputPointType
Definition: itkPCAMetric.h:81
vnl_vector< double > m_firstEigenVector
Definition: itkPCAMetric.h:171
virtual MeasureType GetValue(const TransformParametersType &parameters) const
Superclass::FixedImageMaskPointer FixedImageMaskPointer
Definition: itkPCAMetric.h:94
Superclass::MovingImageMaskType MovingImageMaskType
Definition: itkPCAMetric.h:95
bool m_TransformIsStackTransform
Definition: itkPCAMetric.h:207
Superclass::ImageSampleContainerType ImageSampleContainerType
Definition: itkPCAMetric.h:104
vnl_vector< double > m_fifthEigenVector
Definition: itkPCAMetric.h:175
Superclass::MovingImageRegionType MovingImageRegionType
Definition: itkPCAMetric.h:101
Superclass::GradientPixelType GradientPixelType
Definition: itkPCAMetric.h:88
void operator=(const Self &)
Superclass::TransformJacobianType TransformJacobianType
Definition: itkPCAMetric.h:84
Superclass::BSplineInterpolatorType BSplineInterpolatorType
Definition: itkPCAMetric.h:158
virtual void GetDerivative(const TransformParametersType &parameters, DerivativeType &derivative) const
Superclass::MovingImageDerivativeType MovingImageDerivativeType
Definition: itkPCAMetric.h:160
Superclass::RealType RealType
Definition: itkPCAMetric.h:87
AdvancedImageToImageMetric< TFixedImage, TMovingImage > Superclass
Definition: itkPCAMetric.h:41
Superclass::MovingImageDerivativeScalesType MovingImageDerivativeScalesType
Definition: itkPCAMetric.h:114
unsigned int m_NumAdditionalSamplesFixed
Definition: itkPCAMetric.h:193
Superclass::MovingImageConstPointer MovingImageConstPointer
Definition: itkPCAMetric.h:76
Superclass::CoordinateRepresentationType CoordinateRepresentationType
Definition: itkPCAMetric.h:69
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
void SampleRandom(const int n, const int m, std::vector< int > &numbers) const
Superclass::FixedImageLimiterOutputType FixedImageLimiterOutputType
Definition: itkPCAMetric.h:110
Superclass::GradientImageType GradientImageType
Definition: itkPCAMetric.h:89
Superclass::InterpolatorType InterpolatorType
Definition: itkPCAMetric.h:85
Superclass::ParametersType ParametersType
Definition: itkPCAMetric.h:99
Superclass::FixedImageRegionType FixedImageRegionType
Definition: itkPCAMetric.h:45
PCAMetric(const Self &)
Superclass::GradientImageFilterType GradientImageFilterType
Definition: itkPCAMetric.h:91
Superclass::FixedImagePointType FixedImagePointType
Definition: itkPCAMetric.h:153
SmartPointer< Self > Pointer
Definition: itkPCAMetric.h:42
virtual ~PCAMetric()
Definition: itkPCAMetric.h:144
virtual void GetValueAndDerivative(const TransformParametersType &parameters, MeasureType &Value, DerivativeType &Derivative) const
Superclass::MovingImageLimiterType MovingImageLimiterType
Definition: itkPCAMetric.h:108
Superclass::FixedImagePixelType FixedImagePixelType
Definition: itkPCAMetric.h:100
Superclass::MovingImageMaskPointer MovingImageMaskPointer
Definition: itkPCAMetric.h:96
Superclass::FixedImageIndexType FixedImageIndexType
Definition: itkPCAMetric.h:150
Superclass::FixedImageMaskType FixedImageMaskType
Definition: itkPCAMetric.h:93
vnl_vector< double > m_seventhEigenVector
Definition: itkPCAMetric.h:177
Superclass::ImageSampleContainerPointer ImageSampleContainerPointer
Definition: itkPCAMetric.h:106
FixedImageRegionType::SizeType FixedImageSizeType
Definition: itkPCAMetric.h:46
Superclass::TransformParametersType TransformParametersType
Definition: itkPCAMetric.h:83
vnl_vector< double > m_eigenValues
Definition: itkPCAMetric.h:178
PCAMetric Self
Definition: itkPCAMetric.h:39
Superclass::FixedImageIndexValueType FixedImageIndexValueType
Definition: itkPCAMetric.h:151
unsigned int m_ReducedDimensionIndex
Definition: itkPCAMetric.h:194
SmartPointer< const Self > ConstPointer
Definition: itkPCAMetric.h:43
Superclass::TransformType TransformType
Definition: itkPCAMetric.h:79
bool m_UseDerivativeOfMean
Definition: itkPCAMetric.h:212
Superclass::FixedImageType FixedImageType
Definition: itkPCAMetric.h:77


Generated on 1667476801 for elastix by doxygen 1.9.1 elastix logo