18#ifndef itkMRIBiasFieldCorrectionFilter_h
19#define itkMRIBiasFieldCorrectionFilter_h
50template <
typename TImage,
typename TImageMask,
typename TBiasField>
83 using typename Superclass::ParametersType;
91 static constexpr unsigned int SpaceDimension = 3;
120 for (
unsigned int i = 0; i < SpaceDimension; ++i)
122 m_SamplingFactor[i] = factor[i];
132 return (*m_InternalEnergyFunction)(diff);
234template <
typename TInputImage,
typename TOutputImage,
typename TMaskImage>
254 static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
318#if defined(ITK_LEGACY_REMOVE)
325 m_BiasFieldMultiplicative = flag;
332 itkSetMacro(BiasFieldMultiplicative,
bool);
333 itkGetConstMacro(BiasFieldMultiplicative,
bool);
334 itkBooleanMacro(BiasFieldMultiplicative);
337#if defined(ITK_LEGACY_REMOVE)
342 return m_BiasFieldMultiplicative;
350 itkSetMacro(UsingInterSliceIntensityCorrection,
bool);
351 itkGetConstMacro(UsingInterSliceIntensityCorrection,
bool);
352 itkBooleanMacro(UsingInterSliceIntensityCorrection);
360 itkSetMacro(UsingSlabIdentification,
bool);
361 itkGetConstMacro(UsingSlabIdentification,
bool);
362 itkBooleanMacro(UsingSlabIdentification);
368 itkSetMacro(SlabNumberOfSamples,
unsigned int);
369 itkGetConstReferenceMacro(SlabNumberOfSamples,
unsigned int);
371 itkSetMacro(SlabTolerance,
double);
372 itkGetConstReferenceMacro(SlabTolerance,
double);
379 itkSetMacro(UsingBiasFieldCorrection,
bool);
380 itkGetConstMacro(UsingBiasFieldCorrection,
bool);
381 itkBooleanMacro(UsingBiasFieldCorrection);
386 itkSetMacro(GeneratingOutput,
bool);
387 itkGetConstMacro(GeneratingOutput,
bool);
388 itkBooleanMacro(GeneratingOutput);
393 itkSetMacro(SlicingDirection,
int);
394 itkGetConstMacro(SlicingDirection,
int);
398 itkSetMacro(BiasFieldDegree,
int);
399 itkGetConstMacro(BiasFieldDegree,
int);
408 m_BiasFieldCoefficients = coefficients;
415 BiasFieldType::CoefficientArrayType
418 return m_EstimatedBiasFieldCoefficients;
429 itkSetMacro(VolumeCorrectionMaximumIteration,
int);
430 itkGetConstMacro(VolumeCorrectionMaximumIteration,
int);
435 itkSetMacro(InterSliceCorrectionMaximumIteration,
int);
436 itkGetConstMacro(InterSliceCorrectionMaximumIteration,
int);
440 itkSetMacro(OptimizerInitialRadius,
double);
441 itkGetConstMacro(OptimizerInitialRadius,
double);
445 itkSetMacro(OptimizerGrowthFactor,
double);
446 itkGetConstMacro(OptimizerGrowthFactor,
double);
451 itkSetMacro(OptimizerShrinkFactor,
double);
452 itkGetConstMacro(OptimizerShrinkFactor,
double);
464 itkGetConstMacro(NumberOfLevels,
unsigned int);
548 template <
typename TSource,
typename TTarget>
554 using TargetPixelType =
typename TTarget::PixelType;
556 SourceIterator s_iter(source, requestedRegion);
557 TargetIterator t_iter(target, requestedRegion);
561 while (!s_iter.IsAtEnd())
563 t_iter.Set(
static_cast<TargetPixelType
>(s_iter.Get()));
605 int m_SlicingDirection{};
608 bool m_BiasFieldMultiplicative{
true };
611 bool m_UsingInterSliceIntensityCorrection{};
612 bool m_UsingSlabIdentification{
false };
613 bool m_UsingBiasFieldCorrection{
true };
614 bool m_GeneratingOutput{
true };
616 unsigned int m_SlabNumberOfSamples{ 200 };
618 double m_SlabTolerance{ 0.0 };
621 int m_BiasFieldDegree{ 3 };
624 unsigned int m_NumberOfLevels{ 0 };
637 int m_VolumeCorrectionMaximumIteration{ 2000 };
639 int m_InterSliceCorrectionMaximumIteration{ 4000 };
642 double m_OptimizerInitialRadius{ 1.01 };
645 double m_OptimizerGrowthFactor{ 1.05 };
648 double m_OptimizerShrinkFactor{};
659#ifndef ITK_MANUAL_INSTANTIATION
660# include "itkMRIBiasFieldCorrectionFilter.hxx"
Array class with size defined at construction time.
A multi-dimensional iterator templated over image type that walks a region of pixels.
A multi-dimensional iterator templated over image type that walks a region of pixels.
Base class for all process objects that output image data.
typename OutputImageType::PixelType OutputImagePixelType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename OutputImageType::Pointer OutputImagePointer
Base class for filters that take an image as input and produce an image as output.
TInputImage InputImageType
typename InputImageType::Pointer InputImagePointer
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::RegionType InputImageRegionType
Templated n-dimensional image class.
Control indentation during Print() invocation.
Light weight base class for most itk classes.
Identifies slabs in MR images comparing minimum intensity averages.
std::vector< ImageRegionType > SlabRegionVectorType
Represents a cost function for MRI bias field correction optimization.
typename ImageType::IndexType ImageIndexType
CompositeValleyFunction InternalEnergyFunction
void SetSamplingFactors(const SamplingFactorType factor)
unsigned int[SpaceDimension] SamplingFactorType
std::unique_ptr< InternalEnergyFunction > m_InternalEnergyFunction
~MRIBiasEnergyFunction() override=default
unsigned int GetNumberOfParameters() const override
void InitializeDistributions(Array< double > classMeans, Array< double > classSigmas)
typename ImageType::PixelType ImageElementType
typename ImageType::RegionType ImageRegionType
void GetDerivative(const ParametersType &, DerivativeType &) const override
double GetEnergy0(double diff)
typename MaskType::PixelType MaskElementType
void SetBiasField(BiasFieldType *bias)
MeasureType GetValue(const ParametersType ¶meters) const override
typename ImageType::Pointer ImagePointer
typename MaskType::Pointer MaskPointer
Corrects 3D MRI bias field.
void SetNumberOfLevels(unsigned int num)
MRIBiasFieldCorrectionFilter()
void GenerateData() override
typename TOutputImage::IndexType OutputImageIndexType
void SetStartingShrinkFactors(unsigned int factor)
typename TInputImage::IndexType InputImageIndexType
void SetInitialBiasFieldCoefficients(const BiasFieldType::CoefficientArrayType &coefficients)
void CorrectImage(BiasFieldType &bias, InputImageRegionType region)
void GetBiasFieldSize(InputImageRegionType region, BiasFieldType::DomainSizeType &biasSize)
static bool IsScheduleDownwardDivisible(const ScheduleType &schedule)
const unsigned int * GetStartingShrinkFactors() const
bool CheckMaskImage(ImageMaskType *mask)
void SetOutputMask(ImageMaskType *outputMask)
typename InternalImageType::PixelType InternalImagePixelType
BiasFieldType EstimateBiasField(InputImageRegionType region, unsigned int degree, int maximumIteration)
typename ImageMaskType::Pointer ImageMaskPointer
void PrintSelf(std::ostream &os, Indent indent) const override
void SetSchedule(const ScheduleType &schedule)
BiasFieldType::CoefficientArrayType GetEstimatedBiasFieldCoefficients()
typename MRASlabIdentifierType::SlabRegionVectorType SlabRegionVectorType
typename ImageMaskType::RegionType ImageMaskRegionType
typename TInputImage::SizeType InputImageSizeType
void CorrectInterSliceIntensityInhomogeneity(InputImageRegionType region)
typename TOutputImage::SizeType OutputImageSizeType
void ExpImage(InternalImageType *source, InternalImageType *target)
typename InternalImageType::Pointer InternalImagePointer
typename InternalImageType::RegionType InternalImageRegionType
void AdjustSlabRegions(SlabRegionVectorType &slabs, OutputImageRegionType requestedRegion)
bool IsBiasFieldMultiplicative()
typename SlabRegionVectorType::iterator SlabRegionVectorIteratorType
void IsBiasFieldMultiplicative(bool flag)
void SetStartingShrinkFactors(const unsigned int *factors)
void CopyAndConvertImage(const TSource *source, TTarget *target, typename TTarget::RegionType requestedRegion)
~MRIBiasFieldCorrectionFilter() override=default
typename EnergyFunctionType::Pointer EnergyFunctionPointer
void Log1PImage(InternalImageType *source, InternalImageType *target)
void SetInputMask(ImageMaskType *inputMask)
void SetTissueClassStatistics(const Array< double > &means, const Array< double > &sigmas)
2D and 3D multivariate Legendre Polynomial
ULongArrayType DomainSizeType
DoubleArrayType CoefficientArrayType
1+1 evolutionary strategy optimizer
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
A region represents some portion or piece of data.
This class is a base for the CostFunctions returning a single value.
Superclass::ParametersType ParametersType
Normal random variate generator.
SmartPointer< Self > Pointer
ImageBaseType::RegionType RegionType
ImageBaseType::IndexType IndexType
ImageBaseType::SizeType SizeType
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....