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 // LR limits inferiorly
30 ExtractStation_3P_LR_inf_Limits();
32 // LR limits superiorly => not here for the moment because not
34 // ExtractStation_3P_LR_sup_Limits_2(); //TODO
35 // ExtractStation_3P_LR_sup_Limits(); // old version to change
37 ExtractStation_8_Single_CCL_Limits(); // YES 8 !
38 ExtractStation_3P_Remove_Structures(); // after CCL
40 // Store image filenames into AFDB
41 writeImage<MaskImageType>(m_ListOfStations["3P"], "seg/Station3P.mhd");
42 GetAFDB()->SetImageFilename("Station3P", "seg/Station3P.mhd");
46 //--------------------------------------------------------------------
49 //--------------------------------------------------------------------
50 template <class ImageType>
52 clitk::ExtractLymphStationsFilter<ImageType>::
53 ExtractStation_3P_Remove_Structures()
55 StartNewStep("[Station 3P] Remove some structures.");
57 Remove_Structures("3P", "Aorta");
58 Remove_Structures("3P", "VertebralBody");
59 Remove_Structures("3P", "SubclavianArteryLeft");
60 Remove_Structures("3P", "SubclavianArteryRight");
61 Remove_Structures("3P", "Esophagus");
62 Remove_Structures("3P", "AzygousVein");
63 Remove_Structures("3P", "Thyroid");
64 Remove_Structures("3P", "VertebralArtery");
66 StopCurrentStep<MaskImageType>(m_Working_Support);
67 m_ListOfStations["3P"] = m_Working_Support;
69 //--------------------------------------------------------------------
72 //--------------------------------------------------------------------
73 template <class ImageType>
75 clitk::ExtractLymphStationsFilter<ImageType>::
76 ExtractStation_3P_LR_sup_Limits()
79 "On the right side, the limit is defined by the air–soft-tissue
80 interface. On the left side, it is defined by the air–tissue
81 interface superiorly (Fig. 2A–C) and the aorta inferiorly
82 (Figs. 2D–I and 3A–C)."
85 Resizelike support : Trachea, SubclavianArtery
86 Trachea, slice by slice, get centroid trachea
87 SubclavianArtery, slice by slice, CCL
88 prendre la 1ère à L et R, not at Left
91 StartNewStep("[Station 3P] Left/Right limits (superior part) ");
94 MaskImagePointer Trachea = GetAFDB()->template GetImage<MaskImageType>("Trachea");
95 MaskImagePointer SubclavianArtery = GetAFDB()->template GetImage<MaskImageType>("SubclavianArtery");
97 // Crop like current support
98 Trachea = clitk::ResizeImageLike<MaskImageType>(Trachea, m_Working_Support, GetBackgroundValue());
99 SubclavianArtery = clitk::ResizeImageLike<MaskImageType>(SubclavianArtery, m_Working_Support, GetBackgroundValue());
101 writeImage<MaskImageType>(Trachea, "tr.mhd");
102 writeImage<MaskImageType>(SubclavianArtery, "sca.mhd");
104 // Get list of slices
105 std::vector<MaskSlicePointer> slices_support;
106 std::vector<MaskSlicePointer> slices_trachea;
107 std::vector<MaskSlicePointer> slices_subclavianartery;
108 clitk::ExtractSlices<MaskImageType>(m_Working_Support, 2, slices_support);
109 clitk::ExtractSlices<MaskImageType>(Trachea, 2, slices_trachea);
110 clitk::ExtractSlices<MaskImageType>(SubclavianArtery, 2, slices_subclavianartery);
113 std::vector<MaskImagePointType> points;
114 MaskImagePointType p;
115 for(uint i=0; i<slices_support.size(); i++) {
116 // Get Trachea centroid
117 std::vector<typename MaskSliceType::PointType> centroids;
118 typename MaskSliceType::PointType c;
119 ComputeCentroids<MaskSliceType>(slices_trachea[i], GetBackgroundValue(), centroids);
122 // [debug] Store point
123 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(centroids[1], Trachea, i, p);
126 // Get Right and Left CCL in SubclavianArtery
127 slices_subclavianartery[i] = Labelize<MaskSliceType>(slices_subclavianartery[i], 0, true, 10);
128 ComputeCentroids<MaskSliceType>(slices_subclavianartery[i], GetBackgroundValue(), centroids);
130 if (centroids.size() > 1) {
131 // Determine the one at Right/Left -> first after Trachea
133 typename MaskSliceType::PointType right;
134 typename MaskSliceType::PointType left;
139 for(uint j=1; j<centroids.size(); j++) {
140 if (centroids[j][0] < c[0]) { // At Right of Trachea centroid
141 if (centroids[j][0] >= right[0]) {
142 right = centroids[j];
146 if (centroids[j][0] > c[0]) { // At Left of Trachea centroid
147 if (centroids[j][0] <= left[0]) {
154 if (label_right != -1) {
157 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(centroids[label_right], SubclavianArtery, i, p);
160 // Set Background and ForegroundValue according to label_right
161 MaskSlicePointer object =
162 clitk::Binarize<MaskSliceType>(slices_subclavianartery[i], label_right, label_right,
163 GetBackgroundValue(), GetForegroundValue());
165 // Relative Position : not at Right
166 typedef clitk::AddRelativePositionConstraintToLabelImageFilter<MaskSliceType> RelPosFilterType;
167 typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
168 relPosFilter->VerboseStepFlagOff();
169 relPosFilter->WriteStepFlagOff();
170 relPosFilter->SetBackgroundValue(GetBackgroundValue());
171 relPosFilter->SetInput(slices_support[i]);
172 relPosFilter->SetInputObject(object);
173 relPosFilter->AddOrientationTypeString("R");
174 relPosFilter->SetInverseOrientationFlag(true);
175 // relPosFilter->SetIntermediateSpacing(3);
176 relPosFilter->SetIntermediateSpacingFlag(false);
177 relPosFilter->SetFuzzyThreshold(0.7);
178 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
179 relPosFilter->Update();
180 slices_support[i] = relPosFilter->GetOutput();
182 // Relative Position : not Anterior
183 relPosFilter = RelPosFilterType::New();
184 relPosFilter->VerboseStepFlagOff();
185 relPosFilter->WriteStepFlagOff();
186 relPosFilter->SetBackgroundValue(GetBackgroundValue());
187 relPosFilter->SetInput(slices_support[i]);
188 relPosFilter->SetInputObject(object);
189 relPosFilter->AddOrientationTypeString("A");
190 relPosFilter->SetInverseOrientationFlag(true);
191 // relPosFilter->SetIntermediateSpacing(3);
192 relPosFilter->SetIntermediateSpacingFlag(false);
193 relPosFilter->SetFuzzyThreshold(0.7);
194 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
195 relPosFilter->Update();
196 slices_support[i] = relPosFilter->GetOutput();
198 } // End RelativePosition for Right
201 if (label_left != -1) {
204 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(centroids[label_left], SubclavianArtery, i, p);
207 // Set Background and ForegroundValue according to label_right
208 MaskSlicePointer object =
209 clitk::Binarize<MaskSliceType>(slices_subclavianartery[i], label_left, label_left,
210 GetBackgroundValue(), GetForegroundValue());
212 // Relative Position : not at Right
213 typedef clitk::AddRelativePositionConstraintToLabelImageFilter<MaskSliceType> RelPosFilterType;
214 typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
215 relPosFilter->VerboseStepFlagOff();
216 relPosFilter->WriteStepFlagOff();
217 relPosFilter->SetBackgroundValue(GetBackgroundValue());
218 relPosFilter->SetInput(slices_support[i]);
219 relPosFilter->SetInputObject(object);
220 relPosFilter->AddOrientationTypeString("L");
221 relPosFilter->SetInverseOrientationFlag(true);
222 // relPosFilter->SetIntermediateSpacing(3);
223 relPosFilter->SetIntermediateSpacingFlag(false);
224 relPosFilter->SetFuzzyThreshold(0.7);
225 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
226 relPosFilter->Update();
227 slices_support[i] = relPosFilter->GetOutput();
229 // Relative Position : not Anterior
230 relPosFilter = RelPosFilterType::New();
231 relPosFilter->VerboseStepFlagOff();
232 relPosFilter->WriteStepFlagOff();
233 relPosFilter->SetBackgroundValue(GetBackgroundValue());
234 relPosFilter->SetInput(slices_support[i]);
235 relPosFilter->SetInputObject(object);
236 relPosFilter->AddOrientationTypeString("A");
237 relPosFilter->SetInverseOrientationFlag(true);
238 // relPosFilter->SetIntermediateSpacing(3);
239 relPosFilter->SetIntermediateSpacingFlag(false);
240 relPosFilter->SetFuzzyThreshold(0.7);
241 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
242 relPosFilter->Update();
243 slices_support[i] = relPosFilter->GetOutput();
248 } // if centroids.size > 1
252 m_Working_Support = clitk::JoinSlices<MaskImageType>(slices_support, m_Working_Support, 2);
255 clitk::WriteListOfLandmarks<MaskImageType>(points, "subcl-lr.txt");
258 StopCurrentStep<MaskImageType>(m_Working_Support);
259 m_ListOfStations["3P"] = m_Working_Support;
261 //--------------------------------------------------------------------
263 //--------------------------------------------------------------------
264 template <class ImageType>
266 clitk::ExtractLymphStationsFilter<ImageType>::
267 ExtractStation_3P_LR_sup_Limits_2()
270 "On the right side, the limit is defined by the air–soft-tissue
271 interface. On the left side, it is defined by the air–tissue
272 interface superiorly (Fig. 2A–C) and the aorta inferiorly
273 (Figs. 2D–I and 3A–C)."
276 Resizelike support : Trachea, SubclavianArtery
277 Trachea, slice by slice, get centroid trachea
278 SubclavianArtery, slice by slice, CCL
279 prendre la 1ère à L et R, not at Left
282 // StartNewStep("[Station 3P] Left/Right limits (superior part) ");
286 //--------------------------------------------------------------------
288 //--------------------------------------------------------------------
289 template <class ImageType>
291 clitk::ExtractLymphStationsFilter<ImageType>::
292 ExtractStation_3P_LR_inf_Limits()
295 "On the right side, the limit is defined by the air–soft-tissue
296 interface. On the left side, it is defined by the air–tissue
297 interface superiorly (Fig. 2A–C) and the aorta inferiorly
298 (Figs. 2D–I and 3A–C)."
300 inf : not Right to Azygousvein
302 StartNewStep("[Station 3P] Left/Right limits (inferior part) with Azygousvein and Aorta");
305 MaskImagePointer AzygousVein = GetAFDB()->template GetImage<MaskImageType>("AzygousVein");
306 MaskImagePointer Aorta = GetAFDB()->template GetImage<MaskImageType>("Aorta");
309 writeImage<MaskImageType>(m_Working_Support, "ws.mhd");
311 typedef clitk::AddRelativePositionConstraintToLabelImageFilter<MaskImageType> RelPosFilterType;
312 typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
313 relPosFilter->VerboseStepFlagOff();
314 relPosFilter->WriteStepFlagOff();
315 relPosFilter->SetBackgroundValue(GetBackgroundValue());
316 relPosFilter->SetInput(m_Working_Support);
317 relPosFilter->SetInputObject(AzygousVein);
318 relPosFilter->AddOrientationTypeString("R");
319 relPosFilter->SetInverseOrientationFlag(true);
320 relPosFilter->SetIntermediateSpacing(3);
321 relPosFilter->SetIntermediateSpacingFlag(false);
322 relPosFilter->SetFuzzyThreshold(0.7);
323 relPosFilter->AutoCropFlagOn();
324 relPosFilter->Update();
325 m_Working_Support = relPosFilter->GetOutput();
328 writeImage<MaskImageType>(m_Working_Support, "before-L-aorta.mhd");
329 relPosFilter->SetInput(m_Working_Support);
330 relPosFilter->SetInputObject(Aorta);
331 relPosFilter->AddOrientationTypeString("L");
332 relPosFilter->SetInverseOrientationFlag(true);
333 relPosFilter->SetIntermediateSpacing(3);
334 relPosFilter->SetIntermediateSpacingFlag(false);
335 relPosFilter->SetFuzzyThreshold(0.7);
336 relPosFilter->AutoCropFlagOn();
337 relPosFilter->Update();
338 m_Working_Support = relPosFilter->GetOutput();
339 writeImage<MaskImageType>(m_Working_Support, "after-L-aorta.mhd");
341 StopCurrentStep<MaskImageType>(m_Working_Support);
342 m_ListOfStations["3P"] = m_Working_Support;
344 //--------------------------------------------------------------------