18 #ifndef itkMRIBiasFieldCorrectionFilter_h
19 #define itkMRIBiasFieldCorrectionFilter_h
46 template<
typename TImage,
typename TImageMask,
typename TBiasField >
148 virtual ~MRIBiasEnergyFunction();
170 MRIBiasEnergyFunction(const
Self &);
171 void operator=(const Self &);
224 template< typename TInputImage, typename TOutputImage, typename TMaskImage >
242 itkStaticConstMacro(ImageDimension,
unsigned int,
243 TOutputImage::ImageDimension);
281 typedef MRIBiasEnergyFunction< InternalImageType,
298 void SetInputMask(ImageMaskType *inputMask);
299 itkGetModifiableObjectMacro(InputMask, ImageMaskType);
304 void SetOutputMask(ImageMaskType *outputMask);
305 itkGetModifiableObjectMacro(OutputMask, ImageMaskType);
312 { m_BiasMultiplicative = flag; }
316 {
return m_BiasMultiplicative; }
321 itkSetMacro(UsingInterSliceIntensityCorrection,
bool);
322 itkGetConstReferenceMacro(UsingInterSliceIntensityCorrection,
bool);
330 itkSetMacro(UsingSlabIdentification,
bool);
331 itkGetConstReferenceMacro(UsingSlabIdentification,
bool);
334 itkSetMacro(SlabBackgroundMinimumThreshold, InputImagePixelType);
335 itkGetConstReferenceMacro(SlabBackgroundMinimumThreshold,
336 InputImagePixelType);
338 itkSetMacro(SlabNumberOfSamples,
unsigned int);
339 itkGetConstReferenceMacro(SlabNumberOfSamples,
unsigned int);
341 itkSetMacro(SlabTolerance,
double);
342 itkGetConstReferenceMacro(SlabTolerance,
double);
349 itkSetMacro(UsingBiasFieldCorrection,
bool);
350 itkGetConstReferenceMacro(UsingBiasFieldCorrection,
bool);
355 itkSetMacro(GeneratingOutput,
bool);
356 itkGetConstReferenceMacro(GeneratingOutput,
bool);
361 itkSetMacro(SlicingDirection,
int);
364 itkSetMacro(BiasFieldDegree,
int);
365 itkGetConstMacro(BiasFieldDegree,
int);
373 { this->
Modified(); m_BiasFieldCoefficients = coefficients; }
379 {
return m_EstimatedBiasFieldCoefficients; }
389 itkSetMacro(VolumeCorrectionMaximumIteration,
int);
390 itkGetConstMacro(VolumeCorrectionMaximumIteration,
int);
391 itkSetMacro(InterSliceCorrectionMaximumIteration,
int);
392 itkGetConstMacro(InterSliceCorrectionMaximumIteration,
int);
397 { m_OptimizerInitialRadius = initRadius; }
399 {
return m_OptimizerInitialRadius; }
403 itkSetMacro(OptimizerGrowthFactor,
double);
404 itkGetConstMacro(OptimizerGrowthFactor,
double);
409 itkSetMacro(OptimizerShrinkFactor,
double);
410 itkGetConstMacro(OptimizerShrinkFactor,
double);
418 void SetNumberOfLevels(
unsigned int num);
421 itkGetConstMacro(NumberOfLevels,
unsigned int);
429 void SetSchedule(
const ScheduleType & schedule);
432 itkGetConstReferenceMacro(Schedule, ScheduleType);
438 void SetStartingShrinkFactors(
unsigned int factor);
440 void SetStartingShrinkFactors(
unsigned int *factors);
443 const unsigned int * GetStartingShrinkFactors()
const;
448 static bool IsScheduleDownwardDivisible(
const ScheduleType & schedule);
461 BiasFieldType EstimateBiasField(InputImageRegionType region,
463 int maximumIteration);
468 void CorrectImage(BiasFieldType & bias,
469 InputImageRegionType region);
473 void CorrectInterSliceIntensityInhomogeneity(InputImageRegionType region);
477 virtual ~MRIBiasFieldCorrectionFilter();
482 bool CheckMaskImage(ImageMaskType *mask);
488 void Log1PImage(InternalImageType *source,
489 InternalImageType *target);
493 void ExpImage(InternalImageType *source,
494 InternalImageType *target);
498 template< typename TSource, typename TTarget >
499 void CopyAndConvertImage(const TSource *source,
501 typename TTarget::RegionType requestedRegion)
505 typedef typename TTarget::PixelType TargetPixelType;
507 SourceIterator s_iter(source, requestedRegion);
508 TargetIterator t_iter(target, requestedRegion);
512 while ( !s_iter.IsAtEnd() )
514 t_iter.Set( static_cast< TargetPixelType >( s_iter.Get() ) );
524 void GetBiasFieldSize(InputImageRegionType region,
525 BiasFieldType::DomainSizeType & domainSize);
530 void AdjustSlabRegions(SlabRegionVectorType & slabs,
531 OutputImageRegionType requestedRegion);
533 void GenerateData() ITK_OVERRIDE;
537 void operator=(const Self &);
540 EnergyFunctionPointer m_EnergyFunction;
543 NormalVariateGeneratorType::Pointer m_NormalVariateGenerator;
546 ImageMaskPointer m_InputMask;
549 ImageMaskPointer m_OutputMask;
552 InternalImagePointer m_InternalInput;
555 SlabRegionVectorType m_Slabs;
558 int m_SlicingDirection;
561 bool m_BiasMultiplicative;
564 bool m_UsingInterSliceIntensityCorrection;
565 bool m_UsingSlabIdentification;
566 bool m_UsingBiasFieldCorrection;
567 bool m_GeneratingOutput;
569 unsigned int m_SlabNumberOfSamples;
570 InputImagePixelType m_SlabBackgroundMinimumThreshold;
571 double m_SlabTolerance;
573 int m_BiasFieldDegree;
576 unsigned int m_NumberOfLevels;
579 ScheduleType m_Schedule;
583 BiasFieldType::CoefficientArrayType m_BiasFieldCoefficients;
587 BiasFieldType::CoefficientArrayType m_EstimatedBiasFieldCoefficients;
590 int m_VolumeCorrectionMaximumIteration;
593 int m_InterSliceCorrectionMaximumIteration;
596 double m_OptimizerInitialRadius;
599 double m_OptimizerGrowthFactor;
602 double m_OptimizerShrinkFactor;
608 Array<
double > m_TissueClassSigmas;
614 #ifndef ITK_MANUAL_INSTANTIATION
615 #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
void InitializeDistributions(Array< double > classMeans, Array< double > classSigmas)
InternalImageType::RegionType InternalImageRegionType
virtual void PrintSelf(std::ostream &os, Indent indent) const override
MaskType::Pointer MaskPointer
TOutputImage::SizeType OutputImageSizeType
ImageMaskType::Pointer ImageMaskPointer
void IsBiasFieldMultiplicative(bool flag)
TOutputImage::Pointer OutputImagePointer
ImageMaskType::RegionType ImageMaskRegionType
double GetOptimizerInitialRadius()
CompositeValleyFunction InternalEnergyFunction
unsigned int SamplingFactorType[SpaceDimension]
virtual MeasureType GetValue(const ParametersType ¶meters) const override
EnergyFunctionType::Pointer EnergyFunctionPointer
double GetEnergy0(double diff)
std::vector< ImageRegionType > SlabRegionVectorType
ImageType::Pointer ImagePointer
ImageType::IndexType ImageIndexType
virtual unsigned int GetNumberOfParameters(void) const override
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
Array< ParametersValueType > DerivativeType
ImageType::PixelType ImageElementType
A multi-dimensional iterator templated over image type that walks a region of pixels.
MRIBiasEnergyFunction Self
void SetOptimizerInitialRadius(double initRadius)
InternalEnergyFunction * m_InternalEnergyFunction
a cost function for optimization
2D and 3D multivariate Legendre Polynomial
Standard exception handling object.
static const unsigned int SpaceDimension
A region represents some portion or piece of data.
virtual void Modified() const
SmartPointer< Self > Pointer
Superclass::ParametersType ParametersType
identifies slab in MR images comparing minimum intensity averages
1+1 evolutionary strategy optimizer
void GetDerivative(const ParametersType &, DerivativeType &) const override
bool IsBiasFieldMultiplicative()
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
SamplingFactorType m_SamplingFactor
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
BiasFieldType * m_BiasField