1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #ifndef CLITKEXTRACTLYMPHSTATIONSFILTER_H
20 #define CLITKEXTRACTLYMPHSTATIONSFILTER_H
23 #include "clitkFilterBase.h"
24 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
28 //--------------------------------------------------------------------
30 Try to extract the LymphStations part of a thorax CT.
31 Need a set of Anatomical Features (AFDB)
33 //--------------------------------------------------------------------
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> >
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;
49 /** Method for creation through the object factory. */
52 /** Run-time type information (and related methods). */
53 itkTypeMacro(ExtractLymphStationsFilter, ImageToImageFilter);
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;
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;
73 typedef itk::Image<MaskImagePixelType, 2> MaskSliceType;
74 typedef typename MaskSliceType::Pointer MaskSlicePointer;
76 /** ImageDimension constants */
77 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
80 itkGetConstMacro(BackgroundValue, MaskImagePixelType);
81 itkGetConstMacro(ForegroundValue, MaskImagePixelType);
82 itkSetMacro(BackgroundValue, MaskImagePixelType);
83 itkSetMacro(ForegroundValue, MaskImagePixelType);
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);
95 itkSetMacro(InjectedThresholdForS8, double);
96 itkGetConstMacro(InjectedThresholdForS8, double);
99 void SetFuzzyThresholdForS7(std::string tag, double value);
100 double GetFuzzyThresholdForS7(std::string tag);
103 bool GetComputeStation(std::string s);
104 void AddComputeStation(std::string station) ;
107 ExtractLymphStationsFilter();
108 virtual ~ExtractLymphStationsFilter() {}
110 virtual void GenerateOutputInformation();
111 virtual void GenerateInputRequestedRegion();
112 virtual void GenerateData();
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;
122 bool CheckForStation(std::string station);
123 void Remove_Structures(std::string s);
126 double m_DistanceMaxToAnteriorPartOfTheSpine;
127 double m_DiaphragmInferiorLimit;
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();
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();
163 void ExtractStation_3A();
164 void ExtractStation_3A_SetDefaultValues();
165 void ExtractStation_3A_SI_Limits();
166 void ExtractStation_3A_Ant_Limits();
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;
187 void FindExtremaPointsInBronchus(MaskImagePointer input,
189 double distance_max_from_center_point,
190 ListOfPointsType & LR,
191 ListOfPointsType & Ant,
192 ListOfPointsType & Post);
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;
202 ExtractLymphStationsFilter(const Self&); //purposely not implemented
203 void operator=(const Self&); //purposely not implemented
206 //--------------------------------------------------------------------
208 } // end namespace clitk
209 //--------------------------------------------------------------------
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"