go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxPreconditionedStochasticGradientDescent.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 __elxPreconditionedStochasticGradientDescent_h
19 #define __elxPreconditionedStochasticGradientDescent_h
20 
21 #include "elxIncludes.h" // include first to avoid MSVS warning
23 #include "itkComputeDisplacementDistribution.h" // For fast step size estimation
24 
25 
27 #include "elxProgressCommand.h"
28 #include "itkAdvancedTransform.h"
29 #include "itkMersenneTwisterRandomVariateGenerator.h"
31 #include "itkImageRandomSampler.h"
32 
33 
34 namespace elastix
35 {
177 template< class TElastix >
180  public OptimizerBase< TElastix >
181 {
182 public:
183 
188  typedef itk::SmartPointer< Self > Pointer;
189  typedef itk::SmartPointer< const Self > ConstPointer;
190 
192  itkNewMacro( Self );
193 
196  VoxelWiseASGDOptimizer );
197 
202  elxClassNameMacro( "PreconditionedStochasticGradientDescent" );
203 
206  typedef Superclass1::CostFunctionPointer CostFunctionPointer;
208 
217  typedef itk::SizeValueType SizeValueType;
218 
221 
225  void BeforeRegistration( void ) override;
226 
227  void BeforeEachResolution( void ) override;
228 
229  void AfterEachResolution( void ) override;
230 
231  void AfterEachIteration( void ) override;
232 
233  void AfterRegistration( void ) override;
234 
238  void StartOptimization( void ) override;
239 
241  void AdvanceOneStep( void ) override;
242 
247  void ResumeOptimization( void ) override;
248 
250  void MetricErrorResponse( itk::ExceptionObject & err ) override;
251 
261  itkSetMacro( AutomaticParameterEstimation, bool );
262  itkGetConstMacro( AutomaticParameterEstimation, bool );
263 
265  itkSetMacro( MaximumStepLength, double );
266  itkGetConstReferenceMacro( MaximumStepLength, double );
267 
269  itkSetClampMacro( RegularizationKappa, double, 0.0, 1.0 );
270  itkGetConstReferenceMacro( RegularizationKappa, double );
271 
273  itkSetMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
274  itkGetConstReferenceMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
275 
276 protected :
277 
280 
282  typedef typename RegistrationType::FixedImageType FixedImageType;
283  typedef typename RegistrationType::MovingImageType MovingImageType;
284 
285  typedef typename FixedImageType::RegionType FixedImageRegionType;
286  typedef typename FixedImageType::IndexType FixedImageIndexType;
287  typedef typename FixedImageType::PointType FixedImagePointType;
288  typedef typename RegistrationType::ITKBaseType itkRegistrationType;
289  typedef typename itkRegistrationType::TransformType TransformType;
290  typedef typename TransformType::JacobianType JacobianType;
291  typedef typename JacobianType::ValueType JacobianValueType;
292  struct SettingsType { double a, A, alpha, fmax, fmin, omega; };
293  typedef typename std::vector< SettingsType > SettingsVectorType;
294  typedef typename ElastixType::FixedImageType OutputImageType;
295 
299 
302 
307  typedef typename
309  typedef
311  typedef typename
317  typedef typename
320 
322  typedef itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType;
323  typedef typename RandomGeneratorType::Pointer RandomGeneratorPointer;
326 
329  itkStaticConstMacro( FixedImageDimension, unsigned int, FixedImageType::ImageDimension );
330  itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension );
331  typedef typename TransformType::ScalarType CoordinateRepresentationType;
332 
333  typedef itk::AdvancedTransform<
335  itkGetStaticConstMacro( FixedImageDimension ),
336  itkGetStaticConstMacro( MovingImageDimension ) > AdvancedTransformType;
338  typedef typename
340 
343  itkGetStaticConstMacro( FixedImageDimension )> AdvancedBSplineDeformableTransformType;
345 
348 
355 
358 
361 
367 
369  virtual void CheckForAdvancedTransform( void );
370 
372  virtual void PrintSettingsVector( const SettingsVectorType & settings ) const;
373 
378  virtual void AutomaticPreconditionerEstimation( void );
379 
387  virtual void SampleGradients( const ParametersType & mu0,
388  double perturbationSigma, double & gg, double & ee );
389 
394  const ParametersType & parameters, DerivativeType & derivative );
395 
399  virtual void AddRandomPerturbation( ParametersType & parameters, double sigma );
400 
401 private:
402 
403  PreconditionedStochasticGradientDescent( const Self & ); // purposely not implemented
404  void operator=( const Self & ); // purposely not implemented
405 
409 
415 
419 
423 
424 };
425 
426 } // end namespace elastix
427 
428 #ifndef ITK_MANUAL_INSTANTIATION
429 #include "elxPreconditionedStochasticGradientDescent.hxx"
430 #endif
431 
432 #endif // end #ifndef __elxPreconditionedStochasticGradientDescent_h
A class that deals with user given parameters and command line arguments.
This class is the elastix base class for all Optimizers.
Superclass::ConfigurationPointer ConfigurationPointer
itk::Optimizer ITKBaseType
Superclass::ElastixType ElastixType
Superclass::ElastixPointer ElastixPointer
Superclass::RegistrationPointer RegistrationPointer
Superclass::RegistrationType RegistrationType
virtual void PrintSettingsVector(const SettingsVectorType &settings) const
itk::ComputeDisplacementDistribution< FixedImageType, TransformType > ComputeDisplacementDistributionType
virtual void GetScaledDerivativeWithExceptionHandling(const ParametersType &parameters, DerivativeType &derivative)
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
itk::ImageRandomSamplerBase< FixedImageType > ImageRandomSamplerBaseType
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
ImageRandomCoordinateSamplerType::Pointer ImageRandomCoordinateSamplerPointer
itk::ImageRandomCoordinateSampler< FixedImageType > ImageRandomCoordinateSamplerType
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
itk::ComputePreconditionerUsingDisplacementDistribution< FixedImageType, TransformType > PreconditionerEstimationType
elxClassNameMacro("PreconditionedStochasticGradientDescent")
AdvancedBSplineDeformableTransformType::Pointer BSplineTransformBasePointer
itk::AdvancedBSplineDeformableTransformBase< CoordinateRepresentationType, itkGetStaticConstMacro(FixedImageDimension)> AdvancedBSplineDeformableTransformType
itk::AdvancedTransform< CoordinateRepresentationType, itkGetStaticConstMacro(FixedImageDimension), itkGetStaticConstMacro(MovingImageDimension) > AdvancedTransformType
void MetricErrorResponse(itk::ExceptionObject &err) override
virtual void AddRandomPerturbation(ParametersType &parameters, double sigma)
A specialized Command object for updating the progress of a filter.
itk::SmartPointer< Self > Pointer
Base class for deformable transform using a B-spline representation.
Transform maps points, vectors and covariant vectors from an input space to an output space.
SmartPointer< Self > Pointer
std::vector< unsigned long > NonZeroJacobianIndicesType
This is a helper class for the automatic parameter estimation of the ASGD optimizer.
This is a helper class for the automatic estimation of a preconditioner for the FPSGD optimizer....
Samples image voxels on a regular grid.
SmartPointer< Self > Pointer
Samples an image by randomly composing a set of physical coordinates.
This class is a base class for any image sampler that randomly picks samples.
Samples randomly some voxels of an image.
SmartPointer< Self > Pointer
This class is a base class for any image sampler.
SmartPointer< Self > Pointer
This class implements a gradient descent optimizer with adaptive gain.
Superclass::StopConditionType StopConditionType
Superclass::CostFunctionType CostFunctionType
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
SmartPointer< Self > Pointer


Generated on 1641078589 for elastix by doxygen 1.9.1 elastix logo