2 //--------------------------------------------------------------------
3 template <class ImageType>
5 clitk::ExtractLymphStationsFilter<ImageType>::
6 ExtractStation_3P_SetDefaultValues()
9 //--------------------------------------------------------------------
12 //--------------------------------------------------------------------
13 template <class TImageType>
15 clitk::ExtractLymphStationsFilter<TImageType>::
18 if (!CheckForStation("3P")) return;
20 StartNewStep("Station 3P");
23 // Get the current support
24 StartNewStep("[Station 3P] Get the current 3P suppport");
25 m_Working_Support = m_ListOfSupports["S3P"];
26 m_ListOfStations["3P"] = m_Working_Support;
27 StopCurrentStep<MaskImageType>(m_Working_Support);
29 // Generic RelativePosition processes
30 m_ListOfStations["3P"] = this->ApplyRelativePositionList("Station_3P", m_ListOfStations["3P"]);
31 m_Working_Support = m_ListOfStations["3P"];
32 ExtractStation_8_Single_CCL_Limits(); // YES 8 !
33 ExtractStation_3P_Remove_Structures(); // after CCL
34 m_ListOfStations["3P"] = m_Working_Support;
37 // LR limits superiorly => not here for the moment because not clear in the def
38 // ExtractStation_3P_LR_sup_Limits_2(); //TODO
39 // ExtractStation_3P_LR_sup_Limits(); // old version to change
40 // ExtractStation_3P_LR_inf_Limits(); // <-- done in RelPosList
42 // Store image filenames into AFDB
43 writeImage<MaskImageType>(m_ListOfStations["3P"], "seg/Station3P.mhd");
44 GetAFDB()->SetImageFilename("Station3P", "seg/Station3P.mhd");
48 //--------------------------------------------------------------------
51 //--------------------------------------------------------------------
52 template <class ImageType>
54 clitk::ExtractLymphStationsFilter<ImageType>::
55 ExtractStation_3P_Remove_Structures()
57 StartNewStep("[Station 3P] Remove some structures.");
58 Remove_Structures("3P", "Esophagus");
59 Remove_Structures("3P", "Thyroid");
60 Remove_Structures("3P", "VertebralArtery"); // (inside the station)
61 StopCurrentStep<MaskImageType>(m_Working_Support);
62 m_ListOfStations["3P"] = m_Working_Support;
64 //--------------------------------------------------------------------
67 //--------------------------------------------------------------------
68 template <class ImageType>
70 clitk::ExtractLymphStationsFilter<ImageType>::
71 ExtractStation_3P_LR_sup_Limits()
74 "On the right side, the limit is defined by the air–soft-tissue
75 interface. On the left side, it is defined by the air–tissue
76 interface superiorly (Fig. 2A–C) and the aorta inferiorly
77 (Figs. 2D–I and 3A–C)."
80 Resizelike support : Trachea, SubclavianArtery
81 Trachea, slice by slice, get centroid trachea
82 SubclavianArtery, slice by slice, CCL
83 prendre la 1ère à L et R, not at Left
86 StartNewStep("[Station 3P] Left/Right limits (superior part) ");
89 MaskImagePointer Trachea = GetAFDB()->template GetImage<MaskImageType>("Trachea");
90 MaskImagePointer SubclavianArtery = GetAFDB()->template GetImage<MaskImageType>("SubclavianArtery");
92 // Crop like current support
93 Trachea = clitk::ResizeImageLike<MaskImageType>(Trachea, m_Working_Support, GetBackgroundValue());
94 SubclavianArtery = clitk::ResizeImageLike<MaskImageType>(SubclavianArtery, m_Working_Support, GetBackgroundValue());
96 // writeImage<MaskImageType>(Trachea, "tr.mhd");
97 // writeImage<MaskImageType>(SubclavianArtery, "sca.mhd");
100 std::vector<MaskSlicePointer> slices_support;
101 std::vector<MaskSlicePointer> slices_trachea;
102 std::vector<MaskSlicePointer> slices_subclavianartery;
103 clitk::ExtractSlices<MaskImageType>(m_Working_Support, 2, slices_support);
104 clitk::ExtractSlices<MaskImageType>(Trachea, 2, slices_trachea);
105 clitk::ExtractSlices<MaskImageType>(SubclavianArtery, 2, slices_subclavianartery);
108 std::vector<MaskImagePointType> points;
109 MaskImagePointType p;
110 for(uint i=0; i<slices_support.size(); i++) {
111 // Get Trachea centroid
112 std::vector<typename MaskSliceType::PointType> centroids;
113 typename MaskSliceType::PointType c;
114 ComputeCentroids<MaskSliceType>(slices_trachea[i], GetBackgroundValue(), centroids);
117 // [debug] Store point
118 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(centroids[1], Trachea, i, p);
121 // Get Right and Left CCL in SubclavianArtery
122 slices_subclavianartery[i] = Labelize<MaskSliceType>(slices_subclavianartery[i], 0, true, 10);
123 ComputeCentroids<MaskSliceType>(slices_subclavianartery[i], GetBackgroundValue(), centroids);
125 if (centroids.size() > 1) {
126 // Determine the one at Right/Left -> first after Trachea
128 typename MaskSliceType::PointType right;
129 typename MaskSliceType::PointType left;
134 for(uint j=1; j<centroids.size(); j++) {
135 if (centroids[j][0] < c[0]) { // At Right of Trachea centroid
136 if (centroids[j][0] >= right[0]) {
137 right = centroids[j];
141 if (centroids[j][0] > c[0]) { // At Left of Trachea centroid
142 if (centroids[j][0] <= left[0]) {
149 if (label_right != -1) {
152 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(centroids[label_right], SubclavianArtery, i, p);
155 // Set Background and ForegroundValue according to label_right
156 MaskSlicePointer object =
157 clitk::Binarize<MaskSliceType>(slices_subclavianartery[i], label_right, label_right,
158 GetBackgroundValue(), GetForegroundValue());
160 // Relative Position : not at Right
161 typedef clitk::AddRelativePositionConstraintToLabelImageFilter<MaskSliceType> RelPosFilterType;
162 typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
163 relPosFilter->VerboseStepFlagOff();
164 relPosFilter->WriteStepFlagOff();
165 relPosFilter->SetBackgroundValue(GetBackgroundValue());
166 relPosFilter->SetInput(slices_support[i]);
167 relPosFilter->SetInputObject(object);
168 relPosFilter->AddOrientationTypeString("RightTo");
169 relPosFilter->SetInverseOrientationFlag(true);
170 // relPosFilter->SetIntermediateSpacing(3);
171 relPosFilter->SetIntermediateSpacingFlag(false);
172 relPosFilter->SetFuzzyThreshold(0.7);
173 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
174 relPosFilter->Update();
175 slices_support[i] = relPosFilter->GetOutput();
177 // Relative Position : not Anterior
178 relPosFilter = RelPosFilterType::New();
179 relPosFilter->VerboseStepFlagOff();
180 relPosFilter->WriteStepFlagOff();
181 relPosFilter->SetBackgroundValue(GetBackgroundValue());
182 relPosFilter->SetInput(slices_support[i]);
183 relPosFilter->SetInputObject(object);
184 relPosFilter->AddOrientationTypeString("AntTo");
185 relPosFilter->SetInverseOrientationFlag(true);
186 // relPosFilter->SetIntermediateSpacing(3);
187 relPosFilter->SetIntermediateSpacingFlag(false);
188 relPosFilter->SetFuzzyThreshold(0.7);
189 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
190 relPosFilter->Update();
191 slices_support[i] = relPosFilter->GetOutput();
193 } // End RelativePosition for Right
196 if (label_left != -1) {
199 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(centroids[label_left], SubclavianArtery, i, p);
202 // Set Background and ForegroundValue according to label_right
203 MaskSlicePointer object =
204 clitk::Binarize<MaskSliceType>(slices_subclavianartery[i], label_left, label_left,
205 GetBackgroundValue(), GetForegroundValue());
207 // Relative Position : not at Right
208 typedef clitk::AddRelativePositionConstraintToLabelImageFilter<MaskSliceType> RelPosFilterType;
209 typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
210 relPosFilter->VerboseStepFlagOff();
211 relPosFilter->WriteStepFlagOff();
212 relPosFilter->SetBackgroundValue(GetBackgroundValue());
213 relPosFilter->SetInput(slices_support[i]);
214 relPosFilter->SetInputObject(object);
215 relPosFilter->AddOrientationTypeString("L");
216 relPosFilter->SetInverseOrientationFlag(true);
217 // relPosFilter->SetIntermediateSpacing(3);
218 relPosFilter->SetIntermediateSpacingFlag(false);
219 relPosFilter->SetFuzzyThreshold(0.7);
220 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
221 relPosFilter->Update();
222 slices_support[i] = relPosFilter->GetOutput();
224 // Relative Position : not Anterior
225 relPosFilter = RelPosFilterType::New();
226 relPosFilter->VerboseStepFlagOff();
227 relPosFilter->WriteStepFlagOff();
228 relPosFilter->SetBackgroundValue(GetBackgroundValue());
229 relPosFilter->SetInput(slices_support[i]);
230 relPosFilter->SetInputObject(object);
231 relPosFilter->AddOrientationTypeString("A");
232 relPosFilter->SetInverseOrientationFlag(true);
233 // relPosFilter->SetIntermediateSpacing(3);
234 relPosFilter->SetIntermediateSpacingFlag(false);
235 relPosFilter->SetFuzzyThreshold(0.7);
236 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
237 relPosFilter->Update();
238 slices_support[i] = relPosFilter->GetOutput();
243 } // if centroids.size > 1
247 m_Working_Support = clitk::JoinSlices<MaskImageType>(slices_support, m_Working_Support, 2);
250 clitk::WriteListOfLandmarks<MaskImageType>(points, "subcl-lr.txt");
253 StopCurrentStep<MaskImageType>(m_Working_Support);
254 m_ListOfStations["3P"] = m_Working_Support;
256 //--------------------------------------------------------------------
258 //--------------------------------------------------------------------
259 template <class ImageType>
261 clitk::ExtractLymphStationsFilter<ImageType>::
262 ExtractStation_3P_LR_sup_Limits_2()
265 "On the right side, the limit is defined by the air–soft-tissue
266 interface. On the left side, it is defined by the air–tissue
267 interface superiorly (Fig. 2A–C) and the aorta inferiorly
268 (Figs. 2D–I and 3A–C)."
271 Resizelike support : Trachea, SubclavianArtery
272 Trachea, slice by slice, get centroid trachea
273 SubclavianArtery, slice by slice, CCL
274 prendre la 1ère à L et R, not at Left
277 // StartNewStep("[Station 3P] Left/Right limits (superior part) ");
281 //--------------------------------------------------------------------