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 "itkMultiThreaderBase.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;
321 using typename Superclass2::SettingsType;
322 using typename Superclass2::SettingsVectorType;
324
333
338 using ImageRadomSampleContainerPointer = typename ImageRadomSampleContainerType::Pointer;
339
344 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
345
347 using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
348
351 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
352 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
353 using CoordinateRepresentationType = typename TransformType::ScalarType;
357
360
363
368
371
373 typename RandomGeneratorType::Pointer m_RandomGenerator;
374
376
381 virtual void
383
388 virtual void
390
394 virtual void
396
404 virtual void
405 SampleGradients(const ParametersType & mu0, double perturbationSigma, double & gg, double & ee);
406
410 virtual void
411 GetScaledDerivativeWithExceptionHandling(const ParametersType & parameters, DerivativeType & derivative);
412
416 virtual void
417 AddRandomPerturbation(ParametersType & parameters, double sigma);
418
419 DerivativeType m_ExactGradient;
420 DerivativeType m_MeanGradient;
421
423
424private:
426
427 // multi-threaded AdvanceOneStep:
433
435 static itk::ITK_THREAD_RETURN_TYPE
437
439 inline void
441
444
450
452
458
463
464}; // end class AdaptiveStochasticVarianceReducedGradient
465
466
467} // end namespace elastix
468
469#ifndef ITK_MANUAL_INSTANTIATION
470# include "elxAdaptiveStochasticVarianceReducedGradient.hxx"
471#endif
472
473#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)
typename ImageRadomSampleContainerType::Pointer ImageRadomSampleContainerPointer
typename std::vector< SettingsType > SettingsVectorType
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
typename std::vector< SettingsType > SettingsVectorType
typename ITKBaseType::ParametersType ParametersType
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 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo