]> Creatis software - clitk.git/blob - segmentation/clitkExtractMediastinumFilter.h
f0d24b4300d451423c8a951e604f0fe1bf377e72
[clitk.git] / segmentation / clitkExtractMediastinumFilter.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ======================================================================-====*/
18
19 #ifndef CLITKEXTRACTMEDIASTINUMFILTER_H
20 #define CLITKEXTRACTMEDIASTINUMFILTER_H
21
22 #include "clitkFilterBase.h"
23 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
24
25 namespace clitk {
26   
27   //--------------------------------------------------------------------
28   /*
29     Try to extract the mediastinum part of a thorax CT.
30     Inputs : 
31     - Patient label image
32     - Lungs label image
33     - Bones label image
34     - Trachea label image
35   */
36   //--------------------------------------------------------------------
37   
38   template <class TImageType>
39   class ITK_EXPORT ExtractMediastinumFilter: 
40     public virtual clitk::FilterBase, 
41     public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
42     public itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> > 
43   {
44
45   public:
46     /** Some convenient typedefs. */
47     typedef TImageType                       ImageType;
48     typedef typename ImageType::ConstPointer ImageConstPointer;
49     typedef typename ImageType::Pointer      ImagePointer;
50     typedef typename ImageType::RegionType   ImageRegionType; 
51     typedef typename ImageType::PixelType    ImagePixelType; 
52     typedef typename ImageType::SizeType     ImageSizeType; 
53     typedef typename ImageType::IndexType    ImageIndexType; 
54     typedef typename ImageType::PointType    ImagePointType; 
55         
56     /** Some convenient typedefs. */
57     typedef uchar MaskImagePixelType; 
58     typedef itk::Image<MaskImagePixelType, 3>    MaskImageType;
59     typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
60     typedef typename MaskImageType::Pointer      MaskImagePointer;
61     typedef typename MaskImageType::RegionType   MaskImageRegionType; 
62     typedef typename MaskImageType::SizeType     MaskImageSizeType; 
63     typedef typename MaskImageType::IndexType    MaskImageIndexType; 
64     typedef typename MaskImageType::PointType    MaskImagePointType; 
65         
66     /** Standard class typedefs. */
67     typedef itk::ImageToImageFilter<TImageType, MaskImageType> Superclass;
68     typedef ExtractMediastinumFilter            Self;
69     typedef itk::SmartPointer<Self>             Pointer;
70     typedef itk::SmartPointer<const Self>       ConstPointer;
71     
72     /** Method for creation through the object factory. */
73     itkNewMacro(Self);
74     
75     /** Run-time type information (and related methods). */
76     itkTypeMacro(ExtractMediastinumFilter, InPlaceImageFilter);
77     FILTERBASE_INIT;
78
79     /** Connect inputs */
80     void SetInput(const ImageType * image);
81     void SetInputPatientLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
82     void SetInputLungLabelImage(const MaskImageType * image, MaskImagePixelType bg=0, 
83                                 MaskImagePixelType fgLeftLung=1, MaskImagePixelType fgRightLung=2);
84     void SetInputBonesLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
85     void SetInputTracheaLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
86    
87    // Output filename  (for AFBD)
88     itkSetMacro(OutputMediastinumFilename, std::string);
89     itkGetConstMacro(OutputMediastinumFilename, std::string);
90
91     /** ImageDimension constants */
92     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
93
94     // Set all options at a time
95     template<class ArgsInfoType>
96       void SetArgsInfo(ArgsInfoType arg);
97    
98     // Background / Foreground
99     itkSetMacro(BackgroundValuePatient, MaskImagePixelType);
100     itkGetConstMacro(BackgroundValuePatient, MaskImagePixelType);
101     // GGO_DefineOption(patientBG, SetBackgroundValuePatient, MaskImagePixelType);
102     
103     itkSetMacro(BackgroundValueLung, MaskImagePixelType);
104     itkGetConstMacro(BackgroundValueLung, MaskImagePixelType);
105     // GGO_DefineOption(lungBG, SetBackgroundValueLung, MaskImagePixelType);
106     
107     itkSetMacro(BackgroundValueBones, MaskImagePixelType);
108     itkGetConstMacro(BackgroundValueBones, MaskImagePixelType);
109     // GGO_DefineOption(bonesBG, SetBackgroundValueBones, MaskImagePixelType);
110     
111     itkGetConstMacro(BackgroundValue, MaskImagePixelType);
112     itkGetConstMacro(ForegroundValue, MaskImagePixelType);
113
114     itkSetMacro(ForegroundValueLeftLung, MaskImagePixelType);
115     itkGetConstMacro(ForegroundValueLeftLung, MaskImagePixelType);
116     // GGO_DefineOption(lungLeft, SetForegroundValueLeftLung, MaskImagePixelType);
117     
118     itkSetMacro(ForegroundValueRightLung, MaskImagePixelType);
119     itkGetConstMacro(ForegroundValueRightLung, MaskImagePixelType);
120     // GGO_DefineOption(lungRight, SetForegroundValueRightLung, MaskImagePixelType);
121     
122     itkSetMacro(BackgroundValueTrachea, MaskImagePixelType);
123     itkGetConstMacro(BackgroundValueTrachea, MaskImagePixelType);
124     // GGO_DefineOption(lungBG, SetBackgroundValueTrachea, MaskImagePixelType);
125     
126     itkSetMacro(IntermediateSpacing, double);
127     itkGetConstMacro(IntermediateSpacing, double);
128     GGO_DefineOption(spacing, SetIntermediateSpacing, double);
129
130     itkSetMacro(FuzzyThreshold1, double);
131     itkGetConstMacro(FuzzyThreshold1, double);
132     GGO_DefineOption(fuzzy1, SetFuzzyThreshold1, double);
133
134     itkSetMacro(FuzzyThreshold2, double);
135     itkGetConstMacro(FuzzyThreshold2, double);
136     GGO_DefineOption(fuzzy2, SetFuzzyThreshold2, double);
137
138     itkSetMacro(FuzzyThreshold3, double);
139     itkGetConstMacro(FuzzyThreshold3, double);
140     GGO_DefineOption(fuzzy3, SetFuzzyThreshold3, double);
141
142     itkSetMacro(DistanceMaxToAnteriorPartOfTheSpine, double);
143     itkGetConstMacro(DistanceMaxToAnteriorPartOfTheSpine, double);
144     GGO_DefineOption(antSpine, SetDistanceMaxToAnteriorPartOfTheSpine, double);
145
146     itkBooleanMacro(UseBones);
147     itkSetMacro(UseBones, bool);
148     itkGetConstMacro(UseBones, bool);
149     GGO_DefineOption_Flag(useBones, SetUseBones);
150
151     itkSetMacro(UpperThreshold, double);
152     itkGetConstMacro(UpperThreshold, double);
153     GGO_DefineOption(upper, SetUpperThreshold, double);
154
155     itkSetMacro(LowerThreshold, double);
156     itkGetConstMacro(LowerThreshold, double);
157     GGO_DefineOption(lower, SetLowerThreshold, double);
158
159   protected:
160     ExtractMediastinumFilter();
161     virtual ~ExtractMediastinumFilter() {}
162     
163     virtual void GenerateOutputInformation();
164     virtual void GenerateInputRequestedRegion();
165     virtual void GenerateData();
166        
167     itkSetMacro(BackgroundValue, MaskImagePixelType);
168     itkSetMacro(ForegroundValue, MaskImagePixelType);
169     
170     MaskImagePixelType m_BackgroundValuePatient;
171     MaskImagePixelType m_BackgroundValueLung;
172     MaskImagePixelType m_BackgroundValueBones;
173     MaskImagePixelType m_BackgroundValueTrachea;
174     MaskImagePixelType m_ForegroundValueLeftLung;
175     MaskImagePixelType m_ForegroundValueRightLung;
176
177     MaskImagePixelType m_BackgroundValue;
178     MaskImagePixelType m_ForegroundValue;
179
180     typename MaskImageType::Pointer output;
181
182     double m_IntermediateSpacing;
183     double m_FuzzyThreshold1;
184     double m_FuzzyThreshold2;
185     double m_FuzzyThreshold3;
186     double m_DistanceMaxToAnteriorPartOfTheSpine;
187     bool m_UseBones;
188     double m_UpperThreshold;
189     double m_LowerThreshold;
190     
191     std::string m_OutputMediastinumFilename;
192     
193   private:
194     ExtractMediastinumFilter(const Self&); //purposely not implemented
195     void operator=(const Self&); //purposely not implemented
196     
197   }; // end class
198   //--------------------------------------------------------------------
199
200 } // end namespace clitk
201 //--------------------------------------------------------------------
202
203 #ifndef ITK_MANUAL_INSTANTIATION
204 #include "clitkExtractMediastinumFilter.txx"
205 #endif
206
207 #endif