Skip to content

Commit 7021a23

Browse files
committed
ENH: Add m_RandomVariateGenerator
1 parent 55ff8b5 commit 7021a23

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Common/CostFunctions/itkAdvancedImageToImageMetric.h

+10
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ class ITK_TEMPLATE_EXPORT AdvancedImageToImageMetric : public ImageToImageMetric
317317
virtual void
318318
BeforeThreadedGetValueAndDerivative(const TransformParametersType & parameters) const;
319319

320+
itkSetMacro(RandomVariateGenerator, Statistics::MersenneTwisterRandomVariateGenerator *);
321+
320322
protected:
321323
/** Constructor. */
322324
AdvancedImageToImageMetric();
@@ -598,6 +600,12 @@ class ITK_TEMPLATE_EXPORT AdvancedImageToImageMetric : public ImageToImageMetric
598600
itkExceptionMacro("Intentionally left unimplemented!");
599601
}
600602

603+
auto *
604+
GetRandomVariateGenerator()
605+
{
606+
return m_RandomVariateGenerator;
607+
}
608+
601609
// Protected using-declaration, to avoid `-Woverloaded-virtual` warnings from GCC (GCC 11.4) or clang (macos-12).
602610
using Superclass::SetTransform;
603611

@@ -627,6 +635,8 @@ class ITK_TEMPLATE_EXPORT AdvancedImageToImageMetric : public ImageToImageMetric
627635

628636
MovingImageDerivativeScalesType m_MovingImageDerivativeScales{ MovingImageDerivativeScalesType::Filled(1.0) };
629637

638+
Statistics::MersenneTwisterRandomVariateGenerator * m_RandomVariateGenerator{ nullptr };
639+
630640
// Private using-declarations, to avoid `-Woverloaded-virtual` warnings from GCC (GCC 11.4) or clang (macos-12).
631641
using Superclass::TransformPoint;
632642

Common/ImageSamplers/itkImageRandomSamplerBase.h

+10
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ class ITK_TEMPLATE_EXPORT ImageRandomSamplerBase : public ImageSamplerBase<TInpu
9494
return m_OptionalSeed;
9595
}
9696

97+
itkSetMacro(RandomVariateGenerator, Statistics::MersenneTwisterRandomVariateGenerator *);
98+
9799
/** The input image dimension. */
98100
itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
99101

@@ -108,6 +110,12 @@ class ITK_TEMPLATE_EXPORT ImageRandomSamplerBase : public ImageSamplerBase<TInpu
108110
void
109111
GenerateRandomNumberList();
110112

113+
auto *
114+
GetRandomVariateGenerator()
115+
{
116+
return m_RandomVariateGenerator;
117+
}
118+
111119
/** PrintSelf. */
112120
void
113121
PrintSelf(std::ostream & os, Indent indent) const override;
@@ -117,6 +125,8 @@ class ITK_TEMPLATE_EXPORT ImageRandomSamplerBase : public ImageSamplerBase<TInpu
117125

118126
private:
119127
std::optional<SeedIntegerType> m_OptionalSeed{};
128+
129+
Statistics::MersenneTwisterRandomVariateGenerator * m_RandomVariateGenerator{ nullptr };
120130
};
121131

122132
} // end namespace itk

Core/Kernel/elxElastixMain.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#define elxElastixMain_h
2020

2121
#include "elxMainBase.h"
22-
22+
#include "elxDefaultConstruct.h"
23+
#include <itkMersenneTwisterRandomVariateGenerator.h>
2324

2425
namespace elastix
2526
{
@@ -194,6 +195,8 @@ class ElastixMain : public MainBase
194195
ParameterMapType m_TransformParameterMap{};
195196

196197
FlatDirectionCosinesType m_OriginalFixedImageDirectionFlat{};
198+
199+
elx::DefaultConstruct<itk::Statistics::MersenneTwisterRandomVariateGenerator> m_RandomVariateGenerator{};
197200
};
198201

199202
} // end namespace elastix

0 commit comments

Comments
 (0)