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() ITK_OVERRIDE;
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; }
406 itkSetMacro(VolumeCorrectionMaximumIteration,
int);
407 itkGetConstMacro(VolumeCorrectionMaximumIteration,
int);
412 itkSetMacro(InterSliceCorrectionMaximumIteration,
int);
413 itkGetConstMacro(InterSliceCorrectionMaximumIteration,
int);
417 itkSetMacro(OptimizerInitialRadius,
double);
418 itkGetConstMacro(OptimizerInitialRadius,
double);
422 itkSetMacro(OptimizerGrowthFactor,
double);
423 itkGetConstMacro(OptimizerGrowthFactor,
double);
428 itkSetMacro(OptimizerShrinkFactor,
double);
429 itkGetConstMacro(OptimizerShrinkFactor,
double);
437 void SetNumberOfLevels(
unsigned int num);
440 itkGetConstMacro(NumberOfLevels,
unsigned int);
448 void SetSchedule(
const ScheduleType & schedule);
451 itkGetConstReferenceMacro(Schedule, ScheduleType);
457 void SetStartingShrinkFactors(
unsigned int factor);
459 void SetStartingShrinkFactors(
unsigned int *factors);
462 const unsigned int * GetStartingShrinkFactors()
const;
467 static bool IsScheduleDownwardDivisible(
const ScheduleType & schedule);
479 BiasFieldType EstimateBiasField(InputImageRegionType region,
481 int maximumIteration);
486 void CorrectImage(BiasFieldType & bias,
487 InputImageRegionType region);
491 void CorrectInterSliceIntensityInhomogeneity(InputImageRegionType region);
496 void PrintSelf(std::ostream & os,
Indent indent) const ITK_OVERRIDE;
500 bool CheckMaskImage(ImageMaskType *mask);
506 void Log1PImage(InternalImageType *source,
507 InternalImageType *target);
511 void ExpImage(InternalImageType *source,
512 InternalImageType *target);
516 template< typename TSource, typename TTarget >
517 void CopyAndConvertImage(const TSource *source,
519 typename TTarget::RegionType requestedRegion)
523 typedef typename TTarget::PixelType TargetPixelType;
525 SourceIterator s_iter(source, requestedRegion);
526 TargetIterator t_iter(target, requestedRegion);
530 while ( !s_iter.IsAtEnd() )
532 t_iter.Set( static_cast< TargetPixelType >( s_iter.Get() ) );
542 void GetBiasFieldSize(InputImageRegionType region,
543 BiasFieldType::DomainSizeType & domainSize);
548 void AdjustSlabRegions(SlabRegionVectorType & slabs,
549 OutputImageRegionType requestedRegion);
551 void GenerateData() ITK_OVERRIDE;
557 EnergyFunctionPointer m_EnergyFunction;
560 NormalVariateGeneratorType::Pointer m_NormalVariateGenerator;
563 ImageMaskPointer m_InputMask;
566 ImageMaskPointer m_OutputMask;
569 InternalImagePointer m_InternalInput;
572 SlabRegionVectorType m_Slabs;
575 int m_SlicingDirection;
578 bool m_BiasFieldMultiplicative;
581 bool m_UsingInterSliceIntensityCorrection;
582 bool m_UsingSlabIdentification;
583 bool m_UsingBiasFieldCorrection;
584 bool m_GeneratingOutput;
586 unsigned int m_SlabNumberOfSamples;
587 InputImagePixelType m_SlabBackgroundMinimumThreshold;
588 double m_SlabTolerance;
591 int m_BiasFieldDegree;
594 unsigned int m_NumberOfLevels;
597 ScheduleType m_Schedule;
601 BiasFieldType::CoefficientArrayType m_BiasFieldCoefficients;
605 BiasFieldType::CoefficientArrayType m_EstimatedBiasFieldCoefficients;
607 int m_VolumeCorrectionMaximumIteration;
609 int m_InterSliceCorrectionMaximumIteration;
612 double m_OptimizerInitialRadius;
615 double m_OptimizerGrowthFactor;
618 double m_OptimizerShrinkFactor;
624 Array<
double > m_TissueClassSigmas;
629 #ifndef ITK_MANUAL_INSTANTIATION
630 #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
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.
ImageBaseType::SizeType SizeType
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
ImageBaseType::IndexType IndexType