go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkComputeDisplacementDistribution.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 itkComputeDisplacementDistribution_h
19#define itkComputeDisplacementDistribution_h
20
22
23#include "itkImageGridSampler.h"
26#include "itkImageFullSampler.h"
27#include "itkPlatformMultiThreader.h"
28
29#include <vector>
30
31namespace itk
32{
47template <class TFixedImage, class TTransform>
49{
50public:
52
56 using Pointer = SmartPointer<Self>;
57 using ConstPointer = SmartPointer<const Self>;
58
60 itkNewMacro(Self);
61
64
66 using FixedImageType = TFixedImage;
67 using FixedImagePixelType = typename FixedImageType::PixelType;
68 using TransformType = TTransform;
69 using TransformPointer = typename TransformType::Pointer;
70 using FixedImageRegionType = typename FixedImageType::RegionType;
71 using Superclass::ParametersType;
72 using Superclass::DerivativeType;
74
78 itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension);
79 using FixedImageMaskType = SpatialObject<Self::FixedImageDimension>;
80 using FixedImageMaskPointer = typename FixedImageMaskType::Pointer;
81 using FixedImageMaskConstPointer = typename FixedImageMaskType::ConstPointer;
82 using NonZeroJacobianIndicesType = typename TransformType::NonZeroJacobianIndicesType;
83
85 itkSetConstObjectMacro(FixedImage, FixedImageType);
86
88 itkSetObjectMacro(Transform, TransformType);
89
91 itkSetObjectMacro(FixedImageMask, FixedImageMaskType);
92 itkSetConstObjectMacro(FixedImageMask, FixedImageMaskType);
93 itkGetConstObjectMacro(FixedImageMask, FixedImageMaskType);
94
96 itkSetMacro(NumberOfJacobianMeasurements, SizeValueType);
97
99 void
101 {
102 if (region != this->m_FixedImageRegion)
103 {
104 this->m_FixedImageRegion = region;
105 }
106 }
107
108
110 itkGetConstReferenceMacro(FixedImageRegion, FixedImageRegionType);
111
113 virtual void
114 Compute(const ParametersType & mu, double & jacg, double & maxJJ, std::string method);
115
117 virtual void
118 ComputeSingleThreaded(const ParametersType & mu, double & jacg, double & maxJJ, std::string method);
119
120 virtual void
121 ComputeUsingSearchDirection(const ParametersType & mu, double & jacg, double & maxJJ, std::string methods);
122
124 void
125 SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
126 {
127 this->m_Threader->SetNumberOfWorkUnits(numberOfThreads);
128 }
129
130
131 virtual void
132 BeforeThreadedCompute(const ParametersType & mu);
133
134 virtual void
135 AfterThreadedCompute(double & jacg, double & maxJJ);
136
137protected:
140
142 using ThreaderType = itk::PlatformMultiThreader;
143 using ThreadInfoType = ThreaderType::WorkUnitInfo;
144
145 typename FixedImageType::ConstPointer m_FixedImage;
151 DerivativeType m_ExactGradient;
152 SizeValueType m_NumberOfParameters;
153 ThreaderType::Pointer m_Threader;
154
155 using FixedImageIndexType = typename FixedImageType::IndexType;
156 using FixedImagePointType = typename FixedImageType::PointType;
157 using JacobianType = typename TransformType::JacobianType;
158 using JacobianValueType = typename JacobianType::ValueType;
159
163
166
169
172 using ImageSampleContainerType = typename ImageGridSamplerType ::ImageSampleContainerType;
173 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
174
177 using CoordinateRepresentationType = typename TransformType::ScalarType;
178 using NumberOfParametersType = typename TransformType::NumberOfParametersType;
179
181 // \todo: note that this is an exact copy of itk::ComputeJacobianTerms
182 // in the future it would be better to refactoring this part of the code
183 virtual void
185
187 void
189
191 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
193
195 virtual void
196 ThreadedCompute(ThreadIdType threadID);
197
199 virtual void
201
204 {
206 };
208 {
210 double st_MaxJJ;
214 };
215 itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct);
216 itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct);
217
218private:
220
221 mutable std::vector<AlignedComputePerThreadStruct> m_ComputePerThreadVariables;
222
226};
227
228} // end namespace itk
229
230#ifndef ITK_MANUAL_INSTANTIATION
231# include "itkComputeDisplacementDistribution.hxx"
232#endif
233
234#endif // end #ifndef itkComputeDisplacementDistribution_h
This is a helper class for the automatic parameter estimation of the ASGD optimizer.
typename ImageFullSamplerType::Pointer ImageFullSamplerPointer
typename FixedImageType::PointType FixedImagePointType
typename FixedImageType::PixelType FixedImagePixelType
virtual void Compute(const ParametersType &mu, double &jacg, double &maxJJ, std::string method)
typename FixedImageMaskType::Pointer FixedImageMaskPointer
virtual void ComputeSingleThreaded(const ParametersType &mu, double &jacg, double &maxJJ, std::string method)
typename ImageGridSamplerType::Pointer ImageGridSamplerPointer
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct)
virtual void ThreadedCompute(ThreadIdType threadID)
typename FixedImageType::IndexType FixedImageIndexType
itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension)
typename TransformType::JacobianType JacobianType
virtual void SampleFixedImageForJacobianTerms(ImageSampleContainerPointer &sampleContainer)
virtual void ComputeUsingSearchDirection(const ParametersType &mu, double &jacg, double &maxJJ, std::string methods)
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct)
typename ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ComputeThreaderCallback(void *arg)
virtual void AfterThreadedCompute(double &jacg, double &maxJJ)
void SetFixedImageRegion(const FixedImageRegionType &region)
ScaledSingleValuedCostFunction::Pointer m_CostFunction
typename FixedImageType::RegionType FixedImageRegionType
ITK_DISALLOW_COPY_AND_MOVE(ComputeDisplacementDistribution)
~ComputeDisplacementDistribution() override=default
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
SpatialObject< Self::FixedImageDimension > FixedImageMaskType
typename TransformType::NumberOfParametersType NumberOfParametersType
typename TransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
void SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
typename ImageGridSamplerType ::ImageSampleContainerType ImageSampleContainerType
std::vector< AlignedComputePerThreadStruct > m_ComputePerThreadVariables
typename TransformType::ScalarType CoordinateRepresentationType
typename ImageSamplerBaseType::Pointer ImageSamplerBasePointer
typename FixedImageMaskType::ConstPointer FixedImageMaskConstPointer
virtual void BeforeThreadedCompute(const ParametersType &mu)
Samples all voxels in the InputImageRegion.
Samples image voxels on a regular grid.
This class is a base class for any image sampler that randomly picks samples.
This class is a base class for any image sampler.


Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo