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 CLITKEXTRACTMEDIASTINUMFILTER_H
20 #define CLITKEXTRACTMEDIASTINUMFILTER_H
22 #include "clitkFilterBase.h"
23 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
27 //--------------------------------------------------------------------
29 Try to extract the mediastinum part of a thorax CT.
37 //--------------------------------------------------------------------
39 template <class TImageType>
40 class ITK_EXPORT ExtractMediastinumFilter:
41 public virtual clitk::FilterBase,
42 public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
43 public itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> >
47 /** Some convenient typedefs. */
48 typedef TImageType ImageType;
49 typedef typename ImageType::ConstPointer ImageConstPointer;
50 typedef typename ImageType::Pointer ImagePointer;
51 typedef typename ImageType::RegionType ImageRegionType;
52 typedef typename ImageType::PixelType ImagePixelType;
53 typedef typename ImageType::SizeType ImageSizeType;
54 typedef typename ImageType::IndexType ImageIndexType;
55 typedef typename ImageType::PointType ImagePointType;
57 /** Some convenient typedefs. */
58 typedef uchar MaskImagePixelType;
59 typedef itk::Image<MaskImagePixelType, 3> MaskImageType;
60 typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
61 typedef typename MaskImageType::Pointer MaskImagePointer;
62 typedef typename MaskImageType::RegionType MaskImageRegionType;
63 typedef typename MaskImageType::SizeType MaskImageSizeType;
64 typedef typename MaskImageType::IndexType MaskImageIndexType;
65 typedef typename MaskImageType::PointType MaskImagePointType;
67 typedef itk::Image<MaskImagePixelType, 2> MaskSliceType;
68 typedef typename MaskSliceType::Pointer MaskSlicePointer;
69 typedef typename MaskSliceType::PointType MaskSlicePointType;
71 /** Standard class typedefs. */
72 typedef itk::ImageToImageFilter<TImageType, MaskImageType> Superclass;
73 typedef ExtractMediastinumFilter Self;
74 typedef itk::SmartPointer<Self> Pointer;
75 typedef itk::SmartPointer<const Self> ConstPointer;
77 /** Method for creation through the object factory. */
80 /** Run-time type information (and related methods). */
81 itkTypeMacro(ExtractMediastinumFilter, InPlaceImageFilter);
85 void SetInput(const ImageType * image);
86 void SetInputPatientLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
87 void SetInputLungLabelImage(const MaskImageType * image, MaskImagePixelType bg=0,
88 MaskImagePixelType fgLeftLung=1, MaskImagePixelType fgRightLung=2);
89 void SetInputBonesLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
90 void SetInputTracheaLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
92 // Output filename (for AFBD)
93 itkSetMacro(OutputMediastinumFilename, std::string);
94 itkGetConstMacro(OutputMediastinumFilename, std::string);
96 /** ImageDimension constants */
97 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
99 // Background / Foreground
100 itkSetMacro(BackgroundValuePatient, MaskImagePixelType);
101 itkGetConstMacro(BackgroundValuePatient, MaskImagePixelType);
103 itkSetMacro(BackgroundValueLung, MaskImagePixelType);
104 itkGetConstMacro(BackgroundValueLung, MaskImagePixelType);
106 itkSetMacro(BackgroundValueBones, MaskImagePixelType);
107 itkGetConstMacro(BackgroundValueBones, MaskImagePixelType);
109 itkGetConstMacro(BackgroundValue, MaskImagePixelType);
110 itkGetConstMacro(ForegroundValue, MaskImagePixelType);
112 itkSetMacro(ForegroundValueLeftLung, MaskImagePixelType);
113 itkGetConstMacro(ForegroundValueLeftLung, MaskImagePixelType);
115 itkSetMacro(ForegroundValueRightLung, MaskImagePixelType);
116 itkGetConstMacro(ForegroundValueRightLung, MaskImagePixelType);
118 itkSetMacro(BackgroundValueTrachea, MaskImagePixelType);
119 itkGetConstMacro(BackgroundValueTrachea, MaskImagePixelType);
121 itkSetMacro(IntermediateSpacing, double);
122 itkGetConstMacro(IntermediateSpacing, double);
124 itkBooleanMacro(UseBones);
125 itkSetMacro(UseBones, bool);
126 itkGetConstMacro(UseBones, bool);
128 itkSetMacro(DistanceMaxToAnteriorPartOfTheVertebralBody, double);
129 itkGetConstMacro(DistanceMaxToAnteriorPartOfTheVertebralBody, double);
131 void SetFuzzyThreshold(std::string tag, double value);
132 double GetFuzzyThreshold(std::string tag);
135 ExtractMediastinumFilter();
136 virtual ~ExtractMediastinumFilter() {}
138 virtual void GenerateOutputInformation();
139 virtual void GenerateInputRequestedRegion();
140 virtual void GenerateData();
142 itkSetMacro(BackgroundValue, MaskImagePixelType);
143 itkSetMacro(ForegroundValue, MaskImagePixelType);
145 MaskImagePixelType m_BackgroundValuePatient;
146 MaskImagePixelType m_BackgroundValueLung;
147 MaskImagePixelType m_BackgroundValueBones;
148 MaskImagePixelType m_BackgroundValueTrachea;
149 MaskImagePixelType m_ForegroundValueLeftLung;
150 MaskImagePixelType m_ForegroundValueRightLung;
152 MaskImagePixelType m_BackgroundValue;
153 MaskImagePixelType m_ForegroundValue;
155 MaskImagePointer output;
156 MaskImagePointer patient;
157 MaskImagePointer lung;
158 MaskImagePointer bones;
159 MaskImagePointer trachea;
161 std::map<std::string, double> m_FuzzyThreshold;
162 double m_IntermediateSpacing;
164 double m_DistanceMaxToAnteriorPartOfTheVertebralBody;
166 void RemovePostPartOfVertebralBody();
168 std::string m_OutputMediastinumFilename;
171 ExtractMediastinumFilter(const Self&); //purposely not implemented
172 void operator=(const Self&); //purposely not implemented
175 //--------------------------------------------------------------------
177 } // end namespace clitk
178 //--------------------------------------------------------------------
180 #ifndef ITK_MANUAL_INSTANTIATION
181 #include "clitkExtractMediastinumFilter.txx"