]> Creatis software - clitk.git/blob - segmentation/clitkExtractLymphStationsFilter.h
small improvement for S8
[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     itkSetMacro(FuzzyThreshold, double);
100     itkGetConstMacro(FuzzyThreshold, double);
101     itkSetMacro(Station7Filename, std::string);
102     itkGetConstMacro(Station7Filename, std::string);
103     
104     bool GetComputeStation(std::string s);
105     void AddComputeStation(std::string station) ;
106
107   protected:
108     ExtractLymphStationsFilter();
109     virtual ~ExtractLymphStationsFilter() {}
110     
111     virtual void GenerateOutputInformation();
112     virtual void GenerateInputRequestedRegion();
113     virtual void GenerateData();
114     
115     ImageConstPointer  m_Input;
116     MaskImagePointer   m_Mediastinum;
117     MaskImagePointer   m_Working_Support;
118     std::map<std::string, MaskImagePointer> m_ListOfStations;
119     MaskImagePixelType m_BackgroundValue;
120     MaskImagePixelType m_ForegroundValue;
121     std::map<std::string, bool> m_ComputeStationMap;
122
123     bool CheckForStation(std::string station);
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_inf_Limits();
160
161     // Station 7
162     void ExtractStation_7();
163     void ExtractStation_7_SI_Limits();
164     void ExtractStation_7_RL_Limits();
165     void ExtractStation_7_Posterior_Limits();   
166     std::string      m_Station7Filename;
167     MaskImagePointer m_working_trachea;
168     double           m_FuzzyThreshold;
169     MaskImagePointer m_LeftBronchus;
170     MaskImagePointer m_RightBronchus;
171     MaskImagePointer m_Station7;
172     typedef std::vector<MaskImageType::PointType> ListOfPointsType;
173     ListOfPointsType  m_RightMostInLeftBronchus;
174     ListOfPointsType  m_AntMostInLeftBronchus;
175     ListOfPointsType  m_PostMostInLeftBronchus;
176     ListOfPointsType  m_LeftMostInRightBronchus;
177     ListOfPointsType  m_AntMostInRightBronchus;
178     ListOfPointsType  m_PostMostInRightBronchus;
179
180     void FindExtremaPointsInBronchus(MaskImagePointer input, 
181                                      int direction,
182                                      double distance_max_from_center_point, 
183                                      ListOfPointsType & LR, 
184                                      ListOfPointsType & Ant, 
185                                      ListOfPointsType & Post);
186     // Station 4RL
187     void ExtractStation_4RL();
188     void ExtractStation_4RL_SI_Limits();
189     void ExtractStation_4RL_LR_Limits();
190     void ExtractStation_4RL_AP_Limits();
191     MaskImagePointer m_RightSupport;
192     MaskImagePointer m_LeftSupport;
193
194   private:
195     ExtractLymphStationsFilter(const Self&); //purposely not implemented
196     void operator=(const Self&); //purposely not implemented
197     
198   }; // end class
199   //--------------------------------------------------------------------
200
201 } // end namespace clitk
202 //--------------------------------------------------------------------
203
204 #ifndef ITK_MANUAL_INSTANTIATION
205 #include "clitkExtractLymphStationsFilter.txx"
206 #include "clitkExtractLymphStation_8.txx"
207 #include "clitkExtractLymphStation_3P.txx"
208 #include "clitkExtractLymphStation_7.txx"
209 #include "clitkExtractLymphStation_4RL.txx"
210 #endif
211
212 #endif