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 "itkMultiThreader.h"
28 
29 namespace itk
30 {
45 template< class TFixedImage, class TTransform >
48 {
49 public:
50 
55  typedef SmartPointer< const Self > ConstPointer;
56 
58  itkNewMacro( Self );
59 
61  itkTypeMacro( ComputeDisplacementDistribution,
63 
65  typedef TFixedImage FixedImageType;
66  typedef typename FixedImageType::PixelType FixedImagePixelType;
67  typedef TTransform TransformType;
68  typedef typename TransformType::Pointer TransformPointer;
69  typedef typename FixedImageType::RegionType FixedImageRegionType;
73 
77  itkStaticConstMacro( FixedImageDimension, unsigned int,
78  TFixedImage::ImageDimension );
79  typedef SpatialObject< itkGetStaticConstMacro( FixedImageDimension ) > FixedImageMaskType;
80  typedef typename FixedImageMaskType::Pointer FixedImageMaskPointer;
81  typedef typename FixedImageMaskType::ConstPointer FixedImageMaskConstPointer;
82  typedef typename TransformType::NonZeroJacobianIndicesType 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 
100  {
101  if( region != this->m_FixedImageRegion )
102  {
103  this->m_FixedImageRegion = region;
104  }
105  }
106 
107 
109  itkGetConstReferenceMacro( FixedImageRegion, FixedImageRegionType );
110 
112  virtual void Compute( const ParametersType & mu,
113  double & jacg, double & maxJJ, std::string method );
114 
116  virtual void ComputeSingleThreaded( const ParametersType & mu,
117  double & jacg, double & maxJJ, std::string method );
118 
119  virtual void ComputeUsingSearchDirection( const ParametersType & mu,
120  double & jacg, double & maxJJ, std::string methods );
121 
123  void SetNumberOfThreads( ThreadIdType numberOfThreads )
124  {
125  this->m_Threader->SetNumberOfThreads( numberOfThreads );
126  }
127 
128 
129  virtual void BeforeThreadedCompute( const ParametersType & mu );
130 
131  virtual void AfterThreadedCompute( double & jacg, double & maxJJ );
132 
133 protected:
134 
137 
139  typedef itk::MultiThreader ThreaderType;
140  typedef ThreaderType::ThreadInfoStruct ThreadInfoType;
141 
142  typename FixedImageType::ConstPointer m_FixedImage;
149  SizeValueType m_NumberOfParameters;
150  ThreaderType::Pointer m_Threader;
151 
152  typedef typename FixedImageType::IndexType FixedImageIndexType;
153  typedef typename FixedImageType::PointType FixedImagePointType;
154  typedef typename TransformType::JacobianType JacobianType;
155  typedef typename JacobianType::ValueType JacobianValueType;
156 
160 
163 
166 
169  typedef typename ImageGridSamplerType
171  typedef typename ImageSampleContainerType::Pointer ImageSampleContainerPointer;
172 
175  typedef typename TransformType::ScalarType CoordinateRepresentationType;
176  typedef typename TransformType::NumberOfParametersType NumberOfParametersType;
177 
179  // \todo: note that this is an exact copy of itk::ComputeJacobianTerms
180  // in the future it would be better to refactoring this part of the code
182  ImageSampleContainerPointer & sampleContainer );
183 
185  void LaunchComputeThreaderCallback( void ) const;
186 
188  static ITK_THREAD_RETURN_TYPE ComputeThreaderCallback( void * arg );
189 
191  virtual inline void ThreadedCompute( ThreadIdType threadID );
192 
194  virtual void InitializeThreadingParameters( void );
195 
200  {
201  // To give the threads access to all member variables and functions.
203  };
205 
207  {
208  // Used for accumulating derivatives
209  double st_MaxJJ;
213  };
214  itkPadStruct( ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct,
215  PaddedComputePerThreadStruct );
216  itkAlignedTypedef( ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct,
217  AlignedComputePerThreadStruct );
218  mutable AlignedComputePerThreadStruct * m_ComputePerThreadVariables;
220 
221  SizeValueType m_NumberOfPixelsCounted;
225 
226 private:
227 
228  ComputeDisplacementDistribution( const Self & ); // purposely not implemented
229  void operator=( const Self & ); // purposely not implemented
230 
231 };
232 
233 } // end namespace itk
234 
235 #ifndef ITK_MANUAL_INSTANTIATION
236 #include "itkComputeDisplacementDistribution.hxx"
237 #endif
238 
239 #endif // end #ifndef __itkComputeDisplacementDistribution_h
itk::ComputeDisplacementDistribution::m_NumberOfPixelsCounted
SizeValueType m_NumberOfPixelsCounted
Definition: itkComputeDisplacementDistribution.h:221
itk::ComputeDisplacementDistribution::MultiThreaderParameterType::st_Self
Self * st_Self
Definition: itkComputeDisplacementDistribution.h:202
itk::ComputeDisplacementDistribution::ComputePerThreadStruct::st_DisplacementSquared
double st_DisplacementSquared
Definition: itkComputeDisplacementDistribution.h:211
itk::ComputeDisplacementDistribution::TransformPointer
TransformType::Pointer TransformPointer
Definition: itkComputeDisplacementDistribution.h:68
itk::ComputeDisplacementDistribution::ImageRandomSamplerBaseType
ImageRandomSamplerBase< FixedImageType > ImageRandomSamplerBaseType
Definition: itkComputeDisplacementDistribution.h:164
itk::ComputeDisplacementDistribution::FixedImageIndexType
FixedImageType::IndexType FixedImageIndexType
Definition: itkComputeDisplacementDistribution.h:152
itk::ComputeDisplacementDistribution::ImageSamplerBaseType
ImageSamplerBase< FixedImageType > ImageSamplerBaseType
Definition: itkComputeDisplacementDistribution.h:158
itk::ComputeDisplacementDistribution::FixedImagePixelType
FixedImageType::PixelType FixedImagePixelType
Definition: itkComputeDisplacementDistribution.h:66
itk::ComputeDisplacementDistribution::SetNumberOfThreads
void SetNumberOfThreads(ThreadIdType numberOfThreads)
Definition: itkComputeDisplacementDistribution.h:123
itk::ComputeDisplacementDistribution::ComputePerThreadStruct::st_MaxJJ
double st_MaxJJ
Definition: itkComputeDisplacementDistribution.h:209
itk::ComputeDisplacementDistribution::SampleFixedImageForJacobianTerms
virtual void SampleFixedImageForJacobianTerms(ImageSampleContainerPointer &sampleContainer)
itkImageGridSampler.h
SmartPointer< Self >
itk::ComputeDisplacementDistribution::itkAlignedTypedef
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedComputePerThreadStruct, AlignedComputePerThreadStruct)
itk::ComputeDisplacementDistribution::SetFixedImageRegion
void SetFixedImageRegion(const FixedImageRegionType &region)
Definition: itkComputeDisplacementDistribution.h:99
itkImageRandomCoordinateSampler.h
itk::ComputeDisplacementDistribution::Pointer
SmartPointer< Self > Pointer
Definition: itkComputeDisplacementDistribution.h:54
itk::ComputeDisplacementDistribution
This is a helper class for the automatic parameter estimation of the ASGD optimizer.
Definition: itkComputeDisplacementDistribution.h:48
itk::ComputeDisplacementDistribution::m_FixedImageRegion
FixedImageRegionType m_FixedImageRegion
Definition: itkComputeDisplacementDistribution.h:143
itk::ComputeDisplacementDistribution::m_FixedImageMask
FixedImageMaskConstPointer m_FixedImageMask
Definition: itkComputeDisplacementDistribution.h:144
itk::ComputeDisplacementDistribution::m_ExactGradient
DerivativeType m_ExactGradient
Definition: itkComputeDisplacementDistribution.h:148
itk::ComputeDisplacementDistribution::FixedImageMaskConstPointer
FixedImageMaskType::ConstPointer FixedImageMaskConstPointer
Definition: itkComputeDisplacementDistribution.h:81
itk::ComputeDisplacementDistribution::ImageSamplerBasePointer
ImageSamplerBaseType::Pointer ImageSamplerBasePointer
Definition: itkComputeDisplacementDistribution.h:159
itkImageFullSampler.h
itk::ComputeDisplacementDistribution::NonZeroJacobianIndicesType
TransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
Definition: itkComputeDisplacementDistribution.h:82
itk::ComputeDisplacementDistribution::ImageSampleContainerPointer
ImageSampleContainerType::Pointer ImageSampleContainerPointer
Definition: itkComputeDisplacementDistribution.h:171
itk::ComputeDisplacementDistribution::FixedImageMaskType
SpatialObject< itkGetStaticConstMacro(FixedImageDimension) > FixedImageMaskType
Definition: itkComputeDisplacementDistribution.h:79
itk::ComputeDisplacementDistribution::MultiThreaderParameterType
Definition: itkComputeDisplacementDistribution.h:200
itk::ScaledSingleValuedNonLinearOptimizer::DerivativeType
Superclass::DerivativeType DerivativeType
Definition: itkScaledSingleValuedNonLinearOptimizer.h:83
itk::ComputeDisplacementDistribution::ThreaderType
itk::MultiThreader ThreaderType
Definition: itkComputeDisplacementDistribution.h:139
itk::ComputeDisplacementDistribution::m_ComputePerThreadVariablesSize
ThreadIdType m_ComputePerThreadVariablesSize
Definition: itkComputeDisplacementDistribution.h:219
itk::ComputeDisplacementDistribution::JacobianValueType
JacobianType::ValueType JacobianValueType
Definition: itkComputeDisplacementDistribution.h:155
itk::ComputeDisplacementDistribution::m_ComputePerThreadVariables
AlignedComputePerThreadStruct * m_ComputePerThreadVariables
Definition: itkComputeDisplacementDistribution.h:218
itk::ComputeDisplacementDistribution::ParametersType
Superclass::ParametersType ParametersType
Definition: itkComputeDisplacementDistribution.h:70
itk::ImageFullSampler
Samples all voxels in the InputImageRegion.
Definition: itkImageFullSampler.h:39
itk::ComputeDisplacementDistribution::ComputeSingleThreaded
virtual void ComputeSingleThreaded(const ParametersType &mu, double &jacg, double &maxJJ, std::string method)
itk::ComputeDisplacementDistribution::FixedImageMaskPointer
FixedImageMaskType::Pointer FixedImageMaskPointer
Definition: itkComputeDisplacementDistribution.h:80
itk::ComputeDisplacementDistribution::InitializeThreadingParameters
virtual void InitializeThreadingParameters(void)
itk::ComputeDisplacementDistribution::TransformJacobianType
JacobianType TransformJacobianType
Definition: itkComputeDisplacementDistribution.h:174
itk::ComputeDisplacementDistribution::DerivativeType
Superclass::DerivativeType DerivativeType
Definition: itkComputeDisplacementDistribution.h:71
itk::ComputeDisplacementDistribution::FixedImageRegionType
FixedImageType::RegionType FixedImageRegionType
Definition: itkComputeDisplacementDistribution.h:69
itk::ComputeDisplacementDistribution::JacobianType
TransformType::JacobianType JacobianType
Definition: itkComputeDisplacementDistribution.h:154
itk::ComputeDisplacementDistribution::itkPadStruct
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, ComputePerThreadStruct, PaddedComputePerThreadStruct)
itkScaledSingleValuedNonLinearOptimizer.h
itk::ComputeDisplacementDistribution::AfterThreadedCompute
virtual void AfterThreadedCompute(double &jacg, double &maxJJ)
itk::ComputeDisplacementDistribution::FixedImagePointType
FixedImageType::PointType FixedImagePointType
Definition: itkComputeDisplacementDistribution.h:153
itk::ComputeDisplacementDistribution::ImageGridSamplerType
ImageGridSampler< FixedImageType > ImageGridSamplerType
Definition: itkComputeDisplacementDistribution.h:167
ThreadIdType
itk::ComputeDisplacementDistribution::m_SampleContainer
ImageSampleContainerPointer m_SampleContainer
Definition: itkComputeDisplacementDistribution.h:224
itk::ComputeDisplacementDistribution::ScalesType
Superclass::ScalesType ScalesType
Definition: itkComputeDisplacementDistribution.h:72
itk::ScaledSingleValuedNonLinearOptimizer
Definition: itkScaledSingleValuedNonLinearOptimizer.h:64
itk::ComputeDisplacementDistribution::ComputePerThreadStruct::st_Displacement
double st_Displacement
Definition: itkComputeDisplacementDistribution.h:210
itk::ComputeDisplacementDistribution::ComputeThreaderCallback
static ITK_THREAD_RETURN_TYPE ComputeThreaderCallback(void *arg)
itk::ComputeDisplacementDistribution::ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkComputeDisplacementDistribution.h:55
itk::ComputeDisplacementDistribution::Self
ComputeDisplacementDistribution Self
Definition: itkComputeDisplacementDistribution.h:52
itk::ComputeDisplacementDistribution::m_NumberOfParameters
SizeValueType m_NumberOfParameters
Definition: itkComputeDisplacementDistribution.h:149
itk::ComputeDisplacementDistribution::ImageFullSamplerPointer
ImageFullSamplerType::Pointer ImageFullSamplerPointer
Definition: itkComputeDisplacementDistribution.h:162
itk::ComputeDisplacementDistribution::ImageSampleContainerType
ImageGridSamplerType ::ImageSampleContainerType ImageSampleContainerType
Definition: itkComputeDisplacementDistribution.h:170
itk::ComputeDisplacementDistribution::ComputeDisplacementDistribution
ComputeDisplacementDistribution(const Self &)
itk::ComputeDisplacementDistribution::BeforeThreadedCompute
virtual void BeforeThreadedCompute(const ParametersType &mu)
itk::ComputeDisplacementDistribution::TransformType
TTransform TransformType
Definition: itkComputeDisplacementDistribution.h:67
itk::ComputeDisplacementDistribution::itkStaticConstMacro
itkStaticConstMacro(FixedImageDimension, unsigned int, TFixedImage::ImageDimension)
itkImageRandomSamplerBase.h
itk::ComputeDisplacementDistribution::~ComputeDisplacementDistribution
virtual ~ComputeDisplacementDistribution()
itk::ComputeDisplacementDistribution::ComputePerThreadStruct
Definition: itkComputeDisplacementDistribution.h:207
itk::ComputeDisplacementDistribution::NumberOfParametersType
TransformType::NumberOfParametersType NumberOfParametersType
Definition: itkComputeDisplacementDistribution.h:176
itk::ComputeDisplacementDistribution::LaunchComputeThreaderCallback
void LaunchComputeThreaderCallback(void) const
itk::ComputeDisplacementDistribution::ImageFullSamplerType
ImageFullSampler< FixedImageType > ImageFullSamplerType
Definition: itkComputeDisplacementDistribution.h:161
itk
Definition: itkAdvancedImageToImageMetric.h:40
itk::ComputeDisplacementDistribution::m_CostFunction
ScaledSingleValuedCostFunction::Pointer m_CostFunction
Definition: itkComputeDisplacementDistribution.h:146
itk::ScaledSingleValuedNonLinearOptimizer::ParametersType
Superclass::ParametersType ParametersType
Definition: itkScaledSingleValuedNonLinearOptimizer.h:82
itk::ComputeDisplacementDistribution::m_ThreaderParameters
MultiThreaderParameterType m_ThreaderParameters
Definition: itkComputeDisplacementDistribution.h:204
itk::ComputeDisplacementDistribution::ThreadInfoType
ThreaderType::ThreadInfoStruct ThreadInfoType
Definition: itkComputeDisplacementDistribution.h:140
itk::ComputeDisplacementDistribution::ImageGridSamplerPointer
ImageGridSamplerType::Pointer ImageGridSamplerPointer
Definition: itkComputeDisplacementDistribution.h:168
itk::ComputeDisplacementDistribution::Superclass
ScaledSingleValuedNonLinearOptimizer Superclass
Definition: itkComputeDisplacementDistribution.h:53
itk::ComputeDisplacementDistribution::m_NumberOfJacobianMeasurements
SizeValueType m_NumberOfJacobianMeasurements
Definition: itkComputeDisplacementDistribution.h:147
itk::ComputeDisplacementDistribution::ComputeUsingSearchDirection
virtual void ComputeUsingSearchDirection(const ParametersType &mu, double &jacg, double &maxJJ, std::string methods)
itk::ComputeDisplacementDistribution::Compute
virtual void Compute(const ParametersType &mu, double &jacg, double &maxJJ, std::string method)
itk::ComputeDisplacementDistribution::m_Threader
ThreaderType::Pointer m_Threader
Definition: itkComputeDisplacementDistribution.h:150
itk::ComputeDisplacementDistribution::CoordinateRepresentationType
TransformType::ScalarType CoordinateRepresentationType
Definition: itkComputeDisplacementDistribution.h:175
itk::ComputeDisplacementDistribution::ComputeDisplacementDistribution
ComputeDisplacementDistribution()
itk::ComputeDisplacementDistribution::m_Transform
TransformPointer m_Transform
Definition: itkComputeDisplacementDistribution.h:145
itk::ComputeDisplacementDistribution::m_UseMultiThread
bool m_UseMultiThread
Definition: itkComputeDisplacementDistribution.h:222
itk::ImageSamplerBase
This class is a base class for any image sampler.
Definition: itkImageSamplerBase.h:45
itk::ImageGridSampler::ImageSampleContainerType
Superclass::ImageSampleContainerType ImageSampleContainerType
Definition: itkImageGridSampler.h:71
itk::ImageGridSampler
Samples image voxels on a regular grid.
Definition: itkImageGridSampler.h:46
itk::ComputeDisplacementDistribution::m_Scales
ScalesType m_Scales
Definition: itkComputeDisplacementDistribution.h:223
itk::ScaledSingleValuedNonLinearOptimizer::ScalesType
NonLinearOptimizer::ScalesType ScalesType
Definition: itkScaledSingleValuedNonLinearOptimizer.h:86
itk::ComputeDisplacementDistribution::m_FixedImage
FixedImageType::ConstPointer m_FixedImage
Definition: itkComputeDisplacementDistribution.h:142
itk::ComputeDisplacementDistribution::ComputePerThreadStruct::st_NumberOfPixelsCounted
SizeValueType st_NumberOfPixelsCounted
Definition: itkComputeDisplacementDistribution.h:212
itk::ComputeDisplacementDistribution::FixedImageType
TFixedImage FixedImageType
Definition: itkComputeDisplacementDistribution.h:62
itk::ComputeDisplacementDistribution::ThreadedCompute
virtual void ThreadedCompute(ThreadIdType threadID)
itk::ImageRandomSamplerBase
This class is a base class for any image sampler that randomly picks samples.
Definition: itkImageRandomSamplerBase.h:38
itk::ComputeDisplacementDistribution::operator=
void operator=(const Self &)
itk::ComputeDisplacementDistribution::ImageRandomSamplerBasePointer
ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
Definition: itkComputeDisplacementDistribution.h:165


Generated on OURCE_DATE_EPOCH for elastix by doxygen 1.8.18 elastix logo