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
28using namespace std;
29
30namespace itk
31{
32template <class TFixedImage, class TMovingImage>
33class ITK_TEMPLATE_EXPORT PCAMetric : public AdvancedImageToImageMetric<TFixedImage, TMovingImage>
34{
35public:
37
39 using Self = PCAMetric;
41 using Pointer = SmartPointer<Self>;
42 using ConstPointer = SmartPointer<const Self>;
43
44 using typename Superclass::FixedImageRegionType;
45 using FixedImageSizeType = typename FixedImageRegionType::SizeType;
46
48 itkNewMacro(Self);
49
52
54 itkSetMacro(SampleLastDimensionRandomly, bool);
55 itkSetMacro(NumSamplesLastDimension, unsigned int);
56 itkSetMacro(NumAdditionalSamplesFixed, unsigned int);
57 itkSetMacro(ReducedDimensionIndex, unsigned int);
58 itkSetMacro(SubtractMean, bool);
59 itkSetMacro(GridSize, FixedImageSizeType);
60 itkSetMacro(TransformIsStackTransform, bool);
61 itkSetMacro(NumEigenValues, unsigned int);
62 itkSetMacro(UseDerivativeOfMean, bool);
63 itkSetMacro(DeNoise, bool);
64 itkSetMacro(VarNoise, double);
65
67 itkGetConstMacro(SampleLastDimensionRandomly, bool);
68 itkGetConstMacro(NumSamplesLastDimension, int);
69
71 using typename Superclass::CoordinateRepresentationType;
72 using typename Superclass::MovingImageType;
73 using typename Superclass::MovingImagePixelType;
74 using typename Superclass::MovingImageConstPointer;
75 using typename Superclass::FixedImageType;
76 using typename Superclass::FixedImageConstPointer;
77 using typename Superclass::TransformType;
78 using typename Superclass::TransformPointer;
79 using typename Superclass::InputPointType;
80 using typename Superclass::OutputPointType;
81 using typename Superclass::TransformParametersType;
82 using typename Superclass::TransformJacobianType;
83 using typename Superclass::InterpolatorType;
84 using typename Superclass::InterpolatorPointer;
85 using typename Superclass::RealType;
86 using typename Superclass::GradientPixelType;
87 using typename Superclass::GradientImageType;
88 using typename Superclass::GradientImagePointer;
89 using typename Superclass::GradientImageFilterType;
90 using typename Superclass::GradientImageFilterPointer;
91 using typename Superclass::FixedImageMaskType;
92 using typename Superclass::FixedImageMaskPointer;
93 using typename Superclass::MovingImageMaskType;
94 using typename Superclass::MovingImageMaskPointer;
95 using typename Superclass::MeasureType;
96 using typename Superclass::DerivativeType;
97 using typename Superclass::ParametersType;
100 using typename Superclass::ImageSamplerType;
101 using typename Superclass::ImageSamplerPointer;
109
111 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
112
114 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
115
117 virtual MeasureType
118 GetValue(const TransformParametersType & parameters) const;
119
121 virtual void
122 GetDerivative(const TransformParametersType & parameters, DerivativeType & derivative) const;
123
125 virtual void
126 GetValueAndDerivative(const TransformParametersType & parameters,
127 MeasureType & Value,
128 DerivativeType & Derivative) const;
129
134 virtual void
136
137protected:
139 virtual ~PCAMetric() {}
140 void
141 PrintSelf(std::ostream & os, Indent indent) const;
142
146 using typename Superclass::FixedImageIndexType;
149 using typename Superclass::FixedImagePointType;
151 typename itk::ContinuousIndex<CoordinateRepresentationType, FixedImageDimension>;
158
162 void
163 EvaluateTransformJacobianInnerProduct(const TransformJacobianType & jacobian,
164 const MovingImageDerivativeType & movingImageDerivative,
165 DerivativeType & imageJacobian) const;
166
167 mutable vnl_vector<double> m_firstEigenVector;
168 mutable vnl_vector<double> m_secondEigenVector;
169 mutable vnl_vector<double> m_thirdEigenVector;
170 mutable vnl_vector<double> m_fourthEigenVector;
171 mutable vnl_vector<double> m_fifthEigenVector;
172 mutable vnl_vector<double> m_sixthEigenVector;
173 mutable vnl_vector<double> m_seventhEigenVector;
174 mutable vnl_vector<double> m_eigenValues;
175 mutable vnl_vector<double> m_normdCdmu;
176 mutable int m_NumberOfSamples;
177
178private:
180 void
181 SampleRandom(const int n, const int m, std::vector<int> & numbers) const;
182
188
190
192
195
198
201
203 unsigned int m_NumEigenValues;
204
206};
207
208} // end namespace itk
209
210#ifndef ITK_MANUAL_INSTANTIATION
211# include "itkPCAMetric.hxx"
212#endif
213
214#endif // end #ifndef itkPCAMetric_h
An extension of the ITK ImageToImageMetric. It is the intended base class for all elastix metrics.
typename TransformType::OutputPointType MovingImagePointType
typename ImageSamplerType::OutputVectorContainerPointer ImageSampleContainerPointer
typename MovingImageType::RegionType MovingImageRegionType
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
typename FixedImageType::PixelType FixedImagePixelType
GradientImageFilter< MovingImageType, RealType, RealType > CentralDifferenceGradientFilterType
typename FixedImageIndexType::IndexValueType FixedImageIndexValueType
typename MovingImageType::IndexType MovingImageIndexType
typename ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
typename FixedImageType::IndexType FixedImageIndexType
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
typename MovingImageLimiterType::OutputType MovingImageLimiterOutputType
typename TransformType::InputPointType FixedImagePointType
typename FixedImageLimiterType::OutputType FixedImageLimiterOutputType
typename ImageSamplerType::Pointer ImageSamplerPointer
typename InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType
This class is a base class for any image sampler.
Base class for all ITK limiter function objects.
unsigned int m_NumSamplesLastDimension
Definition: itkPCAMetric.h:185
unsigned int m_NumEigenValues
Definition: itkPCAMetric.h:203
vnl_vector< double > m_normdCdmu
Definition: itkPCAMetric.h:175
ITK_DISALLOW_COPY_AND_MOVE(PCAMetric)
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
typename itk::ContinuousIndex< CoordinateRepresentationType, FixedImageDimension > FixedImageContinuousIndexType
Definition: itkPCAMetric.h:151
void PrintSelf(std::ostream &os, Indent indent) const
vnl_vector< double > m_secondEigenVector
Definition: itkPCAMetric.h:168
bool m_SampleLastDimensionRandomly
Definition: itkPCAMetric.h:184
vnl_vector< double > m_firstEigenVector
Definition: itkPCAMetric.h:167
FixedImageSizeType m_GridSize
Definition: itkPCAMetric.h:197
vnl_vector< double > m_fourthEigenVector
Definition: itkPCAMetric.h:170
void EvaluateTransformJacobianInnerProduct(const TransformJacobianType &jacobian, const MovingImageDerivativeType &movingImageDerivative, DerivativeType &imageJacobian) const
virtual MeasureType GetValue(const TransformParametersType &parameters) const
bool m_TransformIsStackTransform
Definition: itkPCAMetric.h:200
vnl_vector< double > m_fifthEigenVector
Definition: itkPCAMetric.h:171
virtual void GetDerivative(const TransformParametersType &parameters, DerivativeType &derivative) const
typename FixedImageRegionType::SizeType FixedImageSizeType
Definition: itkPCAMetric.h:45
SmartPointer< const Self > ConstPointer
Definition: itkPCAMetric.h:42
unsigned int m_NumAdditionalSamplesFixed
Definition: itkPCAMetric.h:186
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
void SampleRandom(const int n, const int m, std::vector< int > &numbers) const
virtual ~PCAMetric()
Definition: itkPCAMetric.h:139
virtual void GetValueAndDerivative(const TransformParametersType &parameters, MeasureType &Value, DerivativeType &Derivative) const
vnl_vector< double > m_sixthEigenVector
Definition: itkPCAMetric.h:172
vnl_vector< double > m_eigenValues
Definition: itkPCAMetric.h:174
virtual void Initialize()
vnl_vector< double > m_seventhEigenVector
Definition: itkPCAMetric.h:173
vnl_vector< double > m_thirdEigenVector
Definition: itkPCAMetric.h:169
unsigned int m_ReducedDimensionIndex
Definition: itkPCAMetric.h:187
bool m_UseDerivativeOfMean
Definition: itkPCAMetric.h:205


Generated on Wed 12 Apr 2023 for elastix by doxygen 1.9.6 elastix logo