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#include <vector>
28
29namespace itk
30{
31template <class TFixedImage, class TMovingImage>
32class ITK_TEMPLATE_EXPORT PCAMetric : public AdvancedImageToImageMetric<TFixedImage, TMovingImage>
33{
34public:
36
38 using Self = PCAMetric;
40 using Pointer = SmartPointer<Self>;
41 using ConstPointer = SmartPointer<const Self>;
42
43 using typename Superclass::FixedImageRegionType;
44 using FixedImageSizeType = typename FixedImageRegionType::SizeType;
45
47 itkNewMacro(Self);
48
51
53 itkSetMacro(UseZeroAverageDisplacementConstraint, bool);
54 itkSetMacro(GridSize, FixedImageSizeType);
55 itkSetMacro(TransformIsStackTransform, bool);
56 itkSetMacro(NumEigenValues, unsigned int);
57
59 using typename Superclass::CoordinateRepresentationType;
60 using typename Superclass::MovingImageType;
61 using typename Superclass::MovingImagePixelType;
62 using typename Superclass::MovingImageConstPointer;
63 using typename Superclass::FixedImageType;
64 using typename Superclass::FixedImageConstPointer;
65 using typename Superclass::TransformType;
66 using typename Superclass::TransformPointer;
67 using typename Superclass::InputPointType;
68 using typename Superclass::OutputPointType;
69 using typename Superclass::TransformParametersType;
70 using typename Superclass::TransformJacobianType;
71 using typename Superclass::InterpolatorType;
72 using typename Superclass::InterpolatorPointer;
73 using typename Superclass::RealType;
74 using typename Superclass::GradientPixelType;
75 using typename Superclass::GradientImageType;
76 using typename Superclass::GradientImagePointer;
77 using typename Superclass::FixedImageMaskType;
81 using typename Superclass::MeasureType;
82 using typename Superclass::DerivativeType;
83 using typename Superclass::ParametersType;
86 using typename Superclass::ImageSamplerType;
96 using typename Superclass::ThreadInfoType;
97
98 using MatrixType = vnl_matrix<RealType>;
99 using DerivativeMatrixType = vnl_matrix<DerivativeValueType>;
100
101 // using MatrixType = vnl_matrix< double >;
102 // using DerivativeMatrixType = vnl_matrix< double >;
103
105 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
106
108 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
109
111 MeasureType
112 GetValue(const TransformParametersType & parameters) const override;
113
115 void
116 GetDerivative(const TransformParametersType & parameters, DerivativeType & derivative) const override;
117
119 void
120 GetValueAndDerivativeSingleThreaded(const TransformParametersType & parameters,
121 MeasureType & Value,
122 DerivativeType & Derivative) const;
123
124 void
125 GetValueAndDerivative(const TransformParametersType & parameters,
126 MeasureType & Value,
127 DerivativeType & Derivative) const override;
128
133 void
134 Initialize() override;
135
136protected:
138 ~PCAMetric() override = default;
139 void
140 PrintSelf(std::ostream & os, Indent indent) const override;
141
145 using typename Superclass::FixedImageIndexType;
148 using typename Superclass::FixedImagePointType;
150 typename itk::ContinuousIndex<CoordinateRepresentationType, FixedImageDimension>;
156
160 void
161 EvaluateTransformJacobianInnerProduct(const TransformJacobianType & jacobian,
162 const MovingImageDerivativeType & movingImageDerivative,
163 DerivativeType & imageJacobian) const override;
164
166 void
167 ThreadedGetSamples(ThreadIdType threadID);
168
169 void
170 ThreadedComputeDerivative(ThreadIdType threadID);
171
173 void
174 AfterThreadedGetSamples(MeasureType & value) const;
175
176 void
177 AfterThreadedComputeDerivative(DerivativeType & derivative) const;
178
180 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
182
183 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
185
187 void
189
190 void
192
194 void
196
197private:
202
203 PCAMetricMultiThreaderParameterType m_PCAMetricThreaderParameters{};
204
206 {
209 std::vector<FixedImagePointType> st_ApprovedSamples;
210 DerivativeType st_Derivative;
211 };
212
213 itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, PCAMetricGetSamplesPerThreadStruct, PaddedPCAMetricGetSamplesPerThreadStruct);
214
215 itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
216 PaddedPCAMetricGetSamplesPerThreadStruct,
217 AlignedPCAMetricGetSamplesPerThreadStruct);
218
219 mutable std::vector<AlignedPCAMetricGetSamplesPerThreadStruct> m_PCAMetricGetSamplesPerThreadVariables{};
220
221 unsigned int m_G{};
222 unsigned int m_LastDimIndex{};
223
225 bool m_UseZeroAverageDisplacementConstraint{ true };
226
228 FixedImageSizeType m_GridSize{};
229
231 bool m_TransformIsStackTransform{ false };
232
234 unsigned int m_NumEigenValues{ 6 };
235
237 mutable std::vector<unsigned int> m_PixelStartIndex{};
238 mutable MatrixType m_Atmm{};
239 mutable DerivativeMatrixType m_vSAtmm{};
240 mutable DerivativeMatrixType m_CSv{};
241 mutable DerivativeMatrixType m_Sv{};
242 mutable DerivativeMatrixType m_vdSdmu_part1{};
243};
244
245} // end namespace itk
246
247#ifndef ITK_MANUAL_INSTANTIATION
248# include "itkPCAMetric.hxx"
249#endif
250
251#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
typename DerivativeType::ValueType DerivativeValueType
typename FixedImageIndexType::IndexValueType FixedImageIndexValueType
typename MovingImageType::IndexType MovingImageIndexType
typename ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
typename FixedImageType::IndexType FixedImageIndexType
SmartPointer< MovingImageMaskType > MovingImageMaskPointer
MultiThreaderBase::WorkUnitInfo ThreadInfoType
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
typename MovingImageLimiterType::OutputType MovingImageLimiterOutputType
typename TransformType::InputPointType FixedImagePointType
typename FixedImageLimiterType::OutputType FixedImageLimiterOutputType
SmartPointer< FixedImageMaskType > FixedImageMaskPointer
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
typename ImageSamplerType::Pointer ImageSamplerPointer
typename InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
This class is a base class for any image sampler.
Base class for all ITK limiter function objects.
void GetValueAndDerivativeSingleThreaded(const TransformParametersType &parameters, MeasureType &Value, DerivativeType &Derivative) const
void InitializeThreadingParameters() const override
void AfterThreadedGetSamples(MeasureType &value) const
void PrintSelf(std::ostream &os, Indent indent) const override
ITK_DISALLOW_COPY_AND_MOVE(PCAMetric)
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedPCAMetricGetSamplesPerThreadStruct, AlignedPCAMetricGetSamplesPerThreadStruct)
void GetValueAndDerivative(const TransformParametersType &parameters, MeasureType &Value, DerivativeType &Derivative) const override
MeasureType GetValue(const TransformParametersType &parameters) const override
void EvaluateTransformJacobianInnerProduct(const TransformJacobianType &jacobian, const MovingImageDerivativeType &movingImageDerivative, DerivativeType &imageJacobian) const override
typename itk::ContinuousIndex< CoordinateRepresentationType, FixedImageDimension > FixedImageContinuousIndexType
typename FixedImageRegionType::SizeType FixedImageSizeType
SmartPointer< const Self > ConstPointer
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
void LaunchComputeDerivativeThreaderCallback() const
void Initialize() override
void ThreadedComputeDerivative(ThreadIdType threadID)
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetSamplesThreaderCallback(void *arg)
void AfterThreadedComputeDerivative(DerivativeType &derivative) const
void LaunchGetSamplesThreaderCallback() const
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ComputeDerivativeThreaderCallback(void *arg)
~PCAMetric() override=default
void ThreadedGetSamples(ThreadIdType threadID)
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, PCAMetricGetSamplesPerThreadStruct, PaddedPCAMetricGetSamplesPerThreadStruct)
void GetDerivative(const TransformParametersType &parameters, DerivativeType &derivative) const override
std::vector< FixedImagePointType > st_ApprovedSamples


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo