go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxAdaptiveStochasticGradientDescent.h
Go to the documentation of this file.
1 /*======================================================================
2 
3  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 
15 #ifndef __elxAdaptiveStochasticGradientDescent_h
16 #define __elxAdaptiveStochasticGradientDescent_h
17 
19 #include "itkImageGridSampler.h"
21 #include "elxIncludes.h"
22 #include "elxProgressCommand.h"
23 #include "itkAdvancedTransform.h"
24 #include "itkMersenneTwisterRandomVariateGenerator.h"
25 
26 namespace elastix
27 {
28 
29 
167 template <class TElastix>
170  public OptimizerBase<TElastix>
171 {
172 public:
173 
178  typedef itk::SmartPointer<Self> Pointer;
179  typedef itk::SmartPointer<const Self> ConstPointer;
180 
182  itkNewMacro( Self );
183 
185  itkTypeMacro( AdaptiveStochasticGradientDescent,
187 
192  elxClassNameMacro( "AdaptiveStochasticGradientDescent" );
193 
195  typedef Superclass1::CostFunctionType CostFunctionType;
196  typedef Superclass1::CostFunctionPointer CostFunctionPointer;
197  typedef Superclass1::StopConditionType StopConditionType;
198 
207  typedef itk::SizeValueType SizeValueType;
208 
210  typedef typename Superclass1::ParametersType ParametersType;
211 
215  virtual void BeforeRegistration( void );
216  virtual void BeforeEachResolution( void );
217  virtual void AfterEachResolution( void );
218  virtual void AfterEachIteration( void );
219  virtual void AfterRegistration( void );
220 
224  virtual void StartOptimization( void );
225 
230  virtual void ResumeOptimization( void );
231 
233  virtual void MetricErrorResponse( itk::ExceptionObject & err );
234 
244  itkSetMacro( AutomaticParameterEstimation, bool );
245  itkGetConstMacro( AutomaticParameterEstimation, bool );
246 
248  itkSetMacro( MaximumStepLength, double );
249  itkGetConstMacro( MaximumStepLength, double );
250 
252  itkSetMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
253 
255  itkGetConstReferenceMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
256 
257 protected:
258 
260  typedef typename RegistrationType::FixedImageType FixedImageType;
261  typedef typename RegistrationType::MovingImageType MovingImageType;
262  typedef typename FixedImageType::RegionType FixedImageRegionType;
263  typedef typename FixedImageType::IndexType FixedImageIndexType;
264  typedef typename FixedImageType::PointType FixedImagePointType;
265  typedef typename RegistrationType::ITKBaseType itkRegistrationType;
266  typedef typename itkRegistrationType::TransformType TransformType;
267  typedef typename TransformType::JacobianType JacobianType;
268  typedef typename JacobianType::ValueType JacobianValueType;
269  struct SettingsType { double a, A, alpha, fmax, fmin, omega; };
270  typedef typename std::vector<SettingsType> SettingsVectorType;
271 
276  typedef typename
278  typedef
280  typedef typename
284  typedef typename
287 
289  typedef itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType;
292 
295  itkStaticConstMacro( FixedImageDimension, unsigned int, FixedImageType::ImageDimension );
296  itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension );
297  typedef typename TransformType::ScalarType CoordinateRepresentationType;
298  typedef itk::AdvancedTransform<
300  itkGetStaticConstMacro(FixedImageDimension),
301  itkGetStaticConstMacro(MovingImageDimension) > AdvancedTransformType;
302  typedef typename
304 
307 
310 
315 
318 
320  typename RandomGeneratorType::Pointer m_RandomGenerator;
321 
323 
325  virtual void CheckForAdvancedTransform( void );
326 
328  virtual void PrintSettingsVector( const SettingsVectorType & settings ) const;
329 
334  virtual void AutomaticParameterEstimation( void );
335 
343  virtual void SampleGradients( const ParametersType & mu0,
344  double perturbationSigma, double & gg, double & ee );
345 
355  ImageSampleContainerPointer & sampleContainer );
356 
360  virtual void ComputeJacobianTerms( double & TrC, double & TrCC,
361  double & maxJJ, double & maxJCJ );
362 
367  const ParametersType & parameters, DerivativeType & derivative );
368 
372  virtual void AddRandomPerturbation( ParametersType & parameters, double sigma );
373 
374 private:
375 
376  AdaptiveStochasticGradientDescent( const Self& ); // purposely not implemented
377  void operator=( const Self& ); // purposely not implemented
378 
381 
387 
391 
392 }; // end class AdaptiveStochasticGradientDescent
393 
394 
395 } // end namespace elastix
396 
397 #ifndef ITK_MANUAL_INSTANTIATION
398 #include "elxAdaptiveStochasticGradientDescent.hxx"
399 #endif
400 
401 #endif // end #ifndef __elxAdaptiveStochasticGradientDescent_h
AdaptiveStochasticGradientDescentOptimizer Superclass1
itk::ImageRandomSamplerBase< FixedImageType > ImageRandomSamplerBaseType
Superclass::RegistrationPointer RegistrationPointer
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
SmartPointer< Self > Pointer
virtual void MetricErrorResponse(itk::ExceptionObject &err)
itk::ImageSamplerBase< FixedImageType > ImageSamplerBaseType
A gradient descent optimizer with an adaptive gain.
virtual void AddRandomPerturbation(ParametersType &parameters, double sigma)
std::vector< unsigned long > NonZeroJacobianIndicesType
This class is the elastix base class for all Optimizers.
ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
Superclass::ElastixType ElastixType
Superclass::ConfigurationPointer ConfigurationPointer
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
SmartPointer< Self > Pointer
Superclass::ElastixPointer ElastixPointer
elxClassNameMacro("AdaptiveStochasticGradientDescent")
This class is a base class for any image sampler.
Superclass::ConfigurationType ConfigurationType
SmartPointer< Self > Pointer
Define a front-end to the STL &quot;vector&quot; container that conforms to the IndexedContainerInterface.
ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
Transform maps points, vectors and covariant vectors from an input space to an output space...
SmartPointer< Self > Pointer
This class implements a gradient descent optimizer with adaptive gain.
itk::SmartPointer< Self > Pointer
itk::Optimizer ITKBaseType
Samples an image by randomly composing a set of physical coordinates.
virtual void GetScaledDerivativeWithExceptionHandling(const ParametersType &parameters, DerivativeType &derivative)
virtual void PrintSettingsVector(const SettingsVectorType &settings) const
virtual void SampleFixedImageForJacobianTerms(ImageSampleContainerPointer &sampleContainer)
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
virtual void ComputeJacobianTerms(double &TrC, double &TrCC, double &maxJJ, double &maxJCJ)
itk::ImageGridSampler< FixedImageType > ImageGridSamplerType
A specialized Command object for updating the progress of a filter.
This class is a base class for any image sampler that randomly picks samples.
Superclass::RegistrationType RegistrationType
AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
ImageRandomCoordinateSamplerType::Pointer ImageRandomCoordinateSamplerPointer
Samples image voxels on a regular grid.
itk::ImageRandomCoordinateSampler< FixedImageType > ImageRandomCoordinateSamplerType
itk::AdvancedTransform< CoordinateRepresentationType, itkGetStaticConstMacro(FixedImageDimension), itkGetStaticConstMacro(MovingImageDimension) > AdvancedTransformType


Generated on 05-01-2014 for elastix by doxygen 1.8.5 elastix logo