go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxAdaptiveStochasticVarianceReducedGradient.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 __elxAdaptiveStochasticVarianceReducedGradient_h
19 #define __elxAdaptiveStochasticVarianceReducedGradient_h
20 
21 #include "elxIncludes.h" // include first to avoid MSVS warning
23 
24 #include "elxProgressCommand.h"
25 #include "itkAdvancedTransform.h"
26 #include "itkMersenneTwisterRandomVariateGenerator.h"
29 #include "itkPlatformMultiThreader.h"
30 #include "itkImageRandomSampler.h"
31 namespace elastix
32 {
192 template <class TElastix>
195  public OptimizerBase<TElastix>
196 {
197 public:
198 
203  typedef itk::SmartPointer<Self> Pointer;
204  typedef itk::SmartPointer<const Self> ConstPointer;
205 
207  itkNewMacro( Self );
208 
212 
217  elxClassNameMacro( "AdaptiveStochasticVarianceReducedGradient" );
218 
221  typedef Superclass1::CostFunctionPointer CostFunctionPointer;
222  //typedef Superclass1::StopConditionType StopConditionType;
223 
232  typedef itk::SizeValueType SizeValueType;
233 
236 
240  void BeforeRegistration( void ) override;
241  void BeforeEachResolution( void ) override;
242  void AfterEachResolution( void ) override;
243  void AfterEachIteration( void ) override;
244  void AfterRegistration( void ) override;
245 
249  void StartOptimization( void ) override;
250 
252  void AdvanceOneStep( void ) override;
253 
258  void ResumeOptimization( void ) override;
259 
261  void MetricErrorResponse( itk::ExceptionObject & err ) override;
262 
265  void StopOptimization( void ) override;
266 
276  itkSetMacro( AutomaticParameterEstimation, bool );
277  itkGetConstMacro( AutomaticParameterEstimation, bool );
278 
280  itkSetMacro( MaximumStepLength, double );
281  itkGetConstMacro( MaximumStepLength, double );
282 
284  itkSetMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
285 
287  itkGetConstReferenceMacro( MaximumNumberOfSamplingAttempts, SizeValueType );
288 
290  itkGetConstReferenceMacro( MeanGradient, DerivativeType);
291 
293  typedef unsigned int ThreadIdType;
294 
296  void SetNumberOfWorkUnits( ThreadIdType numberOfThreads )
297  {
298  this->m_Threader->SetNumberOfWorkUnits( numberOfThreads );
299  }
300 
301 protected:
302 
304  typedef typename RegistrationType::FixedImageType FixedImageType;
305  typedef typename RegistrationType::MovingImageType MovingImageType;
306 
307  typedef typename FixedImageType::RegionType FixedImageRegionType;
308  typedef typename FixedImageType::IndexType FixedImageIndexType;
309  typedef typename FixedImageType::PointType FixedImagePointType;
310  typedef typename RegistrationType::ITKBaseType itkRegistrationType;
311  typedef typename itkRegistrationType::TransformType TransformType;
312  typedef typename TransformType::JacobianType JacobianType;
315  typedef typename JacobianType::ValueType JacobianValueType;
316  struct SettingsType { double a, A, alpha, fmax, fmin, omega; };
317  typedef typename std::vector<SettingsType> SettingsVectorType;
318 
321 
326  typedef typename
328  typedef
330  typedef typename
333 
337  typedef typename
339  typedef typename
341 
345  typedef typename
348 
350  typedef itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType;
353 
356  itkStaticConstMacro( FixedImageDimension, unsigned int, FixedImageType::ImageDimension );
357  itkStaticConstMacro( MovingImageDimension, unsigned int, MovingImageType::ImageDimension );
358  typedef typename TransformType::ScalarType CoordinateRepresentationType;
359  typedef itk::AdvancedTransform<
361  itkGetStaticConstMacro(FixedImageDimension),
362  itkGetStaticConstMacro(MovingImageDimension) > AdvancedTransformType;
363  typedef typename
365 
368 
371 
376 
379 
381  typename RandomGeneratorType::Pointer m_RandomGenerator;
382 
384 
386  virtual void CheckForAdvancedTransform( void );
387 
389  virtual void PrintSettingsVector( const SettingsVectorType & settings ) const;
390 
395  virtual void AutomaticParameterEstimation( void );
396 
402 
407 
415  virtual void SampleGradients( const ParametersType & mu0,
416  double perturbationSigma, double & gg, double & ee );
417 
422  const ParametersType & parameters, DerivativeType & derivative );
423 
427  virtual void AddRandomPerturbation( ParametersType & parameters, double sigma );
428 
431 
433 
434 private:
435 
436  AdaptiveStochasticVarianceReducedGradient( const Self& ); // purposely not implemented
437  void operator=( const Self& ); // purposely not implemented
438 
439  // multi-threaded AdvanceOneStep:
441  {
444  };
445 
447  static itk::ITK_THREAD_RETURN_TYPE AdvanceOneStepThreaderCallback( void * arg );
448 
450  inline void ThreadedAdvanceOneStep( ThreadIdType threadId, ParametersType & newPosition );
451 
454 
460 
462 
468 
473 
474 }; // end class AdaptiveStochasticVarianceReducedGradient
475 
476 
477 } // end namespace elastix
478 
479 #ifndef ITK_MANUAL_INSTANTIATION
480 #include "elxAdaptiveStochasticVarianceReducedGradient.hxx"
481 #endif
482 
483 #endif // end #ifndef __elxAdaptiveStochasticVarianceReducedGradient_h
itk::ImageRandomCoordinateSampler< FixedImageType > ImageRandomCoordinateSamplerType
itk::AdvancedTransform< CoordinateRepresentationType, itkGetStaticConstMacro(FixedImageDimension), itkGetStaticConstMacro(MovingImageDimension) > AdvancedTransformType
itk::ComputeJacobianTerms< FixedImageType, TransformType > ComputeJacobianTermsType
void ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType &newPosition)
AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
void MetricErrorResponse(itk::ExceptionObject &err) override
virtual void GetScaledDerivativeWithExceptionHandling(const ParametersType &parameters, DerivativeType &derivative)
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
static itk::ITK_THREAD_RETURN_TYPE AdvanceOneStepThreaderCallback(void *arg)
ImageRandomSamplerType::ImageSampleContainerType ImageRadomSampleContainerType
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
virtual void PrintSettingsVector(const SettingsVectorType &settings) const
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
virtual void AutomaticParameterEstimationUsingDisplacementDistribution(void)
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
elxClassNameMacro("AdaptiveStochasticVarianceReducedGradient")
virtual void AddRandomPerturbation(ParametersType &parameters, double sigma)
itk::ComputeDisplacementDistribution< FixedImageType, TransformType > ComputeDisplacementDistributionType
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
A specialized Command object for updating the progress of a filter.
itk::SmartPointer< Self > Pointer
This class implements a gradient descent optimizer with adaptive gain.
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 parameter estimation of the ASGD 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
A class that defines an image sample, which is the coordinates of a point and its value.
This class is a base class for any image sampler.
SmartPointer< Self > Pointer
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
SmartPointer< Self > Pointer


Generated on 1652341256 for elastix by doxygen 1.9.1 elastix logo