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 "itkMultiThreaderBase.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 = ImageMaskSpatialObject<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 ThreadInfoType = MultiThreaderBase::WorkUnitInfo;
143
144 typename FixedImageType::ConstPointer m_FixedImage{};
145 FixedImageRegionType m_FixedImageRegion{};
146 FixedImageMaskConstPointer m_FixedImageMask{};
147 TransformPointer m_Transform{};
149 SizeValueType m_NumberOfJacobianMeasurements{};
150 DerivativeType m_ExactGradient{};
151 SizeValueType m_NumberOfParameters{};
152 MultiThreaderBase::Pointer m_Threader{};
153
154 using FixedImageIndexType = typename FixedImageType::IndexType;
155 using FixedImagePointType = typename FixedImageType::PointType;
156 using JacobianType = typename TransformType::JacobianType;
157 using JacobianValueType = typename JacobianType::ValueType;
158
162
165
168
171 using ImageSampleContainerType = typename ImageGridSamplerType ::ImageSampleContainerType;
172 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
173
176 using CoordinateRepresentationType = typename TransformType::ScalarType;
177 using NumberOfParametersType = typename TransformType::NumberOfParametersType;
178
180 // \todo: note that this is an exact copy of itk::ComputeJacobianTerms
181 // in the future it would be better to refactoring this part of the code
182 virtual void
184
186 void
188
190 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
192
194 virtual void
195 ThreadedCompute(ThreadIdType threadID);
196
198 virtual void
200
214 itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct);
215 itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct);
216
217private:
218 mutable MultiThreaderParameterType m_ThreaderParameters{};
219
220 mutable std::vector<AlignedComputePerThreadStruct> m_ComputePerThreadVariables{};
221
222 SizeValueType m_NumberOfPixelsCounted{};
223 bool m_UseMultiThread{};
224 ImageSampleContainerPointer m_SampleContainer{};
225};
226
227} // end namespace itk
228
229#ifndef ITK_MANUAL_INSTANTIATION
230# include "itkComputeDisplacementDistribution.hxx"
231#endif
232
233#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)
typename FixedImageType::RegionType FixedImageRegionType
ITK_DISALLOW_COPY_AND_MOVE(ComputeDisplacementDistribution)
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
~ComputeDisplacementDistribution() override=default
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
typename TransformType::NumberOfParametersType NumberOfParametersType
typename TransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
void SetNumberOfWorkUnits(ThreadIdType numberOfThreads)
typename ImageGridSamplerType ::ImageSampleContainerType ImageSampleContainerType
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 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo