]> Creatis software - clitk.git/blob - segmentation/clitkExtractLymphStationsFilter.h
cosmetic
[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
75     /** ImageDimension constants */
76     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
77     FILTERBASE_INIT;
78    
79     itkGetConstMacro(BackgroundValue, MaskImagePixelType);
80     itkGetConstMacro(ForegroundValue, MaskImagePixelType);
81     itkSetMacro(BackgroundValue, MaskImagePixelType);
82     itkSetMacro(ForegroundValue, MaskImagePixelType);
83
84     // Station 8
85     itkSetMacro(DistanceMaxToAnteriorPartOfTheSpine, double);
86     itkGetConstMacro(DistanceMaxToAnteriorPartOfTheSpine, double);
87     itkSetMacro(EsophagusDiltationForAnt, MaskImagePointType);
88     itkGetConstMacro(EsophagusDiltationForAnt, MaskImagePointType);
89     itkSetMacro(EsophagusDiltationForRight, MaskImagePointType);
90     itkGetConstMacro(EsophagusDiltationForRight, MaskImagePointType);
91     itkSetMacro(FuzzyThresholdForS8, double);
92     itkGetConstMacro(FuzzyThresholdForS8, double);
93
94     // Station 7
95     itkSetMacro(FuzzyThreshold, double);
96     itkGetConstMacro(FuzzyThreshold, double);
97     itkSetMacro(Station7Filename, std::string);
98     itkGetConstMacro(Station7Filename, std::string);
99
100   protected:
101     ExtractLymphStationsFilter();
102     virtual ~ExtractLymphStationsFilter() {}
103     
104     virtual void GenerateOutputInformation();
105     virtual void GenerateInputRequestedRegion();
106     virtual void GenerateData();
107     
108     ImageConstPointer  m_Input;
109     MaskImagePointer   m_Mediastinum;
110     MaskImagePointer   m_Working_Support;
111     std::map<std::string, MaskImagePointer> m_ListOfStations;
112     MaskImagePixelType m_BackgroundValue;
113     MaskImagePixelType m_ForegroundValue;    
114
115     // Station 8
116     double m_DistanceMaxToAnteriorPartOfTheSpine;
117     double m_DiaphragmInferiorLimit;
118     double m_CarinaZ;
119     double m_OriginOfRightMiddleLobeBronchusZ;
120     double m_FuzzyThresholdForS8;
121     MaskImagePointType m_EsophagusDiltationForAnt;
122     MaskImagePointType m_EsophagusDiltationForRight;
123     MaskImagePointer EnlargeEsophagusDilatationRadiusInferiorly(MaskImagePointer & eso);
124     void ExtractStation_8();
125     void ExtractStation_8_SI_Limits();
126     void ExtractStation_8_Post_Limits();
127     void ExtractStation_8_Ant_Limits();
128     void ExtractStation_8_LR_Limits();
129     void ExtractStation_8_LR_Limits_old();
130  
131     // Station 7
132     void ExtractStation_7();
133     void ExtractStation_7_SI_Limits();
134     void ExtractStation_7_RL_Limits();
135     void ExtractStation_7_Posterior_Limits();   
136     std::string      m_Station7Filename;
137     MaskImagePointer m_working_trachea;
138     double           m_FuzzyThreshold;
139     MaskImagePointer m_LeftBronchus;
140     MaskImagePointer m_RightBronchus;
141     MaskImagePointer m_Station7;
142     typedef std::vector<MaskImageType::PointType> ListOfPointsType;
143     ListOfPointsType  m_RightMostInLeftBronchus;
144     ListOfPointsType  m_AntMostInLeftBronchus;
145     ListOfPointsType  m_PostMostInLeftBronchus;
146     ListOfPointsType  m_LeftMostInRightBronchus;
147     ListOfPointsType  m_AntMostInRightBronchus;
148     ListOfPointsType  m_PostMostInRightBronchus;
149
150     void FindExtremaPointsInBronchus(MaskImagePointer input, 
151                                      int direction,
152                                      double distance_max_from_center_point, 
153                                      ListOfPointsType & LR, 
154                                      ListOfPointsType & Ant, 
155                                      ListOfPointsType & Post);
156     // Station 4RL
157     void ExtractStation_4RL();
158     void ExtractStation_4RL_SI_Limits();
159     void ExtractStation_4RL_LR_Limits();
160     void ExtractStation_4RL_AP_Limits();
161     MaskImagePointer m_RightSupport;
162     MaskImagePointer m_LeftSupport;
163
164   private:
165     ExtractLymphStationsFilter(const Self&); //purposely not implemented
166     void operator=(const Self&); //purposely not implemented
167     
168   }; // end class
169   //--------------------------------------------------------------------
170
171 } // end namespace clitk
172 //--------------------------------------------------------------------
173
174 #ifndef ITK_MANUAL_INSTANTIATION
175 #include "clitkExtractLymphStationsFilter.txx"
176 #include "clitkExtractLymphStation_8.txx"
177 #include "clitkExtractLymphStation_7.txx"
178 #include "clitkExtractLymphStation_4RL.txx"
179 #endif
180
181 #endif