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  using namespace itk;
29 
30 
168 template <class TElastix>
171  public OptimizerBase<TElastix>
172 {
173 public:
174 
179  typedef SmartPointer<Self> Pointer;
180  typedef SmartPointer<const Self> ConstPointer;
181 
183  itkNewMacro( Self );
184 
186  itkTypeMacro( AdaptiveStochasticGradientDescent,
188 
193  elxClassNameMacro( "AdaptiveStochasticGradientDescent" );
194 
197  typedef Superclass1::CostFunctionPointer CostFunctionPointer;
199 
208 
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( ExceptionObject & err );
234 
244  itkSetMacro( AutomaticParameterEstimation, bool );
245  itkGetConstMacro( AutomaticParameterEstimation, bool );
246 
248  itkSetMacro( MaximumStepLength, double );
249  itkGetConstMacro( MaximumStepLength, double );
250 
252  itkSetMacro( MaximumNumberOfSamplingAttempts, unsigned long );
253 
255  itkGetConstReferenceMacro( MaximumNumberOfSamplingAttempts, unsigned long );
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 AdvancedTransform<
300  itkGetStaticConstMacro(FixedImageDimension),
301  itkGetStaticConstMacro(MovingImageDimension) > AdvancedTransformType;
302  typedef typename
304 
307 
309  SettingsVectorType m_SettingsVector;
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 
354  virtual void SampleFixedImageForJacobianTerms(
355  ImageSampleContainerPointer & sampleContainer );
356 
360  virtual void ComputeJacobianTerms( double & TrC, double & TrCC,
361  double & maxJJ, double & maxJCJ );
362 
366  virtual void GetScaledDerivativeWithExceptionHandling(
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 
389  unsigned long m_MaxBandCovSize;
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
#define elxClassNameMacro(_name)
Definition: elxMacro.h:254
SmartPointer< Self > Pointer
itk::ImageSamplerBase< FixedImageType > ImageSamplerBaseType
A gradient descent optimizer with an adaptive gain.
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
AdvancedTransform< CoordinateRepresentationType, itkGetStaticConstMacro(FixedImageDimension), itkGetStaticConstMacro(MovingImageDimension) > AdvancedTransformType
Superclass::ElastixPointer ElastixPointer
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.
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


Generated on 05-12-2013 for elastix by doxygen 1.8.5 elastix logo