go home Home | Main Page | Topics | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Loading...
Searching...
No Matches
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{
191
192template <typename 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
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;
319 using JacobianValueType = typename JacobianType::ValueType;
320 using typename Superclass2::SettingsType;
321 using typename Superclass2::SettingsVectorType;
323
332
337 using ImageRadomSampleContainerPointer = typename ImageRadomSampleContainerType::Pointer;
338
343 using ImageSampleContainerPointer = typename ImageSampleContainerType::Pointer;
344
346 using RandomGeneratorType = itk::Statistics::MersenneTwisterRandomVariateGenerator;
347
350 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
351 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
352 using CoordinateRepresentationType = typename TransformType::ScalarType;
356
359
362
367
370
372
377 virtual void
379
384 virtual void
386
390 virtual void
392
400 virtual void
401 SampleGradients(const ParametersType & mu0, double perturbationSigma, double & gg, double & ee);
402
406 virtual void
407 GetScaledDerivativeWithExceptionHandling(const ParametersType & parameters, DerivativeType & derivative);
408
412 virtual void
413 AddRandomPerturbation(ParametersType & parameters, double sigma);
414
415 DerivativeType m_ExactGradient;
416 DerivativeType m_MeanGradient;
417
419
420private:
422
423 // multi-threaded AdvanceOneStep:
429
431 static itk::ITK_THREAD_RETURN_TYPE
433
435 inline void
437
440
446
448
454
459
460}; // end class AdaptiveStochasticVarianceReducedGradient
461
462
463} // end namespace elastix
464
465#ifndef ITK_MANUAL_INSTANTIATION
466# include "elxAdaptiveStochasticVarianceReducedGradient.hxx"
467#endif
468
469#endif // end #ifndef elxAdaptiveStochasticVarianceReducedGradient_h
void ThreadedAdvanceOneStep(ThreadIdType threadId, ParametersType &newPosition)
itk::ImageRandomCoordinateSampler< FixedImageType > ImageRandomCoordinateSamplerType
void MetricErrorResponse(itk::ExceptionObject &err) override
virtual void GetScaledDerivativeWithExceptionHandling(const ParametersType &parameters, DerivativeType &derivative)
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
itkOverrideGetNameOfClassMacro(AdaptiveStochasticVarianceReducedGradient)
itk::ComputeDisplacementDistribution< FixedImageType, TransformType > ComputeDisplacementDistributionType
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)
itk::AdvancedTransform< CoordinateRepresentationType, Self::FixedImageDimension, Self::MovingImageDimension > AdvancedTransformType
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
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.
This is a helper class for the automatic parameter estimation of the ASGD optimizer.
Samples image voxels on a regular grid.
VectorDataContainer< ImageSampleType > ImageSampleContainerType
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.
This class is a base class for any image sampler.
VectorDataContainer< ImageSampleType > ImageSampleContainerType
ImageSample< InputImageType > ImageSampleType


Generated on 1774142652 for elastix by doxygen 1.15.0 elastix logo