+//--------------------------------------------------------------------
+template <class ImageType>
+void
+clitk::ExtractLymphStationsFilter<ImageType>::
+ExtractStation_8_LR_2_Limits()
+{
+ //--------------------------------------------------------------------
+ StartNewStep("[Station8] Left and Right (from PulmTrunk to OriginMiddleLobeBronchus) Right to line from Aorta to PulmonaryTrunk");
+
+ /*
+ We consider a line from Left part of Aorta to left part of
+ PulmonaryTrunk and remove what is at Left.
+ */
+
+ // Load the structures
+ MaskImagePointer Aorta = GetAFDB()->template GetImage<MaskImageType>("Aorta");
+ MaskImagePointer PulmonaryTrunk = GetAFDB()->template GetImage<MaskImageType>("PulmonaryTrunk");
+
+ // Resize like the PT and define the slices
+ MaskImagePointType min, max;
+ clitk::GetMinMaxPointPosition<MaskImageType>(PulmonaryTrunk, min, max);
+ Aorta = clitk::CropImageAlongOneAxis<MaskImageType>(Aorta, 2, min[2], max[2], false, GetBackgroundValue());
+ std::vector<MaskSlicePointer> slices_aorta;
+ clitk::ExtractSlices<MaskImageType>(Aorta, 2, slices_aorta);
+ std::vector<MaskSlicePointer> slices_PT;
+ clitk::ExtractSlices<MaskImageType>(PulmonaryTrunk, 2, slices_PT);
+
+ // Find the points at left
+ std::vector<MaskImagePointType> p_A;
+ std::vector<MaskImagePointType> p_B;
+ MaskImagePointType pA;
+ MaskImagePointType pB;
+ for(uint i=0; i<slices_PT.size(); i++) {
+ typename MaskSliceType::PointType ps;
+ // In Aorta (assume a single CCL)
+ bool found =
+ clitk::FindExtremaPointInAGivenDirection<MaskSliceType>(slices_aorta[i], GetBackgroundValue(), 0, false, ps);
+ clitk::PointsUtils<MaskImageType>::Convert2DTo3D(ps, Aorta, i, pA);
+
+ if (found) {
+ // In PT : generally 2 CCL, we keep the most at left
+ found =
+ clitk::FindExtremaPointInAGivenDirection<MaskSliceType>(slices_PT[i], GetBackgroundValue(), 0, false, ps);
+ clitk::PointsUtils<MaskImageType>::Convert2DTo3D(ps, PulmonaryTrunk, i, pB);
+ }
+
+ if (found) {
+ p_A.push_back(pA);
+ p_B.push_back(pB);
+ }
+ }
+ clitk::WriteListOfLandmarks<MaskImageType>(p_A, "S8-Aorta-Left-points.txt");
+ clitk::WriteListOfLandmarks<MaskImageType>(p_B, "S8-PT-Left-points.txt");
+
+ // Remove part at Left
+ clitk::SliceBySliceSetBackgroundFromLineSeparation<MaskImageType>(m_Working_Support,
+ p_A, p_B,
+ GetBackgroundValue(),
+ 0, -10);
+
+ StopCurrentStep<MaskImageType>(m_Working_Support);
+ m_ListOfStations["8"] = m_Working_Support;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class ImageType>
+void
+clitk::ExtractLymphStationsFilter<ImageType>::
+ExtractStation_8_Single_CCL_Limits()
+{
+ //--------------------------------------------------------------------
+ StartNewStep("[Station8 or 3P] Slice by slice, keep a single CCL (the closest to VertebralBody)");
+
+ // Consider slices
+ std::vector<typename MaskSliceType::Pointer> slices;
+ std::vector<typename MaskSliceType::Pointer> slices_vb;
+ clitk::ExtractSlices<MaskImageType>(m_Working_Support, 2, slices);
+ MaskImagePointer VertebralBody =
+ GetAFDB()->template GetImage <MaskImageType>("VertebralBody");
+ VertebralBody = clitk::ResizeImageLike<MaskImageType>(VertebralBody, m_Working_Support, GetBackgroundValue());
+ clitk::ExtractSlices<MaskImageType>(VertebralBody, 2, slices_vb);
+
+ for(uint i=0; i<slices.size(); i++) {
+ // Decompose in labels
+ slices[i] = Labelize<MaskSliceType>(slices[i], 0, true, 100);
+ // Compute centroids coordinate
+ std::vector<typename MaskSliceType::PointType> centroids;
+ std::vector<typename MaskSliceType::PointType> c;
+ clitk::ComputeCentroids<MaskSliceType>(slices[i], GetBackgroundValue(), centroids);
+ clitk::ComputeCentroids<MaskSliceType>(slices_vb[i], GetBackgroundValue(), c);
+ if ((c.size() > 1) && (centroids.size() > 1)) {
+ // keep the one which is the closer to vertebralbody centroid
+ double distance=1000000;
+ int index=0;
+ for(uint j=1; j<centroids.size(); j++) {
+ double d = centroids[j].EuclideanDistanceTo(c[1]);
+ if (d<distance) {
+ distance = d;
+ index = j;
+ }
+ }
+ // remove all others label
+ slices[i] = KeepLabels<MaskSliceType>(slices[i], GetBackgroundValue(),
+ GetForegroundValue(), index, index, true);
+ }
+ }
+ m_Working_Support = clitk::JoinSlices<MaskImageType>(slices, m_Working_Support, 2);
+
+ StopCurrentStep<MaskImageType>(m_Working_Support);
+ m_ListOfStations["8"] = m_Working_Support;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class ImageType>
+void
+clitk::ExtractLymphStationsFilter<ImageType>::
+ExtractStation_8_LR_Limits_old2()
+{
+
+ //--------------------------------------------------------------------
+ StartNewStep("[Station8] Left and Right limits arround esophagus (below Carina)");