]> Creatis software - clitk.git/blob - segmentation/clitkExtractMediastinumFilter.h
Attempt to manually adjust the layout of the overlay panel for fusion to minimize...
[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://www.centreleonberard.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     Input masks needed : 
31     - Patient
32     - Lungs 
33     - Bones [Optional]
34     - Trachea
35     - VertebralBody 
36   */
37   //--------------------------------------------------------------------
38   
39   template <class TImageType>
40   class ITK_EXPORT ExtractMediastinumFilter: 
41     public virtual clitk::FilterBase, 
42     public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
43     public itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> > 
44   {
45
46   public:
47     /** Some convenient typedefs. */
48     typedef TImageType                       ImageType;
49     typedef typename ImageType::ConstPointer ImageConstPointer;
50     typedef typename ImageType::Pointer      ImagePointer;
51     typedef typename ImageType::RegionType   ImageRegionType; 
52     typedef typename ImageType::PixelType    ImagePixelType; 
53     typedef typename ImageType::SizeType     ImageSizeType; 
54     typedef typename ImageType::IndexType    ImageIndexType; 
55     typedef typename ImageType::PointType    ImagePointType; 
56         
57     /** Some convenient typedefs. */
58     typedef uchar MaskImagePixelType; 
59     typedef itk::Image<MaskImagePixelType, 3>    MaskImageType;
60     typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
61     typedef typename MaskImageType::Pointer      MaskImagePointer;
62     typedef typename MaskImageType::RegionType   MaskImageRegionType; 
63     typedef typename MaskImageType::SizeType     MaskImageSizeType; 
64     typedef typename MaskImageType::IndexType    MaskImageIndexType; 
65     typedef typename MaskImageType::PointType    MaskImagePointType; 
66         
67     typedef itk::Image<MaskImagePixelType, 2>    MaskSliceType;
68     typedef typename MaskSliceType::Pointer      MaskSlicePointer;
69     typedef typename MaskSliceType::PointType    MaskSlicePointType;
70
71     /** Standard class typedefs. */
72     typedef itk::ImageToImageFilter<TImageType, MaskImageType> Superclass;
73     typedef ExtractMediastinumFilter            Self;
74     typedef itk::SmartPointer<Self>             Pointer;
75     typedef itk::SmartPointer<const Self>       ConstPointer;
76     
77     /** Method for creation through the object factory. */
78     itkNewMacro(Self);
79     
80     /** Run-time type information (and related methods). */
81     itkTypeMacro(ExtractMediastinumFilter, InPlaceImageFilter);
82     FILTERBASE_INIT;
83
84     /** Connect inputs */
85     void SetInput(const ImageType * image);
86     void SetInputPatientLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
87     void SetInputLungLabelImage(const MaskImageType * image, MaskImagePixelType bg=0, 
88                                 MaskImagePixelType fgLeftLung=1, MaskImagePixelType fgRightLung=2);
89     void SetInputBonesLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
90     void SetInputTracheaLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
91    
92    // Output filename  (for AFBD)
93     itkSetMacro(OutputMediastinumFilename, std::string);
94     itkGetConstMacro(OutputMediastinumFilename, std::string);
95
96     /** ImageDimension constants */
97     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
98
99     // Background / Foreground
100     itkSetMacro(BackgroundValuePatient, MaskImagePixelType);
101     itkGetConstMacro(BackgroundValuePatient, MaskImagePixelType);
102     
103     itkSetMacro(BackgroundValueLung, MaskImagePixelType);
104     itkGetConstMacro(BackgroundValueLung, MaskImagePixelType);
105     
106     itkSetMacro(BackgroundValueBones, MaskImagePixelType);
107     itkGetConstMacro(BackgroundValueBones, MaskImagePixelType);
108     
109     itkGetConstMacro(BackgroundValue, MaskImagePixelType);
110     itkGetConstMacro(ForegroundValue, MaskImagePixelType);
111
112     itkSetMacro(ForegroundValueLeftLung, MaskImagePixelType);
113     itkGetConstMacro(ForegroundValueLeftLung, MaskImagePixelType);
114     
115     itkSetMacro(ForegroundValueRightLung, MaskImagePixelType);
116     itkGetConstMacro(ForegroundValueRightLung, MaskImagePixelType);
117     
118     itkSetMacro(BackgroundValueTrachea, MaskImagePixelType);
119     itkGetConstMacro(BackgroundValueTrachea, MaskImagePixelType);
120     
121     itkSetMacro(IntermediateSpacing, double);
122     itkGetConstMacro(IntermediateSpacing, double);
123
124     itkBooleanMacro(UseBones);
125     itkSetMacro(UseBones, bool);
126     itkGetConstMacro(UseBones, bool);
127
128     itkSetMacro(DistanceMaxToAnteriorPartOfTheVertebralBody, double);
129     itkGetConstMacro(DistanceMaxToAnteriorPartOfTheVertebralBody, double);
130
131     void SetFuzzyThreshold(std::string tag, double value);
132     double GetFuzzyThreshold(std::string tag);
133
134   protected:
135     ExtractMediastinumFilter();
136     virtual ~ExtractMediastinumFilter() {}
137     
138     virtual void GenerateOutputInformation();
139     virtual void GenerateInputRequestedRegion();
140     virtual void GenerateData();
141        
142     itkSetMacro(BackgroundValue, MaskImagePixelType);
143     itkSetMacro(ForegroundValue, MaskImagePixelType);
144     
145     MaskImagePixelType m_BackgroundValuePatient;
146     MaskImagePixelType m_BackgroundValueLung;
147     MaskImagePixelType m_BackgroundValueBones;
148     MaskImagePixelType m_BackgroundValueTrachea;
149     MaskImagePixelType m_ForegroundValueLeftLung;
150     MaskImagePixelType m_ForegroundValueRightLung;
151
152     MaskImagePixelType m_BackgroundValue;
153     MaskImagePixelType m_ForegroundValue;
154
155     MaskImagePointer output;
156     MaskImagePointer patient;
157     MaskImagePointer lung;
158     MaskImagePointer bones;
159     MaskImagePointer trachea;
160
161     std::map<std::string, double> m_FuzzyThreshold;
162     double m_IntermediateSpacing;
163     bool   m_UseBones;
164     double m_DistanceMaxToAnteriorPartOfTheVertebralBody;
165
166     void RemovePostPartOfVertebralBody();
167     
168     std::string m_OutputMediastinumFilename;
169     
170   private:
171     ExtractMediastinumFilter(const Self&); //purposely not implemented
172     void operator=(const Self&); //purposely not implemented
173     
174   }; // end class
175   //--------------------------------------------------------------------
176
177 } // end namespace clitk
178 //--------------------------------------------------------------------
179
180 #ifndef ITK_MANUAL_INSTANTIATION
181 #include "clitkExtractMediastinumFilter.txx"
182 #endif
183
184 #endif