Loading...
Searching...
No Matches
itkPCAMetric.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht 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.
*
*=========================================================================*/
#ifndef itkPCAMetric_h
#define itkPCAMetric_h
#include "itkAdvancedImageToImageMetric.h"
#include "itkSmoothingRecursiveGaussianImageFilter.h"
#include "itkImageRandomCoordinateSampler.h"
#include "itkNearestNeighborInterpolateImageFunction.h"
#include "itkExtractImageFilter.h"
#include <vector>
namespace itk
{
template <class TFixedImage, class TMovingImage>
class ITK_TEMPLATE_EXPORT PCAMetric : public AdvancedImageToImageMetric<TFixedImage, TMovingImage>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(PCAMetric);
using Self = PCAMetric;
using Superclass = AdvancedImageToImageMetric<TFixedImage, TMovingImage>;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
using typename Superclass::FixedImageRegionType;
using FixedImageSizeType = typename FixedImageRegionType::SizeType;
itkNewMacro(Self);
itkTypeMacro(PCAMetric, AdvancedImageToImageMetric);
itkSetMacro(UseZeroAverageDisplacementConstraint, bool);
itkSetMacro(GridSize, FixedImageSizeType);
itkSetMacro(TransformIsStackTransform, bool);
itkSetMacro(NumEigenValues, unsigned int);
using typename Superclass::CoordinateRepresentationType;
using typename Superclass::MovingImageType;
using typename Superclass::MovingImagePixelType;
using typename Superclass::MovingImageConstPointer;
using typename Superclass::FixedImageType;
using typename Superclass::FixedImageConstPointer;
using typename Superclass::TransformType;
using typename Superclass::TransformPointer;
using typename Superclass::InputPointType;
using typename Superclass::OutputPointType;
using typename Superclass::TransformParametersType;
using typename Superclass::TransformJacobianType;
using typename Superclass::InterpolatorType;
using typename Superclass::InterpolatorPointer;
using typename Superclass::RealType;
using typename Superclass::GradientPixelType;
using typename Superclass::GradientImageType;
using typename Superclass::GradientImagePointer;
using typename Superclass::FixedImageMaskType;
using typename Superclass::FixedImageMaskPointer;
using typename Superclass::MovingImageMaskType;
using typename Superclass::MovingImageMaskPointer;
using typename Superclass::MeasureType;
using typename Superclass::DerivativeType;
using typename Superclass::ParametersType;
using typename Superclass::FixedImagePixelType;
using typename Superclass::MovingImageRegionType;
using typename Superclass::ImageSamplerType;
using typename Superclass::ImageSamplerPointer;
using typename Superclass::ImageSampleContainerType;
using typename Superclass::ImageSampleContainerPointer;
using typename Superclass::FixedImageLimiterType;
using typename Superclass::MovingImageLimiterType;
using typename Superclass::FixedImageLimiterOutputType;
using typename Superclass::MovingImageLimiterOutputType;
using typename Superclass::MovingImageDerivativeScalesType;
using typename Superclass::DerivativeValueType;
using typename Superclass::ThreadInfoType;
using MatrixType = vnl_matrix<RealType>;
using DerivativeMatrixType = vnl_matrix<DerivativeValueType>;
// using MatrixType = vnl_matrix< double >;
// using DerivativeMatrixType = vnl_matrix< double >;
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
MeasureType
GetValue(const TransformParametersType & parameters) const override;
void
GetDerivative(const TransformParametersType & parameters, DerivativeType & derivative) const override;
void
GetValueAndDerivativeSingleThreaded(const TransformParametersType & parameters,
MeasureType & Value,
DerivativeType & Derivative) const;
void
GetValueAndDerivative(const TransformParametersType & parameters,
MeasureType & Value,
DerivativeType & Derivative) const override;
void
Initialize() override;
protected:
PCAMetric();
~PCAMetric() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;
using typename Superclass::FixedImageIndexType;
using typename Superclass::FixedImageIndexValueType;
using typename Superclass::MovingImageIndexType;
using typename Superclass::FixedImagePointType;
using FixedImageContinuousIndexType =
typename itk::ContinuousIndex<CoordinateRepresentationType, FixedImageDimension>;
using typename Superclass::MovingImagePointType;
using typename Superclass::MovingImageContinuousIndexType;
using typename Superclass::BSplineInterpolatorType;
using typename Superclass::MovingImageDerivativeType;
using typename Superclass::NonZeroJacobianIndicesType;
void
EvaluateTransformJacobianInnerProduct(const TransformJacobianType & jacobian,
const MovingImageDerivativeType & movingImageDerivative,
DerivativeType & imageJacobian) const override;
void
ThreadedGetSamples(ThreadIdType threadID);
void
ThreadedComputeDerivative(ThreadIdType threadID);
void
AfterThreadedGetSamples(MeasureType & value) const;
void
AfterThreadedComputeDerivative(DerivativeType & derivative) const;
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
GetSamplesThreaderCallback(void * arg);
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
ComputeDerivativeThreaderCallback(void * arg);
void
LaunchGetSamplesThreaderCallback() const;
void
LaunchComputeDerivativeThreaderCallback() const;
void
InitializeThreadingParameters() const override;
private:
struct PCAMetricMultiThreaderParameterType
{
Self * m_Metric;
};
PCAMetricMultiThreaderParameterType m_PCAMetricThreaderParameters{};
struct PCAMetricGetSamplesPerThreadStruct
{
SizeValueType st_NumberOfPixelsCounted;
MatrixType st_DataBlock;
std::vector<FixedImagePointType> st_ApprovedSamples;
DerivativeType st_Derivative;
};
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, PCAMetricGetSamplesPerThreadStruct, PaddedPCAMetricGetSamplesPerThreadStruct);
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
PaddedPCAMetricGetSamplesPerThreadStruct,
AlignedPCAMetricGetSamplesPerThreadStruct);
mutable std::vector<AlignedPCAMetricGetSamplesPerThreadStruct> m_PCAMetricGetSamplesPerThreadVariables{};
unsigned int m_G{};
unsigned int m_LastDimIndex{};
bool m_UseZeroAverageDisplacementConstraint{ true };
FixedImageSizeType m_GridSize{};
bool m_TransformIsStackTransform{ false };
unsigned int m_NumEigenValues{ 6 };
mutable std::vector<unsigned int> m_PixelStartIndex{};
mutable MatrixType m_Atmm{};
mutable DerivativeMatrixType m_vSAtmm{};
mutable DerivativeMatrixType m_CSv{};
mutable DerivativeMatrixType m_Sv{};
mutable DerivativeMatrixType m_vdSdmu_part1{};
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
# include "itkPCAMetric.hxx"
#endif
#endif // end #ifndef itkPCAMetric_h
itk::AdvancedImageToImageMetric::MovingImagePointType
typename TransformType::OutputPointType MovingImagePointType
Definition itkAdvancedImageToImageMetric.h:338
itk::AdvancedImageToImageMetric::ImageSampleContainerPointer
typename ImageSamplerType::OutputVectorContainerPointer ImageSampleContainerPointer
Definition itkAdvancedImageToImageMetric.h:145
itk::AdvancedImageToImageMetric::MovingImageRegionType
typename MovingImageType::RegionType MovingImageRegionType
Definition itkAdvancedImageToImageMetric.h:138
itk::AdvancedImageToImageMetric::NonZeroJacobianIndicesType
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Definition itkAdvancedImageToImageMetric.h:356
itk::AdvancedImageToImageMetric::MovingImageDerivativeScalesType
FixedArray< double, Self::MovingImageDimension > MovingImageDerivativeScalesType
Definition itkAdvancedImageToImageMetric.h:139
itk::AdvancedImageToImageMetric::FixedImagePixelType
typename FixedImageType::PixelType FixedImagePixelType
Definition itkAdvancedImageToImageMetric.h:137
itk::AdvancedImageToImageMetric::DerivativeValueType
typename DerivativeType::ValueType DerivativeValueType
Definition itkAdvancedImageToImageMetric.h:133
itk::AdvancedImageToImageMetric::FixedImageIndexValueType
typename FixedImageIndexType::IndexValueType FixedImageIndexValueType
Definition itkAdvancedImageToImageMetric.h:335
itk::AdvancedImageToImageMetric::MovingImageIndexType
typename MovingImageType::IndexType MovingImageIndexType
Definition itkAdvancedImageToImageMetric.h:336
itk::AdvancedImageToImageMetric::ImageSampleContainerType
typename ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
Definition itkAdvancedImageToImageMetric.h:144
itk::AdvancedImageToImageMetric::FixedImageMaskType
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
Definition itkAdvancedImageToImageMetric.h:124
itk::AdvancedImageToImageMetric::FixedImageIndexType
typename FixedImageType::IndexType FixedImageIndexType
Definition itkAdvancedImageToImageMetric.h:334
itk::AdvancedImageToImageMetric::MovingImageMaskPointer
SmartPointer< MovingImageMaskType > MovingImageMaskPointer
Definition itkAdvancedImageToImageMetric.h:128
itk::AdvancedImageToImageMetric::FixedImageLimiterType
LimiterFunctionBase< RealType, FixedImageDimension > FixedImageLimiterType
Definition itkAdvancedImageToImageMetric.h:148
itk::AdvancedImageToImageMetric::AdvancedImageToImageMetric
AdvancedImageToImageMetric()
itk::AdvancedImageToImageMetric::ImageSamplerType
ImageSamplerBase< FixedImageType > ImageSamplerType
Definition itkAdvancedImageToImageMetric.h:142
itk::AdvancedImageToImageMetric::ThreadInfoType
MultiThreaderBase::WorkUnitInfo ThreadInfoType
Definition itkAdvancedImageToImageMetric.h:170
itk::AdvancedImageToImageMetric::MovingImageDerivativeType
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
Definition itkAdvancedImageToImageMetric.h:353
itk::AdvancedImageToImageMetric::MovingImageLimiterType
LimiterFunctionBase< RealType, MovingImageDimension > MovingImageLimiterType
Definition itkAdvancedImageToImageMetric.h:151
itk::AdvancedImageToImageMetric::MovingImageLimiterOutputType
typename MovingImageLimiterType::OutputType MovingImageLimiterOutputType
Definition itkAdvancedImageToImageMetric.h:153
itk::AdvancedImageToImageMetric::FixedImagePointType
typename TransformType::InputPointType FixedImagePointType
Definition itkAdvancedImageToImageMetric.h:337
itk::AdvancedImageToImageMetric::FixedImageLimiterOutputType
typename FixedImageLimiterType::OutputType FixedImageLimiterOutputType
Definition itkAdvancedImageToImageMetric.h:150
itk::AdvancedImageToImageMetric::FixedImageMaskPointer
SmartPointer< FixedImageMaskType > FixedImageMaskPointer
Definition itkAdvancedImageToImageMetric.h:125
itk::AdvancedImageToImageMetric::BSplineInterpolatorType
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
Definition itkAdvancedImageToImageMetric.h:342
itk::AdvancedImageToImageMetric::ImageSamplerPointer
typename ImageSamplerType::Pointer ImageSamplerPointer
Definition itkAdvancedImageToImageMetric.h:143
itk::AdvancedImageToImageMetric::MovingImageContinuousIndexType
typename InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType
Definition itkAdvancedImageToImageMetric.h:339
itk::AdvancedImageToImageMetric::MovingImageMaskType
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
Definition itkAdvancedImageToImageMetric.h:127
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_G
unsigned int m_G
Definition itkPCAMetric.h:221
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_NumEigenValues
unsigned int m_NumEigenValues
Definition itkPCAMetric.h:234
itk::PCAMetric::GetValueAndDerivativeSingleThreaded
void GetValueAndDerivativeSingleThreaded(const TransformParametersType &parameters, MeasureType &Value, DerivativeType &Derivative) const
itk::PCAMetric::InitializeThreadingParameters
void InitializeThreadingParameters() const override
itk::PCAMetric::AfterThreadedGetSamples
void AfterThreadedGetSamples(MeasureType &value) const
itk::PCAMetric::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::PCAMetric::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(PCAMetric)
itk::PCAMetric::itkStaticConstMacro
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_PixelStartIndex
std::vector< unsigned int > m_PixelStartIndex
Definition itkPCAMetric.h:237
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_LastDimIndex
unsigned int m_LastDimIndex
Definition itkPCAMetric.h:222
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::Superclass
AdvancedImageToImageMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType > Superclass
Definition itkPCAMetric.h:39
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::Self
PCAMetric Self
Definition itkPCAMetric.h:38
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_PCAMetricThreaderParameters
PCAMetricMultiThreaderParameterType m_PCAMetricThreaderParameters
Definition itkPCAMetric.h:203
itk::PCAMetric::itkAlignedTypedef
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedPCAMetricGetSamplesPerThreadStruct, AlignedPCAMetricGetSamplesPerThreadStruct)
itk::PCAMetric::GetValueAndDerivative
void GetValueAndDerivative(const TransformParametersType &parameters, MeasureType &Value, DerivativeType &Derivative) const override
itk::PCAMetric::GetValue
MeasureType GetValue(const TransformParametersType &parameters) const override
itk::PCAMetric::EvaluateTransformJacobianInnerProduct
void EvaluateTransformJacobianInnerProduct(const TransformJacobianType &jacobian, const MovingImageDerivativeType &movingImageDerivative, DerivativeType &imageJacobian) const override
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_Sv
DerivativeMatrixType m_Sv
Definition itkPCAMetric.h:241
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_Atmm
MatrixType m_Atmm
Definition itkPCAMetric.h:238
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_GridSize
FixedImageSizeType m_GridSize
Definition itkPCAMetric.h:228
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::Pointer
SmartPointer< Self > Pointer
Definition itkPCAMetric.h:40
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_TransformIsStackTransform
bool m_TransformIsStackTransform
Definition itkPCAMetric.h:231
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_vSAtmm
DerivativeMatrixType m_vSAtmm
Definition itkPCAMetric.h:239
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::FixedImageContinuousIndexType
typename itk::ContinuousIndex< CoordinateRepresentationType, FixedImageDimension > FixedImageContinuousIndexType
Definition itkPCAMetric.h:149
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::FixedImageSizeType
typename FixedImageRegionType::SizeType FixedImageSizeType
Definition itkPCAMetric.h:44
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::ConstPointer
SmartPointer< const Self > ConstPointer
Definition itkPCAMetric.h:41
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_UseZeroAverageDisplacementConstraint
bool m_UseZeroAverageDisplacementConstraint
Definition itkPCAMetric.h:225
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_CSv
DerivativeMatrixType m_CSv
Definition itkPCAMetric.h:240
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::MovingImageDerivativeType
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::MatrixType
vnl_matrix< RealType > MatrixType
Definition itkPCAMetric.h:98
itk::PCAMetric::itkStaticConstMacro
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
itk::PCAMetric::LaunchComputeDerivativeThreaderCallback
void LaunchComputeDerivativeThreaderCallback() const
itk::PCAMetric::Initialize
void Initialize() override
itk::PCAMetric::ThreadedComputeDerivative
void ThreadedComputeDerivative(ThreadIdType threadID)
itk::PCAMetric::GetSamplesThreaderCallback
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION GetSamplesThreaderCallback(void *arg)
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_PCAMetricGetSamplesPerThreadVariables
std::vector< AlignedPCAMetricGetSamplesPerThreadStruct > m_PCAMetricGetSamplesPerThreadVariables
Definition itkPCAMetric.h:219
itk::PCAMetric::AfterThreadedComputeDerivative
void AfterThreadedComputeDerivative(DerivativeType &derivative) const
itk::PCAMetric::LaunchGetSamplesThreaderCallback
void LaunchGetSamplesThreaderCallback() const
itk::PCAMetric::PCAMetric
PCAMetric()
itk::PCAMetric::ComputeDerivativeThreaderCallback
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ComputeDerivativeThreaderCallback(void *arg)
itk::PCAMetric::~PCAMetric
~PCAMetric() override=default
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::DerivativeMatrixType
vnl_matrix< DerivativeValueType > DerivativeMatrixType
Definition itkPCAMetric.h:99
itk::PCAMetric::ThreadedGetSamples
void ThreadedGetSamples(ThreadIdType threadID)
itk::PCAMetric::itkPadStruct
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, PCAMetricGetSamplesPerThreadStruct, PaddedPCAMetricGetSamplesPerThreadStruct)
itk::PCAMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType >::m_vdSdmu_part1
DerivativeMatrixType m_vdSdmu_part1
Definition itkPCAMetric.h:242
itk::PCAMetric::GetDerivative
void GetDerivative(const TransformParametersType &parameters, DerivativeType &derivative) const override
itkAdvancedImageToImageMetric.h
itkImageRandomCoordinateSampler.h
itk
Definition itkAdvancedImageToImageMetric.h:43
itk::PCAMetric::PCAMetricGetSamplesPerThreadStruct
Definition itkPCAMetric.h:206
itk::PCAMetric::PCAMetricGetSamplesPerThreadStruct::st_NumberOfPixelsCounted
SizeValueType st_NumberOfPixelsCounted
Definition itkPCAMetric.h:207
itk::PCAMetric::PCAMetricGetSamplesPerThreadStruct::st_Derivative
DerivativeType st_Derivative
Definition itkPCAMetric.h:210
itk::PCAMetric::PCAMetricGetSamplesPerThreadStruct::st_ApprovedSamples
std::vector< FixedImagePointType > st_ApprovedSamples
Definition itkPCAMetric.h:209
itk::PCAMetric::PCAMetricGetSamplesPerThreadStruct::st_DataBlock
MatrixType st_DataBlock
Definition itkPCAMetric.h:208
itk::PCAMetric::PCAMetricMultiThreaderParameterType
Definition itkPCAMetric.h:199
itk::PCAMetric::PCAMetricMultiThreaderParameterType::m_Metric
Self * m_Metric
Definition itkPCAMetric.h:200

Generated on 1768596610 for elastix by 1.15.0 |