]> Creatis software - clitk.git/blobdiff - segmentation/clitkExtractLungFilter.h
With ITK 5, add itkReadRawBytesAfterSwappingMacro and itkWriteRawBytesAfterSwappingMacro
[clitk.git] / segmentation / clitkExtractLungFilter.h
index 3183457dde0a6eb7ff06d445670cb132523a2ae8..6c50b1c2d96c85e3c9b8485d970d9ad6e0a261b3 100644 (file)
@@ -3,7 +3,7 @@
 
   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
@@ -14,7 +14,7 @@
 
   - 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
@@ -97,7 +97,8 @@ namespace clitk {
     typedef typename MaskImageType::PointType    MaskImagePointType; 
 
     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
-    typedef int InternalPixelType;
+    //    typedef int InternalPixelType;
+    typedef uchar InternalPixelType;
     typedef itk::Image<InternalPixelType, ImageType::ImageDimension> InternalImageType;
     typedef typename InternalImageType::Pointer                      InternalImagePointer;
     typedef typename InternalImageType::IndexType                    InternalIndexType;
@@ -107,20 +108,13 @@ namespace clitk {
     void SetInput(const ImageType * image);
     itkSetMacro(PatientMaskBackgroundValue, MaskImagePixelType);
     itkGetConstMacro(PatientMaskBackgroundValue, MaskImagePixelType);
-    GGO_DefineOption(patientBG, SetPatientMaskBackgroundValue, MaskImagePixelType);
 
     // Output filename  (for AFBD)
     itkSetMacro(OutputLungFilename, std::string);
     itkGetMacro(OutputLungFilename, std::string);
-    GGO_DefineOption(output, SetOutputLungFilename, std::string);
 
     itkSetMacro(OutputTracheaFilename, std::string);
     itkGetMacro(OutputTracheaFilename, std::string);
-    GGO_DefineOption(outputTrachea, SetOutputTracheaFilename, std::string);
-
-    // Set all options at a time
-    template<class ArgsInfoType>
-      void SetArgsInfo(ArgsInfoType arg);
 
     // Get output (only availabe after update !)
     typename MaskImageType::Pointer GetTracheaImage() { return trachea; }
@@ -132,93 +126,109 @@ namespace clitk {
     // 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);
-    GGO_DefineOption(skipslices, SetNumberOfSlicesToSkipBeforeSearchingSeed, 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);
 
-    void AddSeed(InternalIndexType s);
+    // options FindTrachea2
+    itkSetMacro(NumSlices, int);
+    itkGetConstMacro(NumSlices, int);
+    itkSetMacro(MaxElongation, double);
+    itkGetConstMacro(MaxElongation, double);
+    itkSetMacro(SeedPreProcessingThreshold, int);
+    itkGetConstMacro(SeedPreProcessingThreshold, int);
+
+    void AddSeedInPixels(InternalIndexType s);
+    void AddSeed(InputImagePointType s);
     std::vector<InternalIndexType> & GetSeeds() { return  m_Seeds; }
-    GGO_DefineOption_Vector(seed, AddSeed, InternalIndexType, ImageType::ImageDimension, true);
+
+    itkSetMacro(TracheaVolumeMustBeCheckedFlag, bool);
+    itkGetConstMacro(TracheaVolumeMustBeCheckedFlag, bool);
+    itkBooleanMacro(TracheaVolumeMustBeCheckedFlag);    
+
+    itkSetMacro(VerboseRegionGrowingFlag, bool);
+    itkGetConstMacro(VerboseRegionGrowingFlag, bool);
+    itkBooleanMacro(VerboseRegionGrowingFlag);    
+
+    itkSetMacro(RemoveSmallLabelBeforeSeparationFlag, bool);
+    itkGetConstMacro(RemoveSmallLabelBeforeSeparationFlag, bool);
+    itkBooleanMacro(RemoveSmallLabelBeforeSeparationFlag);    
 
     // 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 final openclose
-    itkSetMacro(OpenClose, bool);
-    itkGetConstMacro(OpenClose, bool);
-    itkBooleanMacro(OpenClose);
-    GGO_DefineOption_Flag(openclose, SetOpenClose);
+    itkSetMacro(OpenCloseFlag, bool);
+    itkGetConstMacro(OpenCloseFlag, bool);
+    itkBooleanMacro(OpenCloseFlag);
 
     itkSetMacro(OpenCloseRadius, int);
     itkGetConstMacro(OpenCloseRadius, int);
-    GGO_DefineOption(opencloseRadius, SetOpenCloseRadius, int);
     
     // Step 6 fill holes
-    itkSetMacro(FillHoles, bool);
-    itkGetConstMacro(FillHoles, bool);
-    itkBooleanMacro(FillHoles);
-    GGO_DefineOption_Flag(doNotFillHoles, SetFillHoles);
-
+    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;
-    MaskImageConstPointer patient;
+    MaskImagePointer patient;
     InputImagePointer working_input;
     std::string m_OutputLungFilename;
     std::string m_OutputTracheaFilename;
-    typename InternalImageType::Pointer working_image;  
-    typename InternalImageType::Pointer trachea_tmp;
+    MaskImagePointer working_mask;  
     MaskImagePointer trachea;
-    MaskImagePointer output;
     unsigned int m_MaxSeedNumber;
 
     // Global options
@@ -228,6 +238,8 @@ namespace clitk {
     MaskImagePixelType m_BackgroundValue;
     MaskImagePixelType m_ForegroundValue;
     int m_MinimalComponentSize;
+    bool m_AutoCrop;
+    bool m_RemoveSmallLabelBeforeSeparationFlag;
 
     // Step 1
     InputImagePixelType m_UpperThreshold;
@@ -236,11 +248,18 @@ namespace clitk {
     LabelParamType* m_LabelizeParameters1;
 
     // Step 2
+    int m_TracheaSeedAlgorithm;
     InputImagePixelType m_UpperThresholdForTrachea;
     InputImagePixelType m_ThresholdStepSizeForTrachea;
     double m_MultiplierForTrachea;
     std::vector<InternalIndexType> m_Seeds;
+    std::vector<InputImagePointType> m_SeedsInMM;
     int m_NumberOfSlicesToSkipBeforeSearchingSeed;
+    bool m_TracheaVolumeMustBeCheckedFlag;
+    bool m_VerboseRegionGrowingFlag;
+    int m_NumSlices;
+    double m_MaxElongation;
+    int m_SeedPreProcessingThreshold;
 
     // Step 3
     int m_NumberOfHistogramBins;
@@ -251,19 +270,23 @@ namespace clitk {
     LabelParamType* m_LabelizeParameters3;
 
     // Step 5
-    bool m_OpenClose;    
+    bool m_OpenCloseFlag;    
     int m_OpenCloseRadius;
 
     // Step 6
-    bool m_FillHoles;    
+    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();