]> Creatis software - clitk.git/blobdiff - segmentation/clitkExtractBonesFilter.h
Debug RTStruct conversion with empty struc
[clitk.git] / segmentation / clitkExtractBonesFilter.h
index b483f37e926d00bd399dafca6cf10ca1fa7793ce..e630f1a5fc4bf738b5d69d667859405e038aadb0 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 CLITKEXTRACTBONESSFILTER_H
 #define CLITKEXTRACTBONESSFILTER_H
@@ -23,7 +23,8 @@
 #include "clitkFilterBase.h"
 #include "clitkDecomposeAndReconstructImageFilter.h"
 #include "clitkExplosionControlledThresholdConnectedImageFilter.h"
-#include "clitkSegmentationFunctions.h"
+#include "clitkSegmentationUtils.h"
+#include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
 
 // itk
 #include "itkStatisticsImageFilter.h"
@@ -32,22 +33,26 @@ namespace clitk {
   
   //--------------------------------------------------------------------
   /*
-    Extract bony anatomy through thresholding and connected component labelling.
+    Extract bony anatomy through thresholding and connected component
+    labelling.
   */
   //--------------------------------------------------------------------
   
-  template <class TInputImageType, class TOutputImageType>
+  template <class TInputImageType>
   class ITK_EXPORT ExtractBonesFilter: 
-    public clitk::FilterBase, 
-    public itk::ImageToImageFilter<TInputImageType, TOutputImageType> 
+    public virtual clitk::FilterBase, 
+    public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
+    public itk::ImageToImageFilter<TInputImageType, 
+                                   itk::Image<uchar, TInputImageType::ImageDimension> > 
   {
     
   public:
     /** Standard class typedefs. */
-    typedef ExtractBonesFilter              Self;
-    typedef itk::ImageToImageFilter<TInputImageType, TOutputImageType> Superclass;
-    typedef itk::SmartPointer<Self>         Pointer;
-    typedef itk::SmartPointer<const Self>   ConstPointer;
+    typedef itk::Image<uchar, TInputImageType::ImageDimension>      MaskImageType;
+    typedef ExtractBonesFilter                                      Self;
+    typedef itk::ImageToImageFilter<TInputImageType, MaskImageType> Superclass;
+    typedef itk::SmartPointer<Self>                                 Pointer;
+    typedef itk::SmartPointer<const Self>                           ConstPointer;
     
     /** Method for creation through the object factory. */
     itkNewMacro(Self);  
@@ -65,13 +70,12 @@ namespace clitk {
     typedef typename InputImageType::SizeType     InputImageSizeType; 
     typedef typename InputImageType::IndexType    InputImageIndexType; 
         
-    typedef TOutputImageType                       OutputImageType;
-    typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
-    typedef typename OutputImageType::Pointer      OutputImagePointer;
-    typedef typename OutputImageType::RegionType   OutputImageRegionType; 
-    typedef typename OutputImageType::PixelType    OutputImagePixelType; 
-    typedef typename OutputImageType::SizeType     OutputImageSizeType; 
-    typedef typename OutputImageType::IndexType    OutputImageIndexType; 
+    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;
@@ -83,64 +87,86 @@ namespace clitk {
     /** Connect inputs */
     void SetInput(const InputImageType * image);
  
-    // Set all options at a time
-    template<class ArgsInfoType>
-      void SetArgsInfo(ArgsInfoType arg);
-
     // Background / Foreground
-    itkGetConstMacro(BackgroundValue, OutputImagePixelType);
-    itkGetConstMacro(ForegroundValue, OutputImagePixelType);
+    itkGetConstMacro(BackgroundValue, MaskImagePixelType);
+    itkGetConstMacro(ForegroundValue, MaskImagePixelType);
 
     itkSetMacro(MinimalComponentSize, int);
     itkGetConstMacro(MinimalComponentSize, int);
-    GGO_DefineOption(minSize, SetMinimalComponentSize, int);
+    
+    // Output filename  (for AFBD)
+    itkSetMacro(OutputBonesFilename, std::string);
+    itkGetMacro(OutputBonesFilename, std::string);
+
+    // Step 0
+    itkBooleanMacro(InitialSmoothing);
+    itkSetMacro(InitialSmoothing, bool);
+    itkGetMacro(InitialSmoothing, bool);
+
+    itkSetMacro(SmoothingConductanceParameter, double);
+    itkGetConstMacro(SmoothingConductanceParameter, double);
+    
+    itkSetMacro(SmoothingNumberOfIterations, int);
+    itkGetConstMacro(SmoothingNumberOfIterations, int);
+
+    itkSetMacro(SmoothingTimeStep, double);
+    itkGetConstMacro(SmoothingTimeStep, double);
+
+    itkSetMacro(SmoothingUseImageSpacing, bool);
+    itkGetConstMacro(SmoothingUseImageSpacing, bool);
+    itkBooleanMacro(SmoothingUseImageSpacing);
 
     // Step 1 
     itkSetMacro(UpperThreshold1, InputImagePixelType);
     itkGetMacro(UpperThreshold1, InputImagePixelType);
-    GGO_DefineOption(upper1, SetUpperThreshold1, InputImagePixelType);
 
     itkSetMacro(LowerThreshold1, InputImagePixelType);
     itkGetMacro(LowerThreshold1, InputImagePixelType);
-    GGO_DefineOption(lower1, SetLowerThreshold1, InputImagePixelType);
 
     itkSetMacro(FullConnectivity, bool);
     itkGetConstMacro(FullConnectivity, bool);
     itkBooleanMacro(FullConnectivity);
-    GGO_DefineOption_Flag(full, SetFullConnectivity);
 
     // Step 2 
     itkSetMacro(UpperThreshold2, InputImagePixelType);
     itkGetMacro(UpperThreshold2, InputImagePixelType);
-    GGO_DefineOption(upper2, SetUpperThreshold2, InputImagePixelType);
 
     itkSetMacro(LowerThreshold2, InputImagePixelType);
     itkGetMacro(LowerThreshold2, InputImagePixelType);
-    GGO_DefineOption(lower2, SetLowerThreshold2, InputImagePixelType);
 
     itkSetMacro(Radius2, InputImageSizeType);
     itkGetConstMacro(Radius2, InputImageSizeType);
-    GGO_DefineOption_Vector(radius2, SetRadius2, InputImageSizeType, ImageDimension, true);
 
     itkSetMacro(SampleRate2, int);
     itkGetConstMacro(SampleRate2, int);
-    GGO_DefineOption(sampleRate2, SetSampleRate2, int);
 
-    // Final Step
+    // Step fill holes
+    itkSetMacro(FillHoles, bool);
+    itkGetConstMacro(FillHoles, bool);
+    itkBooleanMacro(FillHoles);
+
+    // Step Auto Crop
     itkSetMacro(AutoCrop, bool);
     itkGetConstMacro(AutoCrop, bool);
     itkBooleanMacro(AutoCrop);
-    GGO_DefineOption_Flag(autoCrop, SetAutoCrop);
 
   protected:
     ExtractBonesFilter();
     virtual ~ExtractBonesFilter() {}
     
     // Global options
-    itkSetMacro(BackgroundValue, OutputImagePixelType);
-    itkSetMacro(ForegroundValue, OutputImagePixelType);
-    OutputImagePixelType m_BackgroundValue;
-    OutputImagePixelType m_ForegroundValue;
+    itkSetMacro(BackgroundValue, MaskImagePixelType);
+    itkSetMacro(ForegroundValue, MaskImagePixelType);
+    MaskImagePixelType m_BackgroundValue;
+    MaskImagePixelType m_ForegroundValue;
+    bool m_AutoCrop;
+
+    // Step 0 : Initial Filtering
+    bool m_InitialSmoothing;
+    double m_SmoothingConductanceParameter;
+    int m_SmoothingNumberOfIterations;
+    double m_SmoothingTimeStep; 
+    bool m_SmoothingUseImageSpacing;
 
     // Step 1
     InputImagePixelType m_UpperThreshold1;
@@ -154,7 +180,9 @@ namespace clitk {
     InputImageSizeType m_Radius2;
     int m_SampleRate2;
     
-    bool m_AutoCrop;
+    // Step 
+    bool m_FillHoles;    
+    InputImageSizeType m_FillHolesDirections;
 
     virtual void GenerateOutputInformation();
     virtual void GenerateData();
@@ -165,8 +193,10 @@ namespace clitk {
     void ExtractBones();
     void RemoveTrachea();
     void BonesSeparation();
+    std::string m_OutputBonesFilename;
     InputImageConstPointer input;
-    OutputImageConstPointer patient;
+    InputImagePointer filtered_input;
+    MaskImageConstPointer patient;
     InputImagePointer working_input;
     typename InternalImageType::Pointer working_image;  
     typename InternalImageType::Pointer trachea;