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://oncora1.lyon.fnclcc.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;
75 /** ImageDimension constants */
76 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
79 itkGetConstMacro(BackgroundValue, MaskImagePixelType);
80 itkGetConstMacro(ForegroundValue, MaskImagePixelType);
81 itkSetMacro(BackgroundValue, MaskImagePixelType);
82 itkSetMacro(ForegroundValue, MaskImagePixelType);
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);
95 itkSetMacro(FuzzyThreshold, double);
96 itkGetConstMacro(FuzzyThreshold, double);
97 itkSetMacro(Station7Filename, std::string);
98 itkGetConstMacro(Station7Filename, std::string);
100 bool GetComputeStation(std::string s);
101 void AddComputeStation(std::string station) ;
104 ExtractLymphStationsFilter();
105 virtual ~ExtractLymphStationsFilter() {}
107 virtual void GenerateOutputInformation();
108 virtual void GenerateInputRequestedRegion();
109 virtual void GenerateData();
111 ImageConstPointer m_Input;
112 MaskImagePointer m_Mediastinum;
113 MaskImagePointer m_Working_Support;
114 std::map<std::string, MaskImagePointer> m_ListOfStations;
115 MaskImagePixelType m_BackgroundValue;
116 MaskImagePixelType m_ForegroundValue;
117 std::map<std::string, bool> m_ComputeStationMap;
119 bool CheckForStation(std::string station);
122 double m_DistanceMaxToAnteriorPartOfTheSpine;
123 double m_DiaphragmInferiorLimit;
125 double m_OriginOfRightMiddleLobeBronchusZ;
126 double m_FuzzyThresholdForS8;
127 MaskImagePointType m_EsophagusDiltationForAnt;
128 MaskImagePointType m_EsophagusDiltationForRight;
129 MaskImagePointer EnlargeEsophagusDilatationRadiusInferiorly(MaskImagePointer & eso);
130 void ExtractStation_8();
131 void ExtractStation_8_SetDefaultValues();
132 void ExtractStation_8_SI_Limits();
133 void ExtractStation_8_Post_Limits();
134 void ExtractStation_8_Ant_Limits();
135 void ExtractStation_8_LR_Limits();
136 void ExtractStation_8_LR_Limits_old();
139 void ExtractStation_3P();
140 void ExtractStation_3P_SetDefaultValues();
141 void ExtractStation_3P_SI_Limits();
144 void ExtractStation_7();
145 void ExtractStation_7_SI_Limits();
146 void ExtractStation_7_RL_Limits();
147 void ExtractStation_7_Posterior_Limits();
148 std::string m_Station7Filename;
149 MaskImagePointer m_working_trachea;
150 double m_FuzzyThreshold;
151 MaskImagePointer m_LeftBronchus;
152 MaskImagePointer m_RightBronchus;
153 MaskImagePointer m_Station7;
154 typedef std::vector<MaskImageType::PointType> ListOfPointsType;
155 ListOfPointsType m_RightMostInLeftBronchus;
156 ListOfPointsType m_AntMostInLeftBronchus;
157 ListOfPointsType m_PostMostInLeftBronchus;
158 ListOfPointsType m_LeftMostInRightBronchus;
159 ListOfPointsType m_AntMostInRightBronchus;
160 ListOfPointsType m_PostMostInRightBronchus;
162 void FindExtremaPointsInBronchus(MaskImagePointer input,
164 double distance_max_from_center_point,
165 ListOfPointsType & LR,
166 ListOfPointsType & Ant,
167 ListOfPointsType & Post);
169 void ExtractStation_4RL();
170 void ExtractStation_4RL_SI_Limits();
171 void ExtractStation_4RL_LR_Limits();
172 void ExtractStation_4RL_AP_Limits();
173 MaskImagePointer m_RightSupport;
174 MaskImagePointer m_LeftSupport;
177 ExtractLymphStationsFilter(const Self&); //purposely not implemented
178 void operator=(const Self&); //purposely not implemented
181 //--------------------------------------------------------------------
183 } // end namespace clitk
184 //--------------------------------------------------------------------
186 #ifndef ITK_MANUAL_INSTANTIATION
187 #include "clitkExtractLymphStationsFilter.txx"
188 #include "clitkExtractLymphStation_8.txx"
189 #include "clitkExtractLymphStation_3P.txx"
190 #include "clitkExtractLymphStation_7.txx"
191 #include "clitkExtractLymphStation_4RL.txx"