]> Creatis software - clitk.git/blob - segmentation/clitkExtractLymphStationsFilter.h
d67dfa2bce61a4d6daf83e503e7bb2fd766c6268
[clitk.git] / segmentation / clitkExtractLymphStationsFilter.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 CLITKEXTRACTLYMPHSTATIONSFILTER_H
20 #define CLITKEXTRACTLYMPHSTATIONSFILTER_H
21
22 // clitk
23 #include "clitkFilterBase.h"
24 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
25
26 namespace clitk {
27   
28   //--------------------------------------------------------------------
29   /*
30     Try to extract the LymphStations part of a thorax CT.
31     Need a set of Anatomical Features (AFDB)
32   */
33   //--------------------------------------------------------------------
34   
35   template <class TImageType>
36   class ITK_EXPORT ExtractLymphStationsFilter: 
37     public virtual clitk::FilterBase, 
38     public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
39     public itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> >
40   {
41
42   public:
43     /** Standard class typedefs. */
44     typedef itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> > Superclass;
45     typedef ExtractLymphStationsFilter          Self;
46     typedef itk::SmartPointer<Self>             Pointer;
47     typedef itk::SmartPointer<const Self>       ConstPointer;
48     
49     /** Method for creation through the object factory. */
50     itkNewMacro(Self);
51     
52     /** Run-time type information (and related methods). */
53     itkTypeMacro(ExtractLymphStationsFilter, ImageToImageFilter);
54
55     /** Some convenient typedefs. */
56     typedef TImageType                       ImageType;
57     typedef typename ImageType::ConstPointer ImageConstPointer;
58     typedef typename ImageType::Pointer      ImagePointer;
59     typedef typename ImageType::RegionType   ImageRegionType; 
60     typedef typename ImageType::PixelType    ImagePixelType; 
61     typedef typename ImageType::SizeType     ImageSizeType; 
62     typedef typename ImageType::IndexType    ImageIndexType; 
63     typedef typename ImageType::PointType    ImagePointType; 
64         
65     typedef uchar MaskImagePixelType;
66     typedef itk::Image<MaskImagePixelType, 3>    MaskImageType;  
67     typedef typename MaskImageType::Pointer      MaskImagePointer;
68     typedef typename MaskImageType::RegionType   MaskImageRegionType; 
69     typedef typename MaskImageType::SizeType     MaskImageSizeType; 
70     typedef typename MaskImageType::IndexType    MaskImageIndexType; 
71     typedef typename MaskImageType::PointType    MaskImagePointType; 
72
73     typedef itk::Image<MaskImagePixelType, 2>    MaskSliceType;
74     typedef typename MaskSliceType::Pointer      MaskSlicePointer;
75
76     /** ImageDimension constants */
77     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
78     FILTERBASE_INIT;
79    
80     itkGetConstMacro(BackgroundValue, MaskImagePixelType);
81     itkGetConstMacro(ForegroundValue, MaskImagePixelType);
82     itkSetMacro(BackgroundValue, MaskImagePixelType);
83     itkSetMacro(ForegroundValue, MaskImagePixelType);
84
85     // Station 8
86     itkSetMacro(DistanceMaxToAnteriorPartOfTheSpine, double);
87     itkGetConstMacro(DistanceMaxToAnteriorPartOfTheSpine, double);
88     itkSetMacro(EsophagusDiltationForAnt, MaskImagePointType);
89     itkGetConstMacro(EsophagusDiltationForAnt, MaskImagePointType);
90     itkSetMacro(EsophagusDiltationForRight, MaskImagePointType);
91     itkGetConstMacro(EsophagusDiltationForRight, MaskImagePointType);
92     itkSetMacro(FuzzyThresholdForS8, double);
93     itkGetConstMacro(FuzzyThresholdForS8, double);
94
95     itkSetMacro(InjectedThresholdForS8, double);
96     itkGetConstMacro(InjectedThresholdForS8, double);
97
98     // Station 7
99     void SetFuzzyThresholdForS7(std::string tag, double value);
100     double GetFuzzyThresholdForS7(std::string tag);
101
102     // All stations
103     bool GetComputeStation(std::string s);
104     void AddComputeStation(std::string station) ;
105
106   protected:
107     ExtractLymphStationsFilter();
108     virtual ~ExtractLymphStationsFilter() {}
109     
110     virtual void GenerateOutputInformation();
111     virtual void GenerateInputRequestedRegion();
112     virtual void GenerateData();
113     
114     ImageConstPointer  m_Input;
115     MaskImagePointer   m_Mediastinum;
116     MaskImagePointer   m_Working_Support;
117     std::map<std::string, MaskImagePointer> m_ListOfStations;
118     MaskImagePixelType m_BackgroundValue;
119     MaskImagePixelType m_ForegroundValue;
120     std::map<std::string, bool> m_ComputeStationMap;
121
122     bool CheckForStation(std::string station);
123     void Remove_Structures(std::string s);
124
125     // Station 8
126     double m_DistanceMaxToAnteriorPartOfTheSpine;
127     double m_DiaphragmInferiorLimit;
128     double m_CarinaZ;
129     double m_OriginOfRightMiddleLobeBronchusZ;
130     double m_FuzzyThresholdForS8;
131     double m_InjectedThresholdForS8;
132     MaskImagePointer m_Esophagus;
133     MaskImagePointType m_EsophagusDiltationForAnt;
134     MaskImagePointType m_EsophagusDiltationForRight;
135     MaskImagePointer EnlargeEsophagusDilatationRadiusInferiorly(MaskImagePointer & eso);
136     void ExtractStation_8();
137     void ExtractStation_8_SetDefaultValues();
138     void ExtractStation_8_SI_Limits();
139     void ExtractStation_8_Post_Limits();
140     void ExtractStation_8_Ant_Sup_Limits();
141     void ExtractStation_8_Ant_Inf_Limits();
142     void ExtractStation_8_Ant_Injected_Limits();
143     void ExtractStation_8_LR_1_Limits();
144     void ExtractStation_8_LR_2_Limits();
145     void ExtractStation_8_Single_CCL_Limits();
146     void ExtractStation_8_LR_Limits();
147     void ExtractStation_8_Remove_Structures();
148     void ExtractStation_8_LR_Limits_old();
149     void ExtractStation_8_LR_Limits_old2();
150     
151     // Station 3P
152     void ExtractStation_3P();
153     void ExtractStation_3P_SetDefaultValues();
154     void ExtractStation_3P_SI_Limits();
155     void ExtractStation_3P_Remove_Structures();
156     void ExtractStation_3P_Ant_Limits();
157     void ExtractStation_3P_Post_Limits();
158     void ExtractStation_3P_LR_sup_Limits();
159     void ExtractStation_3P_LR_sup_Limits_2();
160     void ExtractStation_3P_LR_inf_Limits();
161
162     // Station 3A
163     void ExtractStation_3A();
164     void ExtractStation_3A_SetDefaultValues();
165     void ExtractStation_3A_SI_Limits();
166     void ExtractStation_3A_Ant_Limits();
167
168     // Station 7
169     void ExtractStation_7();
170     void ExtractStation_7_SetDefaultValues();
171     void ExtractStation_7_SI_Limits();
172     void ExtractStation_7_RL_Limits();
173     void ExtractStation_7_Posterior_Limits();   
174     void ExtractStation_7_Remove_Structures();
175     MaskImagePointer m_Working_Trachea;
176     std::map<std::string, double> m_FuzzyThresholdForS7;
177     MaskImagePointer m_LeftBronchus;
178     MaskImagePointer m_RightBronchus;
179     typedef std::vector<MaskImageType::PointType> ListOfPointsType;
180     ListOfPointsType  m_RightMostInLeftBronchus;
181     ListOfPointsType  m_AntMostInLeftBronchus;
182     ListOfPointsType  m_PostMostInLeftBronchus;
183     ListOfPointsType  m_LeftMostInRightBronchus;
184     ListOfPointsType  m_AntMostInRightBronchus;
185     ListOfPointsType  m_PostMostInRightBronchus;
186
187     void FindExtremaPointsInBronchus(MaskImagePointer input, 
188                                      int direction,
189                                      double distance_max_from_center_point, 
190                                      ListOfPointsType & LR, 
191                                      ListOfPointsType & Ant, 
192                                      ListOfPointsType & Post);
193     // Station 4RL
194     void ExtractStation_4RL();
195     void ExtractStation_4RL_SI_Limits();
196     void ExtractStation_4RL_LR_Limits();
197     void ExtractStation_4RL_AP_Limits();
198     MaskImagePointer m_RightSupport;
199     MaskImagePointer m_LeftSupport;
200
201   private:
202     ExtractLymphStationsFilter(const Self&); //purposely not implemented
203     void operator=(const Self&); //purposely not implemented
204     
205   }; // end class
206   //--------------------------------------------------------------------
207
208 } // end namespace clitk
209 //--------------------------------------------------------------------
210
211 #ifndef ITK_MANUAL_INSTANTIATION
212 #include "clitkExtractLymphStationsFilter.txx"
213 #include "clitkExtractLymphStation_8.txx"
214 #include "clitkExtractLymphStation_3P.txx"
215 #include "clitkExtractLymphStation_3A.txx"
216 #include "clitkExtractLymphStation_7.txx"
217 #include "clitkExtractLymphStation_4RL.txx"
218 #endif
219
220 #endif