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 // ExtractStation_3P_LR_inf_Limits(); // <-- done in RelPosList
31 // Generic RelativePosition processes
32 m_ListOfStations["3P"] = this->ApplyRelativePositionList("Station_3P", m_ListOfStations["3P"]);
33 m_Working_Support = m_ListOfStations["3P"];
34 ExtractStation_8_Single_CCL_Limits(); // YES 8 !
35 ExtractStation_3P_Remove_Structures(); // after CCL
36 m_ListOfStations["3P"] = m_Working_Support;
39 // LR limits superiorly => not here for the moment because not clear in the def
40 // ExtractStation_3P_LR_sup_Limits_2(); //TODO
41 // ExtractStation_3P_LR_sup_Limits(); // old version to change
43 // Store image filenames into AFDB
44 writeImage<MaskImageType>(m_ListOfStations["3P"], "seg/Station3P.mhd");
45 GetAFDB()->SetImageFilename("Station3P", "seg/Station3P.mhd");
49 //--------------------------------------------------------------------
52 //--------------------------------------------------------------------
53 template <class ImageType>
55 clitk::ExtractLymphStationsFilter<ImageType>::
56 ExtractStation_3P_Remove_Structures()
58 StartNewStep("[Station 3P] Remove some structures.");
59 Remove_Structures("3P", "Esophagus");
60 Remove_Structures("3P", "Thyroid");
61 Remove_Structures("3P", "VertebralArtery"); // (inside the station)
62 StopCurrentStep<MaskImageType>(m_Working_Support);
63 m_ListOfStations["3P"] = m_Working_Support;
65 //--------------------------------------------------------------------
68 //--------------------------------------------------------------------
69 template <class ImageType>
71 clitk::ExtractLymphStationsFilter<ImageType>::
72 ExtractStation_3P_LR_sup_Limits()
75 "On the right side, the limit is defined by the air–soft-tissue
76 interface. On the left side, it is defined by the air–tissue
77 interface superiorly (Fig. 2A–C) and the aorta inferiorly
78 (Figs. 2D–I and 3A–C)."
81 Resizelike support : Trachea, SubclavianArtery
82 Trachea, slice by slice, get centroid trachea
83 SubclavianArtery, slice by slice, CCL
84 prendre la 1ère à L et R, not at Left
87 StartNewStep("[Station 3P] Left/Right limits (superior part) ");
90 MaskImagePointer Trachea = GetAFDB()->template GetImage<MaskImageType>("Trachea");
91 MaskImagePointer SubclavianArtery = GetAFDB()->template GetImage<MaskImageType>("SubclavianArtery");
93 // Crop like current support
94 Trachea = clitk::ResizeImageLike<MaskImageType>(Trachea, m_Working_Support, GetBackgroundValue());
95 SubclavianArtery = clitk::ResizeImageLike<MaskImageType>(SubclavianArtery, m_Working_Support, GetBackgroundValue());
97 writeImage<MaskImageType>(Trachea, "tr.mhd");
98 writeImage<MaskImageType>(SubclavianArtery, "sca.mhd");
100 // Get list of slices
101 std::vector<MaskSlicePointer> slices_support;
102 std::vector<MaskSlicePointer> slices_trachea;
103 std::vector<MaskSlicePointer> slices_subclavianartery;
104 clitk::ExtractSlices<MaskImageType>(m_Working_Support, 2, slices_support);
105 clitk::ExtractSlices<MaskImageType>(Trachea, 2, slices_trachea);
106 clitk::ExtractSlices<MaskImageType>(SubclavianArtery, 2, slices_subclavianartery);
109 std::vector<MaskImagePointType> points;
110 MaskImagePointType p;
111 for(uint i=0; i<slices_support.size(); i++) {
112 // Get Trachea centroid
113 std::vector<typename MaskSliceType::PointType> centroids;
114 typename MaskSliceType::PointType c;
115 ComputeCentroids<MaskSliceType>(slices_trachea[i], GetBackgroundValue(), centroids);
118 // [debug] Store point
119 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(centroids[1], Trachea, i, p);
122 // Get Right and Left CCL in SubclavianArtery
123 slices_subclavianartery[i] = Labelize<MaskSliceType>(slices_subclavianartery[i], 0, true, 10);
124 ComputeCentroids<MaskSliceType>(slices_subclavianartery[i], GetBackgroundValue(), centroids);
126 if (centroids.size() > 1) {
127 // Determine the one at Right/Left -> first after Trachea
129 typename MaskSliceType::PointType right;
130 typename MaskSliceType::PointType left;
135 for(uint j=1; j<centroids.size(); j++) {
136 if (centroids[j][0] < c[0]) { // At Right of Trachea centroid
137 if (centroids[j][0] >= right[0]) {
138 right = centroids[j];
142 if (centroids[j][0] > c[0]) { // At Left of Trachea centroid
143 if (centroids[j][0] <= left[0]) {
150 if (label_right != -1) {
153 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(centroids[label_right], SubclavianArtery, i, p);
156 // Set Background and ForegroundValue according to label_right
157 MaskSlicePointer object =
158 clitk::Binarize<MaskSliceType>(slices_subclavianartery[i], label_right, label_right,
159 GetBackgroundValue(), GetForegroundValue());
161 // Relative Position : not at Right
162 typedef clitk::AddRelativePositionConstraintToLabelImageFilter<MaskSliceType> RelPosFilterType;
163 typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
164 relPosFilter->VerboseStepFlagOff();
165 relPosFilter->WriteStepFlagOff();
166 relPosFilter->SetBackgroundValue(GetBackgroundValue());
167 relPosFilter->SetInput(slices_support[i]);
168 relPosFilter->SetInputObject(object);
169 relPosFilter->AddOrientationTypeString("RightTo");
170 relPosFilter->SetInverseOrientationFlag(true);
171 // relPosFilter->SetIntermediateSpacing(3);
172 relPosFilter->SetIntermediateSpacingFlag(false);
173 relPosFilter->SetFuzzyThreshold(0.7);
174 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
175 relPosFilter->Update();
176 slices_support[i] = relPosFilter->GetOutput();
178 // Relative Position : not Anterior
179 relPosFilter = RelPosFilterType::New();
180 relPosFilter->VerboseStepFlagOff();
181 relPosFilter->WriteStepFlagOff();
182 relPosFilter->SetBackgroundValue(GetBackgroundValue());
183 relPosFilter->SetInput(slices_support[i]);
184 relPosFilter->SetInputObject(object);
185 relPosFilter->AddOrientationTypeString("AntTo");
186 relPosFilter->SetInverseOrientationFlag(true);
187 // relPosFilter->SetIntermediateSpacing(3);
188 relPosFilter->SetIntermediateSpacingFlag(false);
189 relPosFilter->SetFuzzyThreshold(0.7);
190 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
191 relPosFilter->Update();
192 slices_support[i] = relPosFilter->GetOutput();
194 } // End RelativePosition for Right
197 if (label_left != -1) {
200 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(centroids[label_left], SubclavianArtery, i, p);
203 // Set Background and ForegroundValue according to label_right
204 MaskSlicePointer object =
205 clitk::Binarize<MaskSliceType>(slices_subclavianartery[i], label_left, label_left,
206 GetBackgroundValue(), GetForegroundValue());
208 // Relative Position : not at Right
209 typedef clitk::AddRelativePositionConstraintToLabelImageFilter<MaskSliceType> RelPosFilterType;
210 typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
211 relPosFilter->VerboseStepFlagOff();
212 relPosFilter->WriteStepFlagOff();
213 relPosFilter->SetBackgroundValue(GetBackgroundValue());
214 relPosFilter->SetInput(slices_support[i]);
215 relPosFilter->SetInputObject(object);
216 relPosFilter->AddOrientationTypeString("L");
217 relPosFilter->SetInverseOrientationFlag(true);
218 // relPosFilter->SetIntermediateSpacing(3);
219 relPosFilter->SetIntermediateSpacingFlag(false);
220 relPosFilter->SetFuzzyThreshold(0.7);
221 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
222 relPosFilter->Update();
223 slices_support[i] = relPosFilter->GetOutput();
225 // Relative Position : not Anterior
226 relPosFilter = RelPosFilterType::New();
227 relPosFilter->VerboseStepFlagOff();
228 relPosFilter->WriteStepFlagOff();
229 relPosFilter->SetBackgroundValue(GetBackgroundValue());
230 relPosFilter->SetInput(slices_support[i]);
231 relPosFilter->SetInputObject(object);
232 relPosFilter->AddOrientationTypeString("A");
233 relPosFilter->SetInverseOrientationFlag(true);
234 // relPosFilter->SetIntermediateSpacing(3);
235 relPosFilter->SetIntermediateSpacingFlag(false);
236 relPosFilter->SetFuzzyThreshold(0.7);
237 relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
238 relPosFilter->Update();
239 slices_support[i] = relPosFilter->GetOutput();
244 } // if centroids.size > 1
248 m_Working_Support = clitk::JoinSlices<MaskImageType>(slices_support, m_Working_Support, 2);
251 clitk::WriteListOfLandmarks<MaskImageType>(points, "subcl-lr.txt");
254 StopCurrentStep<MaskImageType>(m_Working_Support);
255 m_ListOfStations["3P"] = m_Working_Support;
257 //--------------------------------------------------------------------
259 //--------------------------------------------------------------------
260 template <class ImageType>
262 clitk::ExtractLymphStationsFilter<ImageType>::
263 ExtractStation_3P_LR_sup_Limits_2()
266 "On the right side, the limit is defined by the air–soft-tissue
267 interface. On the left side, it is defined by the air–tissue
268 interface superiorly (Fig. 2A–C) and the aorta inferiorly
269 (Figs. 2D–I and 3A–C)."
272 Resizelike support : Trachea, SubclavianArtery
273 Trachea, slice by slice, get centroid trachea
274 SubclavianArtery, slice by slice, CCL
275 prendre la 1ère à L et R, not at Left
278 // StartNewStep("[Station 3P] Left/Right limits (superior part) ");
282 //--------------------------------------------------------------------