18 #ifndef itkMRIBiasFieldCorrectionFilter_h
19 #define itkMRIBiasFieldCorrectionFilter_h
47 template <
typename TImage,
typename TImageMask,
typename TBiasField>
88 static constexpr
unsigned int SpaceDimension = 3;
117 for (
unsigned int i = 0; i < SpaceDimension; i++)
119 m_SamplingFactor[i] = factor[i];
129 return (*m_InternalEnergyFunction)(diff);
135 GetValue(
const ParametersType & parameters)
const override;
151 GetNumberOfParameters()
const override;
231 template <
typename TInputImage,
typename TOutputImage,
typename TMaskImage>
251 static constexpr
unsigned int ImageDimension = TOutputImage::ImageDimension;
315 #if defined(ITK_LEGACY_REMOVE)
322 m_BiasFieldMultiplicative = flag;
324 #endif // defined ( ITK_LEGACY_REMOVE )
329 itkSetMacro(BiasFieldMultiplicative,
bool);
330 itkGetConstMacro(BiasFieldMultiplicative,
bool);
331 itkBooleanMacro(BiasFieldMultiplicative);
334 #if defined(ITK_LEGACY_REMOVE)
339 return m_BiasFieldMultiplicative;
341 #endif // defined ( ITK_LEGACY_REMOVE )
347 itkSetMacro(UsingInterSliceIntensityCorrection,
bool);
348 itkGetConstMacro(UsingInterSliceIntensityCorrection,
bool);
349 itkBooleanMacro(UsingInterSliceIntensityCorrection);
357 itkSetMacro(UsingSlabIdentification,
bool);
358 itkGetConstMacro(UsingSlabIdentification,
bool);
359 itkBooleanMacro(UsingSlabIdentification);
362 itkSetMacro(SlabBackgroundMinimumThreshold, InputImagePixelType);
363 itkGetConstReferenceMacro(SlabBackgroundMinimumThreshold, InputImagePixelType);
365 itkSetMacro(SlabNumberOfSamples,
unsigned int);
366 itkGetConstReferenceMacro(SlabNumberOfSamples,
unsigned int);
368 itkSetMacro(SlabTolerance,
double);
369 itkGetConstReferenceMacro(SlabTolerance,
double);
376 itkSetMacro(UsingBiasFieldCorrection,
bool);
377 itkGetConstMacro(UsingBiasFieldCorrection,
bool);
378 itkBooleanMacro(UsingBiasFieldCorrection);
383 itkSetMacro(GeneratingOutput,
bool);
384 itkGetConstMacro(GeneratingOutput,
bool);
385 itkBooleanMacro(GeneratingOutput);
390 itkSetMacro(SlicingDirection,
int);
391 itkGetConstMacro(SlicingDirection,
int);
395 itkSetMacro(BiasFieldDegree,
int);
396 itkGetConstMacro(BiasFieldDegree,
int);
405 m_BiasFieldCoefficients = coefficients;
412 BiasFieldType::CoefficientArrayType
415 return m_EstimatedBiasFieldCoefficients;
426 itkSetMacro(VolumeCorrectionMaximumIteration,
int);
427 itkGetConstMacro(VolumeCorrectionMaximumIteration,
int);
432 itkSetMacro(InterSliceCorrectionMaximumIteration,
int);
433 itkGetConstMacro(InterSliceCorrectionMaximumIteration,
int);
437 itkSetMacro(OptimizerInitialRadius,
double);
438 itkGetConstMacro(OptimizerInitialRadius,
double);
442 itkSetMacro(OptimizerGrowthFactor,
double);
443 itkGetConstMacro(OptimizerGrowthFactor,
double);
448 itkSetMacro(OptimizerShrinkFactor,
double);
449 itkGetConstMacro(OptimizerShrinkFactor,
double);
458 SetNumberOfLevels(
unsigned int num);
461 itkGetConstMacro(NumberOfLevels,
unsigned int);
470 SetSchedule(
const ScheduleType & schedule);
473 itkGetConstReferenceMacro(Schedule, ScheduleType);
480 SetStartingShrinkFactors(
unsigned int factor);
483 SetStartingShrinkFactors(
const unsigned int * factors);
487 GetStartingShrinkFactors()
const;
493 IsScheduleDownwardDivisible(
const ScheduleType & schedule);
507 EstimateBiasField(InputImageRegionType region,
unsigned int degree,
int maximumIteration);
513 CorrectImage(BiasFieldType & bias, InputImageRegionType region);
518 CorrectInterSliceIntensityInhomogeneity(InputImageRegionType region);
524 PrintSelf(std::ostream & os,
Indent indent)
const override;
529 CheckMaskImage(ImageMaskType * mask);
536 Log1PImage(InternalImageType * source, InternalImageType * target);
541 ExpImage(InternalImageType * source, InternalImageType * target);
545 template <
typename TSource,
typename TTarget>
551 using TargetPixelType =
typename TTarget::PixelType;
553 SourceIterator s_iter(source, requestedRegion);
554 TargetIterator t_iter(target, requestedRegion);
558 while (!s_iter.IsAtEnd())
560 t_iter.Set(static_cast<TargetPixelType>(s_iter.Get()));
571 GetBiasFieldSize(InputImageRegionType region, BiasFieldType::DomainSizeType & biasSize);
577 AdjustSlabRegions(SlabRegionVectorType & slabs, OutputImageRegionType requestedRegion);
580 GenerateData()
override;
605 bool m_BiasFieldMultiplicative{
true };
609 bool m_UsingSlabIdentification{
false };
610 bool m_UsingBiasFieldCorrection{
true };
611 bool m_GeneratingOutput{
true };
613 unsigned int m_SlabNumberOfSamples{ 200 };
615 double m_SlabTolerance{ 0.0 };
618 int m_BiasFieldDegree{ 3 };
621 unsigned int m_NumberOfLevels{ 0 };
634 int m_VolumeCorrectionMaximumIteration{ 2000 };
636 int m_InterSliceCorrectionMaximumIteration{ 4000 };
639 double m_OptimizerInitialRadius{ 1.01 };
642 double m_OptimizerGrowthFactor{ 1.05 };
656 #ifndef ITK_MANUAL_INSTANTIATION
657 # include "itkMRIBiasFieldCorrectionFilter.hxx"