18 #ifndef itkMRIBiasFieldCorrectionFilter_h
19 #define itkMRIBiasFieldCorrectionFilter_h
46 template<
typename TImage,
typename TImageMask,
typename TBiasField >
85 itkStaticConstMacro(SpaceDimension,
unsigned int, 3);
91 typedef unsigned int SamplingFactorType[SpaceDimension];
104 { m_BiasField = bias; }
110 for (
unsigned int i = 0; i < SpaceDimension; i++ )
112 m_SamplingFactor[i] = factor[i];
121 return ( *m_InternalEnergyFunction )( diff );
126 virtual MeasureType GetValue(
const ParametersType & parameters)
const ITK_OVERRIDE;
141 virtual unsigned int GetNumberOfParameters(
void) const ITK_OVERRIDE;
148 virtual ~MRIBiasEnergyFunction();
151 ITK_DISALLOW_COPY_AND_ASSIGN(MRIBiasEnergyFunction);
169 SamplingFactorType m_SamplingFactor;
222 template< typename TInputImage, typename TOutputImage, typename TMaskImage >
240 itkStaticConstMacro(ImageDimension,
unsigned int,
241 TOutputImage::ImageDimension);
279 typedef MRIBiasEnergyFunction< InternalImageType,
296 void SetInputMask(ImageMaskType *inputMask);
297 itkGetModifiableObjectMacro(InputMask, ImageMaskType);
302 void SetOutputMask(ImageMaskType *outputMask);
303 itkGetModifiableObjectMacro(OutputMask, ImageMaskType);
306 #if defined ( ITK_FUTURE_LEGACY_REMOVE )
310 void IsBiasFieldMultiplicative(
bool flag)
311 { m_BiasFieldMultiplicative = flag; }
312 #endif // defined ( ITK_FUTURE_LEGACY_REMOVE )
317 itkSetMacro(BiasFieldMultiplicative,
bool);
318 itkGetConstMacro(BiasFieldMultiplicative,
bool);
319 itkBooleanMacro(BiasFieldMultiplicative);
322 #if defined ( ITK_FUTURE_LEGACY_REMOVE )
324 bool IsBiasFieldMultiplicative()
325 {
return m_BiasFieldMultiplicative; }
326 #endif // defined ( ITK_FUTURE_LEGACY_REMOVE )
332 itkSetMacro(UsingInterSliceIntensityCorrection,
bool);
333 itkGetConstMacro(UsingInterSliceIntensityCorrection,
bool);
334 itkBooleanMacro(UsingInterSliceIntensityCorrection);
342 itkSetMacro(UsingSlabIdentification,
bool);
343 itkGetConstMacro(UsingSlabIdentification,
bool);
344 itkBooleanMacro(UsingSlabIdentification);
347 itkSetMacro(SlabBackgroundMinimumThreshold, InputImagePixelType);
348 itkGetConstReferenceMacro(SlabBackgroundMinimumThreshold,
349 InputImagePixelType);
351 itkSetMacro(SlabNumberOfSamples,
unsigned int);
352 itkGetConstReferenceMacro(SlabNumberOfSamples,
unsigned int);
354 itkSetMacro(SlabTolerance,
double);
355 itkGetConstReferenceMacro(SlabTolerance,
double);
362 itkSetMacro(UsingBiasFieldCorrection,
bool);
363 itkGetConstMacro(UsingBiasFieldCorrection,
bool);
364 itkBooleanMacro(UsingBiasFieldCorrection);
369 itkSetMacro(GeneratingOutput,
bool);
370 itkGetConstMacro(GeneratingOutput,
bool);
371 itkBooleanMacro(GeneratingOutput);
376 itkSetMacro(SlicingDirection,
int);
377 itkGetConstMacro(SlicingDirection,
int);
381 itkSetMacro(BiasFieldDegree,
int);
382 itkGetConstMacro(BiasFieldDegree,
int);
390 { this->Modified(); m_BiasFieldCoefficients = coefficients; }
396 {
return m_EstimatedBiasFieldCoefficients; }
407 itkSetMacro(VolumeCorrectionMaximumIteration,
int);
408 itkGetConstMacro(VolumeCorrectionMaximumIteration,
int);
413 itkSetMacro(InterSliceCorrectionMaximumIteration,
int);
414 itkGetConstMacro(InterSliceCorrectionMaximumIteration,
int);
418 itkSetMacro(OptimizerInitialRadius,
double);
419 itkGetConstMacro(OptimizerInitialRadius,
double);
423 itkSetMacro(OptimizerGrowthFactor,
double);
424 itkGetConstMacro(OptimizerGrowthFactor,
double);
429 itkSetMacro(OptimizerShrinkFactor,
double);
430 itkGetConstMacro(OptimizerShrinkFactor,
double);
438 void SetNumberOfLevels(
unsigned int num);
441 itkGetConstMacro(NumberOfLevels,
unsigned int);
449 void SetSchedule(
const ScheduleType & schedule);
452 itkGetConstReferenceMacro(Schedule, ScheduleType);
458 void SetStartingShrinkFactors(
unsigned int factor);
460 void SetStartingShrinkFactors(
unsigned int *factors);
463 const unsigned int * GetStartingShrinkFactors()
const;
468 static bool IsScheduleDownwardDivisible(
const ScheduleType & schedule);
481 BiasFieldType EstimateBiasField(InputImageRegionType region,
483 int maximumIteration);
488 void CorrectImage(BiasFieldType & bias,
489 InputImageRegionType region);
493 void CorrectInterSliceIntensityInhomogeneity(InputImageRegionType region);
497 virtual ~MRIBiasFieldCorrectionFilter();
498 void PrintSelf(std::ostream & os,
Indent indent) const ITK_OVERRIDE;
502 bool CheckMaskImage(ImageMaskType *mask);
508 void Log1PImage(InternalImageType *source,
509 InternalImageType *target);
513 void ExpImage(InternalImageType *source,
514 InternalImageType *target);
518 template< typename TSource, typename TTarget >
519 void CopyAndConvertImage(const TSource *source,
521 typename TTarget::RegionType requestedRegion)
525 typedef typename TTarget::PixelType TargetPixelType;
527 SourceIterator s_iter(source, requestedRegion);
528 TargetIterator t_iter(target, requestedRegion);
532 while ( !s_iter.IsAtEnd() )
534 t_iter.Set( static_cast< TargetPixelType >( s_iter.Get() ) );
544 void GetBiasFieldSize(InputImageRegionType region,
545 BiasFieldType::DomainSizeType & domainSize);
550 void AdjustSlabRegions(SlabRegionVectorType & slabs,
551 OutputImageRegionType requestedRegion);
553 void GenerateData() ITK_OVERRIDE;
559 EnergyFunctionPointer m_EnergyFunction;
562 NormalVariateGeneratorType::Pointer m_NormalVariateGenerator;
565 ImageMaskPointer m_InputMask;
568 ImageMaskPointer m_OutputMask;
571 InternalImagePointer m_InternalInput;
574 SlabRegionVectorType m_Slabs;
577 int m_SlicingDirection;
580 bool m_BiasFieldMultiplicative;
583 bool m_UsingInterSliceIntensityCorrection;
584 bool m_UsingSlabIdentification;
585 bool m_UsingBiasFieldCorrection;
586 bool m_GeneratingOutput;
588 unsigned int m_SlabNumberOfSamples;
589 InputImagePixelType m_SlabBackgroundMinimumThreshold;
590 double m_SlabTolerance;
593 int m_BiasFieldDegree;
596 unsigned int m_NumberOfLevels;
599 ScheduleType m_Schedule;
603 BiasFieldType::CoefficientArrayType m_BiasFieldCoefficients;
607 BiasFieldType::CoefficientArrayType m_EstimatedBiasFieldCoefficients;
609 int m_VolumeCorrectionMaximumIteration;
611 int m_InterSliceCorrectionMaximumIteration;
614 double m_OptimizerInitialRadius;
617 double m_OptimizerGrowthFactor;
620 double m_OptimizerShrinkFactor;
626 Array<
double > m_TissueClassSigmas;
631 #ifndef ITK_MANUAL_INSTANTIATION
632 #include "itkMRIBiasFieldCorrectionFilter.hxx"
MultivariateLegendrePolynomial BiasFieldType
Array class with size defined at construction time.
Superclass::MeasureType MeasureType
Superclass::RegionType RegionType
Superclass::DerivativeType DerivativeType
SmartPointer< const Self > ConstPointer
SingleValuedCostFunction Superclass
InternalImageType::PixelType InternalImagePixelType
This class is a base for the CostFunctions returning a single value.
Light weight base class for most itk classes.
TOutputImage::PixelType OutputImagePixelType
TOutputImage::RegionType OutputImageRegionType
InternalImageType::RegionType InternalImageRegionType
MaskType::Pointer MaskPointer
TOutputImage::SizeType OutputImageSizeType
ImageMaskType::Pointer ImageMaskPointer
TOutputImage::Pointer OutputImagePointer
ImageMaskType::RegionType ImageMaskRegionType
CompositeValleyFunction InternalEnergyFunction
EnergyFunctionType::Pointer EnergyFunctionPointer
double GetEnergy0(double diff)
std::vector< ImageRegionType > SlabRegionVectorType
ImageType::Pointer ImagePointer
ImageType::IndexType ImageIndexType
ImageToImageFilter< TInputImage, TOutputImage > Superclass
Superclass::ParametersType ParametersType
MRIBiasEnergyFunction< InternalImageType, ImageMaskType, BiasFieldType > EnergyFunctionType
SmartPointer< Self > Pointer
BiasFieldType::CoefficientArrayType GetEstimatedBiasFieldCoefficients()
TOutputImage OutputImageType
void SetBiasField(BiasFieldType *bias)
ImageType::RegionType ImageRegionType
MaskType::PixelType MaskElementType
Image< float, itkGetStaticConstMacro(ImageDimension) > InternalImageType
ImageType::PixelType ImageElementType
A multi-dimensional iterator templated over image type that walks a region of pixels.
MRIBiasEnergyFunction Self
Represents a cost function for MRI bias field correction optimization.
2D and 3D multivariate Legendre Polynomial
Standard exception handling object.
A region represents some portion or piece of data.
SmartPointer< Self > Pointer
identifies slab in MR images comparing minimum intensity averages
1+1 evolutionary strategy optimizer
void GetDerivative(const ParametersType &, DerivativeType &) const override
TInputImage::SizeType InputImageSizeType
SmartPointer< const Self > ConstPointer
MRIBiasFieldCorrectionFilter Self
OnePlusOneEvolutionaryOptimizer OptimizerType
Base class for filters that take an image as input and produce an image as output.
Statistics::NormalVariateGenerator NormalVariateGeneratorType
void SetSamplingFactors(SamplingFactorType factor)
Control indentation during Print() invocation.
DoubleArrayType CoefficientArrayType
Corrects 3D MRI bias field.
InternalImageType::Pointer InternalImagePointer
TOutputImage::IndexType OutputImageIndexType
MRASlabIdentifierType::SlabRegionVectorType SlabRegionVectorType
Array2D< unsigned int > ScheduleType
SlabRegionVectorType::iterator SlabRegionVectorIteratorType
TInputImage::IndexType InputImageIndexType
MRASlabIdentifier< InputImageType > MRASlabIdentifierType
TInputImage InputImageType
TInputImage::PixelType InputImagePixelType
TInputImage::RegionType InputImageRegionType
void SetInitialBiasFieldCoefficients(const BiasFieldType::CoefficientArrayType &coefficients)
Templated n-dimensional image class.
A multi-dimensional iterator templated over image type that walks a region of pixels.
Normal random variate generator.
TInputImage::Pointer InputImagePointer