4 #include <vtkAppendPolyData.h>
5 #include <vtkPolyDataWriter.h>
6 #include <vtkCellArray.h>
9 #include "clitkMeshToBinaryImageFilter.h"
12 #include <itkImageDuplicator.h>
14 //--------------------------------------------------------------------
15 template <class ImageType>
17 clitk::ExtractLymphStationsFilter<ImageType>::
18 ExtractStation_1RL_SetDefaultValues()
22 //--------------------------------------------------------------------
25 //--------------------------------------------------------------------
26 template <class TImageType>
28 clitk::ExtractLymphStationsFilter<TImageType>::
31 if ((!CheckForStation("1R")) && (!CheckForStation("1L"))) return;
33 StartNewStep("Stations 1RL");
36 // Get the current support
37 StartNewStep("[Station 1RL] Get the current 1RL suppport");
38 m_ListOfStations["1R"] = m_ListOfSupports["S1R"];
39 m_ListOfStations["1L"] = m_ListOfSupports["S1L"];
40 StopCurrentStep<MaskImageType>(m_ListOfStations["1R"]);
43 ExtractStation_1RL_Ant_Limits();
44 ExtractStation_1RL_Post_Limits();
45 m_Working_Support = m_ListOfStations["1R"];
46 Remove_Structures(" 1R", "ScaleneMuscleAnt");
47 Remove_Structures(" 1R", "CommonCarotidArteryRight");
48 m_Working_Support = m_ListOfStations["1L"];
49 Remove_Structures(" 1L", "ScaleneMuscleAnt");
50 Remove_Structures(" 1L", "CommonCarotidArteryLeft");
52 // Generic RelativePosition processes
53 m_ListOfStations["1R"] = this->ApplyRelativePositionList("Station_1R", m_ListOfStations["1R"]);
54 m_ListOfStations["1L"] = this->ApplyRelativePositionList("Station_1L", m_ListOfStations["1L"]);
56 // Store image filenames into AFDB
57 writeImage<MaskImageType>(m_ListOfStations["1R"], "seg/Station1R.mhd");
58 writeImage<MaskImageType>(m_ListOfStations["1L"], "seg/Station1L.mhd");
59 GetAFDB()->SetImageFilename("Station1R", "seg/Station1R.mhd");
60 GetAFDB()->SetImageFilename("Station1L", "seg/Station1L.mhd");
64 //--------------------------------------------------------------------
67 //--------------------------------------------------------------------
68 template <class ImageType>
70 clitk::ExtractLymphStationsFilter<ImageType>::
71 ExtractStation_1RL_Ant_Limits()
73 // -----------------------------------------------------
74 StartNewStep("[Station 1RL] anterior limits with Trachea and Thyroid");
77 The idea here it to consider the most anterior points int the
78 Trachea or the Thyroid and cut all parts anterior to it. This is
79 an heuristic, not written explicitely in the articles.
82 MaskImagePointer Trachea = GetAFDB()->template GetImage<MaskImageType>("Trachea");
83 MaskImagePointer Thyroid = GetAFDB()->template GetImage<MaskImageType>("Thyroid");
84 MaskImagePointer S1R = m_ListOfStations["1R"];
85 MaskImagePointer S1L = m_ListOfStations["1L"];
86 MaskImagePointer support = m_ListOfSupports["S1RL"];
88 // Resize like S1R. Warning: for Thyroid, only Right part is thus
90 Trachea = clitk::ResizeImageLike<MaskImageType>(Trachea, S1R, GetBackgroundValue());
91 Thyroid = clitk::ResizeImageLike<MaskImageType>(Thyroid, S1R, GetBackgroundValue());
93 // Search for most Ant point, slice by slice, between Trachea and Thyroid
94 std::vector<MaskSlicePointer> Trachea_slices;
95 clitk::ExtractSlices<MaskImageType>(Trachea, 2, Trachea_slices);
96 std::vector<MaskSlicePointer> Thyroid_slices;
97 clitk::ExtractSlices<MaskImageType>(Thyroid, 2, Thyroid_slices);
98 std::vector<typename ImageType::PointType> A;
99 std::vector<typename ImageType::PointType> B;
100 for(uint i=0; i<Trachea_slices.size(); i++) {
101 MaskSlicePointType p;
102 MaskSlicePointType q;
103 FindExtremaPointInAGivenDirection<MaskSliceType>(Trachea_slices[i],
104 GetBackgroundValue(),
106 FindExtremaPointInAGivenDirection<MaskSliceType>(Thyroid_slices[i],
107 GetBackgroundValue(),
109 if (q[1] < p[1]) p = q; // Now p is the most ant.
110 // Add a little margin, 3mm
113 ImagePointType x; //dummy
116 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(p, Trachea, i, A[i]);
118 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(p, Trachea, i, B[i]);
121 // Remove anterior to this line (keep +10 offset)
122 clitk::SliceBySliceSetBackgroundFromLineSeparation<MaskImageType>(S1R, A, B,
123 GetBackgroundValue(), 1, +10);
124 m_ListOfStations["1R"] = S1R;
126 clitk::SliceBySliceSetBackgroundFromLineSeparation<MaskImageType>(S1L, A, B,
127 GetBackgroundValue(), 1, +10);
128 StopCurrentStep<MaskImageType>(S1L);
129 m_ListOfStations["1L"] = S1L;
131 //--------------------------------------------------------------------
134 //--------------------------------------------------------------------
135 template <class ImageType>
137 clitk::ExtractLymphStationsFilter<ImageType>::
138 ExtractStation_1RL_Post_Limits()
140 // -----------------------------------------------------
141 StartNewStep("[Station 1RL] Posterior limits with VertebralArtery");
143 MaskImagePointer VertebralArtery = GetAFDB()->template GetImage<MaskImageType>("VertebralArtery");
144 MaskImagePointer S1R = m_ListOfStations["1R"];
145 MaskImagePointer S1L = m_ListOfStations["1L"];
148 VertebralArtery = clitk::ResizeImageLike<MaskImageType>(VertebralArtery, S1R, GetBackgroundValue());
150 // Search for most Ant point, slice by slice, between Trachea and Thyroid
151 std::vector<MaskSlicePointer> VertebralArtery_slices;
152 clitk::ExtractSlices<MaskImageType>(VertebralArtery, 2, VertebralArtery_slices);
153 std::vector<typename ImageType::PointType> A;
154 std::vector<typename ImageType::PointType> B;
155 for(uint i=0; i<VertebralArtery_slices.size(); i++) {
156 MaskSlicePointType p;
157 FindExtremaPointInAGivenDirection<MaskSliceType>(VertebralArtery_slices[i],
158 GetBackgroundValue(),
160 // Add a little margin ? No.
164 ImagePointType x; //dummy
167 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(p, VertebralArtery, i, A[i]);
169 clitk::PointsUtils<MaskImageType>::Convert2DTo3D(p, VertebralArtery, i, B[i]);
172 // Remove anterior to this line (keep -10 offset)
173 clitk::SliceBySliceSetBackgroundFromLineSeparation<MaskImageType>(S1R, A, B,
174 GetBackgroundValue(), 1, -10);
175 m_ListOfStations["1R"] = S1R;
177 // Remove anterior to this line (keep -10 offset)
178 clitk::SliceBySliceSetBackgroundFromLineSeparation<MaskImageType>(S1L, A, B,
179 GetBackgroundValue(), 1, -10);
180 StopCurrentStep<MaskImageType>(S1L);
181 m_ListOfStations["1L"] = S1L;
183 //--------------------------------------------------------------------