Authors belong to:
- University of LYON http://www.universite-lyon.fr/
- - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ - Léon Bérard cancer center http://www.centreleonberard.fr
- CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
This software is distributed WITHOUT ANY WARRANTY; without even
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
- ======================================================================-====*/
+ ===========================================================================**/
#ifndef CLITKEXTRACTLUNGSFILTER_H
#define CLITKEXTRACTLUNGSFILTER_H
#include "clitkFilterBase.h"
#include "clitkDecomposeAndReconstructImageFilter.h"
#include "clitkExplosionControlledThresholdConnectedImageFilter.h"
-#include "clitkSegmentationFunctions.h"
+#include "clitkSegmentationUtils.h"
+#include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
// itk
#include "itkStatisticsImageFilter.h"
*/
//--------------------------------------------------------------------
- template <class TInputImageType, class TMaskImageType>
+ //--------------------------------------------------------------------
+ template <class TImageType>
class ITK_EXPORT ExtractLungFilter:
- public clitk::FilterBase,
- public itk::ImageToImageFilter<TInputImageType, TMaskImageType>
+ public virtual clitk::FilterBase,
+ public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
+ public itk::ImageToImageFilter<TImageType, itk::Image<uchar, TImageType::ImageDimension> >
{
public:
/** Standard class typedefs. */
- typedef itk::ImageToImageFilter<TInputImageType, TMaskImageType> Superclass;
+ typedef itk::Image<uchar, TImageType::ImageDimension> MaskImageType;
+ typedef itk::ImageToImageFilter<TImageType, MaskImageType> Superclass;
typedef ExtractLungFilter Self;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
FILTERBASE_INIT;
/** Some convenient typedefs */
- typedef TInputImageType InputImageType;
- typedef typename InputImageType::ConstPointer InputImageConstPointer;
- typedef typename InputImageType::Pointer InputImagePointer;
- typedef typename InputImageType::RegionType InputImageRegionType;
- typedef typename InputImageType::PixelType InputImagePixelType;
- typedef typename InputImageType::SizeType InputImageSizeType;
- typedef typename InputImageType::IndexType InputImageIndexType;
+ typedef TImageType ImageType;
+ typedef typename ImageType::ConstPointer InputImageConstPointer;
+ typedef typename ImageType::Pointer InputImagePointer;
+ typedef typename ImageType::RegionType InputImageRegionType;
+ typedef typename ImageType::PixelType InputImagePixelType;
+ typedef typename ImageType::SizeType InputImageSizeType;
+ typedef typename ImageType::IndexType InputImageIndexType;
+ typedef typename ImageType::PointType InputImagePointType;
- typedef TMaskImageType MaskImageType;
typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
typedef typename MaskImageType::Pointer MaskImagePointer;
typedef typename MaskImageType::RegionType MaskImageRegionType;
typedef typename MaskImageType::PixelType MaskImagePixelType;
typedef typename MaskImageType::SizeType MaskImageSizeType;
typedef typename MaskImageType::IndexType MaskImageIndexType;
-
- itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
- typedef int InternalPixelType;
- typedef itk::Image<InternalPixelType, InputImageType::ImageDimension> InternalImageType;
- typedef typename InternalImageType::Pointer InternalImagePointer;
- typedef typename InternalImageType::IndexType InternalIndexType;
- typedef LabelizeParameters<InternalPixelType> LabelParamType;
+ typedef typename MaskImageType::PointType MaskImagePointType;
+
+ itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
+ // typedef int InternalPixelType;
+ typedef uchar InternalPixelType;
+ typedef itk::Image<InternalPixelType, ImageType::ImageDimension> InternalImageType;
+ typedef typename InternalImageType::Pointer InternalImagePointer;
+ typedef typename InternalImageType::IndexType InternalIndexType;
+ typedef LabelizeParameters<InternalPixelType> LabelParamType;
/** Connect inputs */
- void SetInput(const InputImageType * image);
- void SetInputPatientMask(MaskImageType * mask, MaskImagePixelType BG);
+ void SetInput(const ImageType * image);
itkSetMacro(PatientMaskBackgroundValue, MaskImagePixelType);
itkGetConstMacro(PatientMaskBackgroundValue, MaskImagePixelType);
- GGO_DefineOption(patientBG, SetPatientMaskBackgroundValue, MaskImagePixelType);
- // Set all options at a time
- template<class ArgsInfoType>
- void SetArgsInfo(ArgsInfoType arg);
+ // Output filename (for AFBD)
+ itkSetMacro(OutputLungFilename, std::string);
+ itkGetMacro(OutputLungFilename, std::string);
+
+ itkSetMacro(OutputTracheaFilename, std::string);
+ itkGetMacro(OutputTracheaFilename, std::string);
// Get output (only availabe after update !)
typename MaskImageType::Pointer GetTracheaImage() { return trachea; }
// For common segmentation processes
itkSetMacro(MinimalComponentSize, int);
itkGetConstMacro(MinimalComponentSize, int);
- GGO_DefineOption(minSize, SetMinimalComponentSize, int);
// Step 1 options RemoveAir
itkSetMacro(UpperThreshold, InputImagePixelType);
itkGetConstMacro(UpperThreshold, InputImagePixelType);
- GGO_DefineOption(upper, SetUpperThreshold, InputImagePixelType);
+ itkSetMacro(NumberOfSlicesToSkipBeforeSearchingSeed, int);
+ itkGetConstMacro(NumberOfSlicesToSkipBeforeSearchingSeed, int);
+
itkSetMacro(LowerThreshold, InputImagePixelType);
itkGetConstMacro(LowerThreshold, InputImagePixelType);
itkSetMacro(UseLowerThreshold, bool);
itkGetConstMacro(UseLowerThreshold, bool);
itkBooleanMacro(UseLowerThreshold);
- GGO_DefineOption_WithTest(lower, SetLowerThreshold, InputImagePixelType, UseLowerThreshold);
void SetLabelizeParameters1(LabelParamType * a) { m_LabelizeParameters1 = a; }
itkGetConstMacro(LabelizeParameters1, LabelParamType*);
- GGO_DefineOption_LabelParam(1, SetLabelizeParameters1, LabelParamType);
+
+ itkSetMacro(TracheaSeedAlgorithm, int);
+ itkGetConstMacro(TracheaSeedAlgorithm, int);
// Step 2 options FindTrachea
itkSetMacro(UpperThresholdForTrachea, InputImagePixelType);
itkGetConstMacro(UpperThresholdForTrachea, InputImagePixelType);
- GGO_DefineOption(upperThresholdForTrachea, SetUpperThresholdForTrachea, InputImagePixelType);
itkSetMacro(MultiplierForTrachea, double);
itkGetConstMacro(MultiplierForTrachea, double);
- GGO_DefineOption(multiplierForTrachea, SetMultiplierForTrachea, double);
itkSetMacro(ThresholdStepSizeForTrachea, InputImagePixelType);
itkGetConstMacro(ThresholdStepSizeForTrachea, InputImagePixelType);
- GGO_DefineOption(thresholdStepSizeForTrachea, SetThresholdStepSizeForTrachea, InputImagePixelType);
+
+ // options FindTrachea2
+ itkSetMacro(NumSlices, int);
+ itkGetConstMacro(NumSlices, int);
+ itkSetMacro(MaxElongation, double);
+ itkGetConstMacro(MaxElongation, double);
+ itkSetMacro(SeedPreProcessingThreshold, int);
+ itkGetConstMacro(SeedPreProcessingThreshold, int);
void AddSeed(InternalIndexType s);
std::vector<InternalIndexType> & GetSeeds() { return m_Seeds; }
- GGO_DefineOption_Vector(seed, AddSeed, InternalIndexType, InputImageType::ImageDimension, true);
+
+ itkSetMacro(TracheaVolumeMustBeCheckedFlag, bool);
+ itkGetConstMacro(TracheaVolumeMustBeCheckedFlag, bool);
+ itkBooleanMacro(TracheaVolumeMustBeCheckedFlag);
+
+ itkSetMacro(VerboseRegionGrowingFlag, bool);
+ itkGetConstMacro(VerboseRegionGrowingFlag, bool);
+ itkBooleanMacro(VerboseRegionGrowingFlag);
// Step 3 options ExtractLung
itkSetMacro(NumberOfHistogramBins, int);
itkGetConstMacro(NumberOfHistogramBins, int);
- GGO_DefineOption(bins, SetNumberOfHistogramBins, int);
void SetLabelizeParameters2(LabelParamType* a) { m_LabelizeParameters2 = a; }
itkGetConstMacro(LabelizeParameters2, LabelParamType*);
- GGO_DefineOption_LabelParam(2, SetLabelizeParameters2, LabelParamType);
// Step 4 options RemoveTrachea
itkSetMacro(RadiusForTrachea, int);
itkGetConstMacro(RadiusForTrachea, int);
- GGO_DefineOption(radius, SetRadiusForTrachea, int);
void SetLabelizeParameters3(LabelParamType * a) { m_LabelizeParameters3 = a; }
itkGetConstMacro(LabelizeParameters3, LabelParamType*);
- GGO_DefineOption_LabelParam(3, SetLabelizeParameters3, LabelParamType);
-
- // Step 5 options LungSeparation
- // itkSetMacro(FinalOpenClose, bool);
- // itkGetConstMacro(FinalOpenClose, bool);
- // itkBooleanMacro(FinalOpenClose);
- // virtual void Update();
+ // Step 5 final openclose
+ itkSetMacro(OpenCloseFlag, bool);
+ itkGetConstMacro(OpenCloseFlag, bool);
+ itkBooleanMacro(OpenCloseFlag);
+ itkSetMacro(OpenCloseRadius, int);
+ itkGetConstMacro(OpenCloseRadius, int);
+
+ // Step 6 fill holes
+ itkSetMacro(FillHolesFlag, bool);
+ itkGetConstMacro(FillHolesFlag, bool);
+ itkBooleanMacro(FillHolesFlag);
+
+ // Separate lungs
+ itkSetMacro(SeparateLungsFlag, bool);
+ itkGetConstMacro(SeparateLungsFlag, bool);
+ itkBooleanMacro(SeparateLungsFlag);
+
+ // Step Auto Crop
+ itkSetMacro(AutoCrop, bool);
+ itkGetConstMacro(AutoCrop, bool);
+ itkBooleanMacro(AutoCrop);
+
protected:
ExtractLungFilter();
virtual ~ExtractLungFilter() {}
-
+
+ // Main members
+ InputImageConstPointer input;
+ MaskImagePointer patient;
+ InputImagePointer working_input;
+ std::string m_OutputLungFilename;
+ std::string m_OutputTracheaFilename;
+ MaskImagePointer working_mask;
+ MaskImagePointer trachea;
+ unsigned int m_MaxSeedNumber;
+
// Global options
itkSetMacro(BackgroundValue, MaskImagePixelType);
itkSetMacro(ForegroundValue, MaskImagePixelType);
MaskImagePixelType m_BackgroundValue;
MaskImagePixelType m_ForegroundValue;
int m_MinimalComponentSize;
+ bool m_AutoCrop;
// Step 1
InputImagePixelType m_UpperThreshold;
LabelParamType* m_LabelizeParameters1;
// Step 2
+ int m_TracheaSeedAlgorithm;
InputImagePixelType m_UpperThresholdForTrachea;
InputImagePixelType m_ThresholdStepSizeForTrachea;
double m_MultiplierForTrachea;
std::vector<InternalIndexType> m_Seeds;
+ int m_NumberOfSlicesToSkipBeforeSearchingSeed;
+ bool m_TracheaVolumeMustBeCheckedFlag;
+ bool m_VerboseRegionGrowingFlag;
+ int m_NumSlices;
+ double m_MaxElongation;
+ int m_SeedPreProcessingThreshold;
// Step 3
int m_NumberOfHistogramBins;
LabelParamType* m_LabelizeParameters3;
// Step 5
- // bool m_FinalOpenClose;
+ bool m_OpenCloseFlag;
+ int m_OpenCloseRadius;
+
+ // Step 6
+ bool m_FillHolesFlag;
+ InputImageSizeType m_FillHolesDirections;
+
+ bool m_SeparateLungsFlag;
+ // Main functions
virtual void GenerateOutputInformation();
+ virtual void GenerateInputRequestedRegion();
virtual void GenerateData();
+
+ // Functions for trachea extraction
+ bool SearchForTracheaSeed(int skip);
+ bool SearchForTracheaSeed2(int numberOfSlices);
+ void SearchForTrachea();
+ void TracheaRegionGrowing();
+ double ComputeTracheaVolume();
- // Steps
- void RemoveAir();
- void FindTrachea();
- void ExtractLung();
- void RemoveTrachea();
- void LungSeparation();
- InputImageConstPointer input;
- MaskImageConstPointer patient;
- InputImagePointer working_input;
- typename InternalImageType::Pointer working_image;
- typename InternalImageType::Pointer trachea_tmp;
- MaskImagePointer trachea;
-
private:
ExtractLungFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented