Loading...
Searching...
No Matches
itkComputeDisplacementDistribution.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 itkComputeDisplacementDistribution_h
#define itkComputeDisplacementDistribution_h
#include "itkScaledSingleValuedNonLinearOptimizer.h"
#include "itkImageGridSampler.h"
#include "itkImageRandomSamplerBase.h"
#include "itkImageRandomCoordinateSampler.h"
#include "itkImageFullSampler.h"
#include "itkMultiThreaderBase.h"
#include <vector>
namespace itk
{
template <class TFixedImage, class TTransform>
class ITK_TEMPLATE_EXPORT ComputeDisplacementDistribution : public ScaledSingleValuedNonLinearOptimizer
{
public:
ITK_DISALLOW_COPY_AND_MOVE(ComputeDisplacementDistribution);
using Self = ComputeDisplacementDistribution;
using Superclass = ScaledSingleValuedNonLinearOptimizer;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
itkNewMacro(Self);
itkTypeMacro(ComputeDisplacementDistribution, ScaledSingleValuedNonLinearOptimizer);
using FixedImageType = TFixedImage;
using FixedImagePixelType = typename FixedImageType::PixelType;
using TransformType = TTransform;
using TransformPointer = typename TransformType::Pointer;
using FixedImageRegionType = typename FixedImageType::RegionType;
using Superclass::ParametersType;
using Superclass::DerivativeType;
using Superclass::ScalesType;
itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension);
using FixedImageMaskType = ImageMaskSpatialObject<Self::FixedImageDimension>;
using FixedImageMaskPointer = typename FixedImageMaskType::Pointer;
using FixedImageMaskConstPointer = typename FixedImageMaskType::ConstPointer;
using NonZeroJacobianIndicesType = typename TransformType::NonZeroJacobianIndicesType;
itkSetConstObjectMacro(FixedImage, FixedImageType);
itkSetObjectMacro(Transform, TransformType);
itkSetObjectMacro(FixedImageMask, FixedImageMaskType);
itkSetConstObjectMacro(FixedImageMask, FixedImageMaskType);
itkGetConstObjectMacro(FixedImageMask, FixedImageMaskType);
itkSetMacro(NumberOfJacobianMeasurements, SizeValueType);
void
SetFixedImageRegion(const FixedImageRegionType & region)
{
if (region != this->m_FixedImageRegion)
{
this->m_FixedImageRegion = region;
}
}
itkGetConstReferenceMacro(FixedImageRegion, FixedImageRegionType);
virtual void
Compute(const ParametersType & mu, double & jacg, double & maxJJ, std::string method);
virtual void
ComputeSingleThreaded(const ParametersType & mu, double & jacg, double & maxJJ, std::string method);
virtual void
ComputeUsingSearchDirection(const ParametersType & mu, double & jacg, double & maxJJ, std::string methods);
void
SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
{
this->m_Threader->SetNumberOfWorkUnits(numberOfThreads);
}
virtual void
BeforeThreadedCompute(const ParametersType & mu);
virtual void
AfterThreadedCompute(double & jacg, double & maxJJ);
protected:
ComputeDisplacementDistribution();
~ComputeDisplacementDistribution() override = default;
using ThreadInfoType = MultiThreaderBase::WorkUnitInfo;
typename FixedImageType::ConstPointer m_FixedImage{};
FixedImageRegionType m_FixedImageRegion{};
FixedImageMaskConstPointer m_FixedImageMask{};
TransformPointer m_Transform{};
ScaledSingleValuedCostFunction::Pointer m_CostFunction{};
SizeValueType m_NumberOfJacobianMeasurements{};
DerivativeType m_ExactGradient{};
SizeValueType m_NumberOfParameters{};
MultiThreaderBase::Pointer m_Threader{};
using FixedImageIndexType = typename FixedImageType::IndexType;
using FixedImagePointType = typename FixedImageType::PointType;
using JacobianType = typename TransformType::JacobianType;
using JacobianValueType = typename JacobianType::ValueType;
using ImageSamplerBaseType = ImageSamplerBase<FixedImageType>;
using ImageSamplerBasePointer = typename ImageSamplerBaseType::Pointer;
using ImageFullSamplerType = ImageFullSampler<FixedImageType>;
using ImageFullSamplerPointer = typename ImageFullSamplerType::Pointer;
using ImageRandomSamplerBaseType = ImageRandomSamplerBase<FixedImageType>;
using ImageRandomSamplerBasePointer = typename ImageRandomSamplerBaseType::Pointer;
using ImageGridSamplerType = ImageGridSampler<FixedImageType>;
using ImageGridSamplerPointer = typename ImageGridSamplerType::Pointer;
using ImageSampleContainerType = typename ImageGridSamplerType ::ImageSampleContainerType;
using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
using TransformJacobianType = JacobianType;
using CoordinateRepresentationType = typename TransformType::ScalarType;
using NumberOfParametersType = typename TransformType::NumberOfParametersType;
// \todo: note that this is an exact copy of itk::ComputeJacobianTerms
// in the future it would be better to refactoring this part of the code
virtual void
SampleFixedImageForJacobianTerms(ImageSampleContainerPointer & sampleContainer);
void
LaunchComputeThreaderCallback() const;
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
ComputeThreaderCallback(void * arg);
virtual void
ThreadedCompute(ThreadIdType threadID);
virtual void
InitializeThreadingParameters();
struct MultiThreaderParameterType
{
Self * st_Self;
};
struct ComputePerThreadStruct
{
double st_MaxJJ;
double st_Displacement;
double st_DisplacementSquared;
SizeValueType st_NumberOfPixelsCounted;
};
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct);
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct);
private:
mutable MultiThreaderParameterType m_ThreaderParameters{};
mutable std::vector<AlignedComputePerThreadStruct> m_ComputePerThreadVariables{};
SizeValueType m_NumberOfPixelsCounted{};
bool m_UseMultiThread{};
ImageSampleContainerPointer m_SampleContainer{};
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
# include "itkComputeDisplacementDistribution.hxx"
#endif
#endif // end #ifndef itkComputeDisplacementDistribution_h
itk::ComputeDisplacementDistribution::Superclass
ScaledSingleValuedNonLinearOptimizer Superclass
Definition itkComputeDisplacementDistribution.h:55
itk::ComputeDisplacementDistribution::ImageFullSamplerPointer
typename ImageFullSamplerType::Pointer ImageFullSamplerPointer
Definition itkComputeDisplacementDistribution.h:164
itk::ComputeDisplacementDistribution::FixedImagePointType
typename FixedImageType::PointType FixedImagePointType
Definition itkComputeDisplacementDistribution.h:155
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_Transform
TransformPointer m_Transform
Definition itkComputeDisplacementDistribution.h:147
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_NumberOfPixelsCounted
SizeValueType m_NumberOfPixelsCounted
Definition itkComputeDisplacementDistribution.h:222
itk::ComputeDisplacementDistribution::FixedImagePixelType
typename FixedImageType::PixelType FixedImagePixelType
Definition itkComputeDisplacementDistribution.h:67
itk::ComputeDisplacementDistribution::Compute
virtual void Compute(const ParametersType &mu, double &jacg, double &maxJJ, std::string method)
itk::ComputeDisplacementDistribution::FixedImageMaskPointer
typename FixedImageMaskType::Pointer FixedImageMaskPointer
Definition itkComputeDisplacementDistribution.h:80
itk::ComputeDisplacementDistribution::ComputeSingleThreaded
virtual void ComputeSingleThreaded(const ParametersType &mu, double &jacg, double &maxJJ, std::string method)
itk::ComputeDisplacementDistribution::ImageGridSamplerPointer
typename ImageGridSamplerType::Pointer ImageGridSamplerPointer
Definition itkComputeDisplacementDistribution.h:170
itk::ComputeDisplacementDistribution::ImageGridSamplerType
ImageGridSampler< FixedImageType > ImageGridSamplerType
Definition itkComputeDisplacementDistribution.h:169
itk::ComputeDisplacementDistribution::TransformType
TTransform TransformType
Definition itkComputeDisplacementDistribution.h:68
itk::ComputeDisplacementDistribution::ImageRandomSamplerBaseType
ImageRandomSamplerBase< FixedImageType > ImageRandomSamplerBaseType
Definition itkComputeDisplacementDistribution.h:166
itk::ComputeDisplacementDistribution::itkPadStruct
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct)
itk::ComputeDisplacementDistribution::ThreadedCompute
virtual void ThreadedCompute(ThreadIdType threadID)
itk::ComputeDisplacementDistribution::FixedImageIndexType
typename FixedImageType::IndexType FixedImageIndexType
Definition itkComputeDisplacementDistribution.h:154
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_FixedImageMask
FixedImageMaskConstPointer m_FixedImageMask
Definition itkComputeDisplacementDistribution.h:146
itk::ComputeDisplacementDistribution::itkStaticConstMacro
itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension)
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_FixedImageRegion
FixedImageRegionType m_FixedImageRegion
Definition itkComputeDisplacementDistribution.h:145
itk::ComputeDisplacementDistribution::ComputeDisplacementDistribution
ComputeDisplacementDistribution()
itk::ComputeDisplacementDistribution::JacobianType
typename TransformType::JacobianType JacobianType
Definition itkComputeDisplacementDistribution.h:156
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_FixedImage
FixedImageType::ConstPointer m_FixedImage
Definition itkComputeDisplacementDistribution.h:144
itk::ComputeDisplacementDistribution::SampleFixedImageForJacobianTerms
virtual void SampleFixedImageForJacobianTerms(ImageSampleContainerPointer &sampleContainer)
itk::ComputeDisplacementDistribution::ComputeUsingSearchDirection
virtual void ComputeUsingSearchDirection(const ParametersType &mu, double &jacg, double &maxJJ, std::string methods)
itk::ComputeDisplacementDistribution::InitializeThreadingParameters
virtual void InitializeThreadingParameters()
itk::ComputeDisplacementDistribution::itkAlignedTypedef
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct)
itk::ComputeDisplacementDistribution::ImageRandomSamplerBasePointer
typename ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
Definition itkComputeDisplacementDistribution.h:167
itk::ComputeDisplacementDistribution::ImageFullSamplerType
ImageFullSampler< FixedImageType > ImageFullSamplerType
Definition itkComputeDisplacementDistribution.h:163
itk::ComputeDisplacementDistribution::ComputeThreaderCallback
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ComputeThreaderCallback(void *arg)
itk::ComputeDisplacementDistribution::AfterThreadedCompute
virtual void AfterThreadedCompute(double &jacg, double &maxJJ)
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_NumberOfParameters
SizeValueType m_NumberOfParameters
Definition itkComputeDisplacementDistribution.h:151
itk::ComputeDisplacementDistribution::SetFixedImageRegion
void SetFixedImageRegion(const FixedImageRegionType &region)
Definition itkComputeDisplacementDistribution.h:100
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_CostFunction
ScaledSingleValuedCostFunction::Pointer m_CostFunction
Definition itkComputeDisplacementDistribution.h:148
itk::ComputeDisplacementDistribution::FixedImageRegionType
typename FixedImageType::RegionType FixedImageRegionType
Definition itkComputeDisplacementDistribution.h:70
itk::ComputeDisplacementDistribution::ThreadInfoType
MultiThreaderBase::WorkUnitInfo ThreadInfoType
Definition itkComputeDisplacementDistribution.h:142
itk::ComputeDisplacementDistribution::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(ComputeDisplacementDistribution)
itk::ComputeDisplacementDistribution::FixedImageMaskType
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
Definition itkComputeDisplacementDistribution.h:79
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_SampleContainer
ImageSampleContainerPointer m_SampleContainer
Definition itkComputeDisplacementDistribution.h:224
itk::ComputeDisplacementDistribution::~ComputeDisplacementDistribution
~ComputeDisplacementDistribution() override=default
itk::ComputeDisplacementDistribution::ImageSampleContainerPointer
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
Definition itkComputeDisplacementDistribution.h:172
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_NumberOfJacobianMeasurements
SizeValueType m_NumberOfJacobianMeasurements
Definition itkComputeDisplacementDistribution.h:149
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_Threader
MultiThreaderBase::Pointer m_Threader
Definition itkComputeDisplacementDistribution.h:152
itk::ComputeDisplacementDistribution::LaunchComputeThreaderCallback
void LaunchComputeThreaderCallback() const
itk::ComputeDisplacementDistribution::NumberOfParametersType
typename TransformType::NumberOfParametersType NumberOfParametersType
Definition itkComputeDisplacementDistribution.h:177
itk::ComputeDisplacementDistribution::Pointer
SmartPointer< Self > Pointer
Definition itkComputeDisplacementDistribution.h:56
itk::ComputeDisplacementDistribution::NonZeroJacobianIndicesType
typename TransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Definition itkComputeDisplacementDistribution.h:82
itk::ComputeDisplacementDistribution::SetNumberOfWorkUnits
void SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
Definition itkComputeDisplacementDistribution.h:125
itk::ComputeDisplacementDistribution::ImageSampleContainerType
typename ImageGridSamplerType ::ImageSampleContainerType ImageSampleContainerType
Definition itkComputeDisplacementDistribution.h:171
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_ExactGradient
DerivativeType m_ExactGradient
Definition itkComputeDisplacementDistribution.h:150
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_ComputePerThreadVariables
std::vector< AlignedComputePerThreadStruct > m_ComputePerThreadVariables
Definition itkComputeDisplacementDistribution.h:220
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_UseMultiThread
bool m_UseMultiThread
Definition itkComputeDisplacementDistribution.h:223
itk::ComputeDisplacementDistribution::FixedImageType
TFixedImage FixedImageType
Definition itkComputeDisplacementDistribution.h:66
itk::ComputeDisplacementDistribution::ImageSamplerBaseType
ImageSamplerBase< FixedImageType > ImageSamplerBaseType
Definition itkComputeDisplacementDistribution.h:160
itk::ComputeDisplacementDistribution::TransformPointer
typename TransformType::Pointer TransformPointer
Definition itkComputeDisplacementDistribution.h:69
itk::ComputeDisplacementDistribution::CoordinateRepresentationType
typename TransformType::ScalarType CoordinateRepresentationType
Definition itkComputeDisplacementDistribution.h:176
itk::ComputeDisplacementDistribution::ConstPointer
SmartPointer< const Self > ConstPointer
Definition itkComputeDisplacementDistribution.h:57
itk::ComputeDisplacementDistribution::JacobianValueType
typename JacobianType::ValueType JacobianValueType
Definition itkComputeDisplacementDistribution.h:157
itk::ComputeDisplacementDistribution::TransformJacobianType
JacobianType TransformJacobianType
Definition itkComputeDisplacementDistribution.h:175
itk::ComputeDisplacementDistribution< FixedImageType, TransformType >::m_ThreaderParameters
MultiThreaderParameterType m_ThreaderParameters
Definition itkComputeDisplacementDistribution.h:218
itk::ComputeDisplacementDistribution::ImageSamplerBasePointer
typename ImageSamplerBaseType::Pointer ImageSamplerBasePointer
Definition itkComputeDisplacementDistribution.h:161
itk::ComputeDisplacementDistribution::Self
ComputeDisplacementDistribution Self
Definition itkComputeDisplacementDistribution.h:54
itk::ComputeDisplacementDistribution::FixedImageMaskConstPointer
typename FixedImageMaskType::ConstPointer FixedImageMaskConstPointer
Definition itkComputeDisplacementDistribution.h:81
itk::ComputeDisplacementDistribution::BeforeThreadedCompute
virtual void BeforeThreadedCompute(const ParametersType &mu)
itk::ImageFullSampler
Samples all voxels in the InputImageRegion.
Definition itkImageFullSampler.h:39
itk::ImageFullSampler< FixedImageType >::Pointer
SmartPointer< Self > Pointer
Definition itkImageFullSampler.h:46
itk::ImageGridSampler
Samples image voxels on a regular grid.
Definition itkImageGridSampler.h:46
itk::ImageGridSampler< FixedImageType >::Pointer
SmartPointer< Self > Pointer
Definition itkImageGridSampler.h:53
itk::ImageRandomSamplerBase
This class is a base class for any image sampler that randomly picks samples.
Definition itkImageRandomSamplerBase.h:39
itk::ImageRandomSamplerBase< FixedImageType >::Pointer
SmartPointer< Self > Pointer
Definition itkImageRandomSamplerBase.h:46
itk::ImageSamplerBase
This class is a base class for any image sampler.
Definition itkImageSamplerBase.h:44
itk::ImageSamplerBase< FixedImageType >::Pointer
SmartPointer< Self > Pointer
Definition itkImageSamplerBase.h:51
itk::ScaledSingleValuedCostFunction::Pointer
SmartPointer< Self > Pointer
Definition itkScaledSingleValuedCostFunction.h:47
itk::ScaledSingleValuedNonLinearOptimizer::ScaledSingleValuedNonLinearOptimizer
ScaledSingleValuedNonLinearOptimizer()
itk::ScaledSingleValuedNonLinearOptimizer::ScalesType
NonLinearOptimizer::ScalesType ScalesType
Definition itkScaledSingleValuedNonLinearOptimizer.h:85
itkImageFullSampler.h
itkImageGridSampler.h
itkImageRandomCoordinateSampler.h
itkImageRandomSamplerBase.h
itkScaledSingleValuedNonLinearOptimizer.h
itk
Definition itkAdvancedImageToImageMetric.h:43
itk::ComputeDisplacementDistribution::ComputePerThreadStruct
Definition itkComputeDisplacementDistribution.h:207
itk::ComputeDisplacementDistribution::ComputePerThreadStruct::st_DisplacementSquared
double st_DisplacementSquared
Definition itkComputeDisplacementDistribution.h:211
itk::ComputeDisplacementDistribution::ComputePerThreadStruct::st_Displacement
double st_Displacement
Definition itkComputeDisplacementDistribution.h:210
itk::ComputeDisplacementDistribution::ComputePerThreadStruct::st_NumberOfPixelsCounted
SizeValueType st_NumberOfPixelsCounted
Definition itkComputeDisplacementDistribution.h:212
itk::ComputeDisplacementDistribution::ComputePerThreadStruct::st_MaxJJ
double st_MaxJJ
Definition itkComputeDisplacementDistribution.h:209
itk::ComputeDisplacementDistribution::MultiThreaderParameterType
Definition itkComputeDisplacementDistribution.h:203
itk::ComputeDisplacementDistribution::MultiThreaderParameterType::st_Self
Self * st_Self
Definition itkComputeDisplacementDistribution.h:204

Generated on 1768596610 for elastix by 1.15.0 |