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"
26#include "itkMersenneTwisterRandomVariateGenerator.h"
29#include "itkPlatformMultiThreader.h"
31namespace elastix
32{
192template <class TElastix>
195 , public OptimizerBase<TElastix>
196{
197public:
199
204 using Pointer = itk::SmartPointer<Self>;
205 using ConstPointer = itk::SmartPointer<const Self>;
206
208 itkNewMacro(Self);
209
212
217 elxClassNameMacro("AdaptiveStochasticVarianceReducedGradient");
218
220 using Superclass1::CostFunctionType;
221 using Superclass1::CostFunctionPointer;
222 // using Superclass1::StopConditionType;
223
225 using typename Superclass2::ElastixType;
226 using typename Superclass2::RegistrationType;
228 using SizeValueType = itk::SizeValueType;
229
231 using typename Superclass1::ParametersType;
232
236 void
238 void
240 void
242 void
244 void
246
250 void
252
254 void
255 AdvanceOneStep() override;
256
261 void
263
265 void
266 MetricErrorResponse(itk::ExceptionObject & err) override;
267
270 void
272
282 itkSetMacro(AutomaticParameterEstimation, bool);
283 itkGetConstMacro(AutomaticParameterEstimation, bool);
284
286 itkSetMacro(MaximumStepLength, double);
287 itkGetConstMacro(MaximumStepLength, double);
288
290 itkSetMacro(MaximumNumberOfSamplingAttempts, SizeValueType);
291
293 itkGetConstReferenceMacro(MaximumNumberOfSamplingAttempts, SizeValueType);
294
296 itkGetConstReferenceMacro(MeanGradient, DerivativeType);
297
299 using ThreadIdType = unsigned int;
300
302 void
304 {
305 this->m_Threader->SetNumberOfWorkUnits(numberOfThreads);
306 }
307
308protected:
310 using FixedImageType = typename RegistrationType::FixedImageType;
311 using MovingImageType = typename RegistrationType::MovingImageType;
312
313 using FixedImageRegionType = typename FixedImageType::RegionType;
314 using FixedImageIndexType = typename FixedImageType::IndexType;
315 using FixedImagePointType = typename FixedImageType::PointType;
316 using itkRegistrationType = typename RegistrationType::ITKBaseType;
317 using TransformType = typename itkRegistrationType::TransformType;
318 using JacobianType = typename TransformType::JacobianType;
320 using JacobianValueType = typename JacobianType::ValueType;
322 {
323 double a, A, alpha, fmax, fmin, omega;
324 };
325 using SettingsVectorType = typename std::vector<SettingsType>;
326
328
337
342 using ImageRadomSampleContainerPointer = typename ImageRadomSampleContainerType::Pointer;
343
348 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
349
351 using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
354
357 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
358 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
359 using CoordinateRepresentationType = typename TransformType::ScalarType;
363
366
369
374
377
379 typename RandomGeneratorType::Pointer m_RandomGenerator;
380
382
384 virtual void
386
391 virtual void
393
398 virtual void
400
404 virtual void
406
414 virtual void
415 SampleGradients(const ParametersType & mu0, double perturbationSigma, double & gg, double & ee);
416
420 virtual void
421 GetScaledDerivativeWithExceptionHandling(const ParametersType & parameters, DerivativeType & derivative);
422
426 virtual void
427 AddRandomPerturbation(ParametersType & parameters, double sigma);
428
429 DerivativeType m_ExactGradient;
430 DerivativeType m_MeanGradient;
431
433
434private:
436
437 // multi-threaded AdvanceOneStep:
439 {
442 };
443
445 static itk::ITK_THREAD_RETURN_TYPE
447
449 inline void
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
void ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType &newPosition)
void MetricErrorResponse(itk::ExceptionObject &err) override
virtual void GetScaledDerivativeWithExceptionHandling(const ParametersType &parameters, DerivativeType &derivative)
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
virtual void SampleGradients(const ParametersType &mu0, double perturbationSigma, double &gg, double &ee)
ITK_DISALLOW_COPY_AND_MOVE(AdaptiveStochasticVarianceReducedGradient)
typename ImageRandomCoordinateSamplerType::Pointer ImageRandomCoordinateSamplerPointer
static itk::ITK_THREAD_RETURN_TYPE AdvanceOneStepThreaderCallback(void *arg)
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
virtual void PrintSettingsVector(const SettingsVectorType &settings) const
typename ImageRadomSampleContainerType::Pointer ImageRadomSampleContainerPointer
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
typename ImageRandomSamplerType::ImageSampleContainerType ImageRadomSampleContainerType
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
elxClassNameMacro("AdaptiveStochasticVarianceReducedGradient")
virtual void AddRandomPerturbation(ParametersType &parameters, double sigma)
typename ImageGridSamplerType::ImageSampleContainerType ImageSampleContainerType
This class is the elastix base class for all Optimizers.
typename ElastixType::RegistrationBaseType RegistrationType
itk::Optimizer ITKBaseType
typename ITKBaseType::ParametersType ParametersType
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.
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.
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.
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.
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.


Generated on Wed 12 Apr 2023 for elastix by doxygen 1.9.6 elastix logo