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  * 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 __elxAdaptiveStochasticGradientDescent_h
19 #define __elxAdaptiveStochasticGradientDescent_h
20 
21 #include "elxIncludes.h" // include first to avoid MSVS warning
25 #include "elxProgressCommand.h"
26 #include "itkAdvancedTransform.h"
27 #include "itkMersenneTwisterRandomVariateGenerator.h"
28 
29 namespace elastix
30 {
190 template< class TElastix >
193  public OptimizerBase< TElastix >
194 {
195 public:
196 
201  typedef itk::SmartPointer< Self > Pointer;
202  typedef itk::SmartPointer< const Self > ConstPointer;
203 
205  itkNewMacro( Self );
206 
208  itkTypeMacro( AdaptiveStochasticGradientDescent,
210 
215  elxClassNameMacro( "AdaptiveStochasticGradientDescent" );
216 
219  typedef Superclass1::CostFunctionPointer CostFunctionPointer;
221 
230  typedef itk::SizeValueType SizeValueType;
231 
234 
238  virtual void BeforeRegistration( void );
239 
240  virtual void BeforeEachResolution( void );
241 
242  virtual void AfterEachResolution( void );
243 
244  virtual void AfterEachIteration( void );
245 
246  virtual void AfterRegistration( void );
247 
251  virtual void StartOptimization( void );
252 
257  virtual void ResumeOptimization( void );
258 
260  virtual void MetricErrorResponse( itk::ExceptionObject & err );
261 
271  itkSetMacro( AutomaticParameterEstimation, bool );
272  itkGetConstMacro( AutomaticParameterEstimation, bool );
273 
275  itkSetMacro( MaximumStepLength, double );
276  itkGetConstMacro( MaximumStepLength, double );
277 
279  itkSetMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
280 
282  itkGetConstReferenceMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
283 
284 protected:
285 
287  typedef typename RegistrationType::FixedImageType FixedImageType;
288  typedef typename RegistrationType::MovingImageType MovingImageType;
289 
290  typedef typename FixedImageType::RegionType FixedImageRegionType;
291  typedef typename FixedImageType::IndexType FixedImageIndexType;
292  typedef typename FixedImageType::PointType FixedImagePointType;
293  typedef typename RegistrationType::ITKBaseType itkRegistrationType;
294  typedef typename itkRegistrationType::TransformType TransformType;
295  typedef typename TransformType::JacobianType JacobianType;
298  typedef typename JacobianType::ValueType JacobianValueType;
299  struct SettingsType { double a, A, alpha, fmax, fmin, omega; };
300  typedef typename std::vector< SettingsType > SettingsVectorType;
301 
304 
309  typedef typename
311  typedef
313  typedef typename
317  typedef typename
320 
322  typedef itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType;
323  typedef typename RandomGeneratorType::Pointer RandomGeneratorPointer;
326 
328  typedef JacobianType TransformJacobianType;
329  itkStaticConstMacro( FixedImageDimension, unsigned int, FixedImageType::ImageDimension );
330  itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension );
331  typedef typename TransformType::ScalarType CoordinateRepresentationType;
332  typedef itk::AdvancedTransform<
334  itkGetStaticConstMacro( FixedImageDimension ),
335  itkGetStaticConstMacro( MovingImageDimension ) > AdvancedTransformType;
337  typedef typename
339 
342 
344  SettingsVectorType m_SettingsVector;
345 
350 
352  AdvancedTransformPointer m_AdvancedTransform;
353 
355  RandomGeneratorPointer m_RandomGenerator;
356 
358 
360  virtual void CheckForAdvancedTransform( void );
361 
363  virtual void PrintSettingsVector( const SettingsVectorType & settings ) const;
364 
369  virtual void AutomaticParameterEstimation( void );
370 
375  virtual void AutomaticParameterEstimationOriginal( void );
376 
381 
389  virtual void SampleGradients( const ParametersType & mu0,
390  double perturbationSigma, double & gg, double & ee );
391 
396  const ParametersType & parameters, DerivativeType & derivative );
397 
401  virtual void AddRandomPerturbation( ParametersType & parameters, double sigma );
402 
403 private:
404 
405  AdaptiveStochasticGradientDescent( const Self & ); // purposely not implemented
406  void operator=( const Self & ); // purposely not implemented
407 
410 
416 
418  SizeValueType m_MaxBandCovSize;
420 
424 
425 };
426 
427 } // end namespace elastix
428 
429 #ifndef ITK_MANUAL_INSTANTIATION
430 #include "elxAdaptiveStochasticGradientDescent.hxx"
431 #endif
432 
433 #endif // end #ifndef __elxAdaptiveStochasticGradientDescent_h
AdaptiveStochasticGradientDescentOptimizer Superclass1
itk::ComputeDisplacementDistribution< FixedImageType, TransformType > ComputeDisplacementDistributionType
Superclass::RegistrationPointer RegistrationPointer
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
itk::AdvancedTransform< CoordinateRepresentationType, itkGetStaticConstMacro(FixedImageDimension), itkGetStaticConstMacro(MovingImageDimension) > AdvancedTransformType
virtual void AutomaticParameterEstimationUsingDisplacementDistribution(void)
virtual void MetricErrorResponse(itk::ExceptionObject &err)
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.
This is a helper class for the automatic parameter estimation of the ASGD optimizer.
ImageRandomSamplerBaseType::Pointer ImageRandomSamplerBasePointer
itk::ImageRandomSamplerBase< FixedImageType > ImageRandomSamplerBaseType
Superclass::ElastixType ElastixType
Superclass::ConfigurationPointer ConfigurationPointer
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
Superclass::ElastixPointer ElastixPointer
elxClassNameMacro("AdaptiveStochasticGradientDescent")
This class is a base class for any image sampler.
Superclass::ConfigurationType ConfigurationType
virtual void AutomaticParameterEstimationOriginal(void)
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
Transform maps points, vectors and covariant vectors from an input space to an output space...
This class implements a gradient descent optimizer with adaptive gain.
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
itk::SmartPointer< Self > Pointer
This is a helper class for the automatic parameter estimation of the ASGD optimizer.
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
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
itk::ImageSamplerBase< FixedImageType > ImageSamplerBaseType
ImageRandomCoordinateSamplerType::Pointer ImageRandomCoordinateSamplerPointer
Samples image voxels on a regular grid.
itk::ComputeJacobianTerms< FixedImageType, TransformType > ComputeJacobianTermsType
itk::ImageRandomCoordinateSampler< FixedImageType > ImageRandomCoordinateSamplerType


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo