From 3c86758765bc9bcba20d439424bcf97091b5af6f Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Mon, 26 Sep 2011 09:04:02 +0200 Subject: [PATCH] Extraction of S1RL --- segmentation/clitkExtractLymphStation_1RL.txx | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 segmentation/clitkExtractLymphStation_1RL.txx diff --git a/segmentation/clitkExtractLymphStation_1RL.txx b/segmentation/clitkExtractLymphStation_1RL.txx new file mode 100644 index 0000000..608fdc9 --- /dev/null +++ b/segmentation/clitkExtractLymphStation_1RL.txx @@ -0,0 +1,185 @@ + + +// vtk +#include +#include +#include + +// clitk +#include "clitkMeshToBinaryImageFilter.h" + +// itk +#include + +//-------------------------------------------------------------------- +template +void +clitk::ExtractLymphStationsFilter:: +ExtractStation_1RL_SetDefaultValues() +{ + +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +void +clitk::ExtractLymphStationsFilter:: +ExtractStation_1RL() +{ + if ((!CheckForStation("1R")) && (!CheckForStation("1L"))) return; + + StartNewStep("Stations 1RL"); + StartSubStep(); + + // Get the current support + StartNewStep("[Station 1RL] Get the current 1RL suppport"); + m_ListOfStations["1R"] = m_ListOfSupports["S1R"]; + m_ListOfStations["1L"] = m_ListOfSupports["S1L"]; + StopCurrentStep(m_ListOfStations["1R"]); + + // Specific processes + ExtractStation_1RL_Ant_Limits(); + ExtractStation_1RL_Post_Limits(); + m_Working_Support = m_ListOfStations["1R"]; + Remove_Structures(" 1R", "ScaleneMuscleAnt"); + Remove_Structures(" 1R", "CommonCarotidArteryRight"); + m_Working_Support = m_ListOfStations["1L"]; + Remove_Structures(" 1L", "ScaleneMuscleAnt"); + Remove_Structures(" 1L", "CommonCarotidArteryLeft"); + + // Generic RelativePosition processes + m_ListOfStations["1R"] = this->ApplyRelativePositionList("Station_1R", m_ListOfStations["1R"]); + m_ListOfStations["1L"] = this->ApplyRelativePositionList("Station_1L", m_ListOfStations["1L"]); + + // Store image filenames into AFDB + writeImage(m_ListOfStations["1R"], "seg/Station1R.mhd"); + writeImage(m_ListOfStations["1L"], "seg/Station1L.mhd"); + GetAFDB()->SetImageFilename("Station1R", "seg/Station1R.mhd"); + GetAFDB()->SetImageFilename("Station1L", "seg/Station1L.mhd"); + WriteAFDB(); + StopSubStep(); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +void +clitk::ExtractLymphStationsFilter:: +ExtractStation_1RL_Ant_Limits() +{ + // ----------------------------------------------------- + StartNewStep("[Station 1RL] anterior limits with Trachea and Thyroid"); + + /* + The idea here it to consider the most anterior points int the + Trachea or the Thyroid and cut all parts anterior to it. This is + an heuristic, not written explicitely in the articles. + */ + + MaskImagePointer Trachea = GetAFDB()->template GetImage("Trachea"); + MaskImagePointer Thyroid = GetAFDB()->template GetImage("Thyroid"); + MaskImagePointer S1R = m_ListOfStations["1R"]; + MaskImagePointer S1L = m_ListOfStations["1L"]; + MaskImagePointer support = m_ListOfSupports["S1RL"]; + + // Resize like S1R. Warning: for Thyroid, only Right part is thus + // taken into account + Trachea = clitk::ResizeImageLike(Trachea, S1R, GetBackgroundValue()); + Thyroid = clitk::ResizeImageLike(Thyroid, S1R, GetBackgroundValue()); + + // Search for most Ant point, slice by slice, between Trachea and Thyroid + std::vector Trachea_slices; + clitk::ExtractSlices(Trachea, 2, Trachea_slices); + std::vector Thyroid_slices; + clitk::ExtractSlices(Thyroid, 2, Thyroid_slices); + std::vector A; + std::vector B; + for(uint i=0; i(Trachea_slices[i], + GetBackgroundValue(), + 1, true, p); + FindExtremaPointInAGivenDirection(Thyroid_slices[i], + GetBackgroundValue(), + 1, true, q); + if (q[1] < p[1]) p = q; // Now p is the most ant. + // Add a little margin, 3mm + p[1] -= 3; + // Convert in 3D + ImagePointType x; //dummy + A.push_back(x); + B.push_back(x); + clitk::PointsUtils::Convert2DTo3D(p, Trachea, i, A[i]); + p[0] += 10; + clitk::PointsUtils::Convert2DTo3D(p, Trachea, i, B[i]); + } + + // Remove anterior to this line (keep +10 offset) + clitk::SliceBySliceSetBackgroundFromLineSeparation(S1R, A, B, + GetBackgroundValue(), 1, +10); + m_ListOfStations["1R"] = S1R; + + clitk::SliceBySliceSetBackgroundFromLineSeparation(S1L, A, B, + GetBackgroundValue(), 1, +10); + StopCurrentStep(S1L); + m_ListOfStations["1L"] = S1L; +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +void +clitk::ExtractLymphStationsFilter:: +ExtractStation_1RL_Post_Limits() +{ + // ----------------------------------------------------- + StartNewStep("[Station 1RL] Posterior limits with VertebralArtery"); + + MaskImagePointer VertebralArtery = GetAFDB()->template GetImage("VertebralArtery"); + MaskImagePointer S1R = m_ListOfStations["1R"]; + MaskImagePointer S1L = m_ListOfStations["1L"]; + + // Resize like S1R. + VertebralArtery = clitk::ResizeImageLike(VertebralArtery, S1R, GetBackgroundValue()); + + // Search for most Ant point, slice by slice, between Trachea and Thyroid + std::vector VertebralArtery_slices; + clitk::ExtractSlices(VertebralArtery, 2, VertebralArtery_slices); + std::vector A; + std::vector B; + for(uint i=0; i(VertebralArtery_slices[i], + GetBackgroundValue(), + 1, false, p); + // Add a little margin ? No. + //p[1] += 0; + //DD(p); + // Convert in 3D + ImagePointType x; //dummy + A.push_back(x); + B.push_back(x); + clitk::PointsUtils::Convert2DTo3D(p, VertebralArtery, i, A[i]); + p[0] += 10; + clitk::PointsUtils::Convert2DTo3D(p, VertebralArtery, i, B[i]); + } + + // Remove anterior to this line (keep -10 offset) + clitk::SliceBySliceSetBackgroundFromLineSeparation(S1R, A, B, + GetBackgroundValue(), 1, -10); + m_ListOfStations["1R"] = S1R; + + // Remove anterior to this line (keep -10 offset) + clitk::SliceBySliceSetBackgroundFromLineSeparation(S1L, A, B, + GetBackgroundValue(), 1, -10); + StopCurrentStep(S1L); + m_ListOfStations["1L"] = S1L; +} +//-------------------------------------------------------------------- + + -- 2.47.1