]> Creatis software - clitk.git/blob - segmentation/clitkExtractLymphStation_4RL.txx
motion masks with and without bands
[clitk.git] / segmentation / clitkExtractLymphStation_4RL.txx
1
2
3 //--------------------------------------------------------------------
4 template <class ImageType>
5 void 
6 clitk::ExtractLymphStationsFilter<ImageType>::
7 ExtractStation_4RL_SetDefaultValues()
8 {
9 }
10 //--------------------------------------------------------------------
11
12
13 //--------------------------------------------------------------------
14 template <class TImageType>
15 void 
16 clitk::ExtractLymphStationsFilter<TImageType>::
17 ExtractStation_4R() {
18   if (!CheckForStation("4R")) return;
19   StartNewStep("Stations 4R");
20   StartSubStep(); 
21
22   // Get the current support 
23   StartNewStep("[Station 4R] Get the current 4RL suppport");
24   m_ListOfStations["4R"] = m_ListOfSupports["S4R"];
25   StopCurrentStep<MaskImageType>(m_ListOfStations["4R"]);
26     
27   // Generic RelativePosition processes
28   m_ListOfStations["4R"] = this->ApplyRelativePositionList("Station_4R", m_ListOfStations["4R"]);
29
30   // Store image filenames into AFDB 
31   WriteImageStation("4R");
32   StopSubStep();
33   ComputeOverlapWithRef("4R");
34 }
35 //--------------------------------------------------------------------
36
37
38 //--------------------------------------------------------------------
39 template <class TImageType>
40 void 
41 clitk::ExtractLymphStationsFilter<TImageType>::
42 ExtractStation_4L() {
43   if (!CheckForStation("4L")) return;
44   StartNewStep("Stations 4L");
45   StartSubStep(); 
46
47   // Get the current support 
48   StartNewStep("[Station 4L] Get the current 4RL suppport");
49   m_ListOfStations["4L"] = m_ListOfSupports["S4L"];
50   StopCurrentStep<MaskImageType>(m_ListOfStations["4L"]);
51     
52   // Generic RelativePosition processes
53   m_ListOfStations["4L"] = this->ApplyRelativePositionList("Station_4L", m_ListOfStations["4L"]);
54
55   // Separation Ant/Post
56   m_Working_Support = m_ListOfStations["4L"];
57   ExtractStation_S4L_S5_Limits_Aorta_LeftPulmonaryArtery(10);
58   m_ListOfStations["4L"] = m_Working_Support;
59   
60   // Keep only one single CCL by slice
61   StartNewStep("[Station 4L] Keep only one CCL by slice");  
62   m_ListOfStations["4L"] = SliceBySliceKeepMainCCL<MaskImageType>(m_ListOfStations["4L"], 
63                                                                   GetBackgroundValue(), 
64                                                                   GetForegroundValue());
65   StopCurrentStep<MaskImageType>(m_ListOfStations["4L"]);
66
67   // Store image filenames into AFDB 
68   WriteImageStation("4L");
69   StopSubStep();
70   ComputeOverlapWithRef("4L");
71 }
72 //--------------------------------------------------------------------
73
74
75 //--------------------------------------------------------------------
76 template <class TImageType>
77 void 
78 clitk::ExtractLymphStationsFilter<TImageType>::
79 ExtractStation_S4L_S5_Limits_Aorta_LeftPulmonaryArtery(int KeepPoint) 
80 {
81   // ----------------------------------------------------------
82   StartNewStep("[Station 4L] Limits between Asc and Desc Aorta, and with LeftPulmonaryArtery ");
83
84   // Separate Aorta into DescendingAorta AscendingAorta
85   MaskImagePointer AscendingAorta = GetAFDB()->template GetImage<MaskImageType>("AscendingAorta");
86   MaskImagePointer DescendingAorta = GetAFDB()->template GetImage<MaskImageType>("DescendingAorta");  
87
88   // Crop like support (inferiorly)
89   m_Working_Support = clitk::AutoCrop<MaskImageType>(m_Working_Support, GetBackgroundValue());
90   AscendingAorta = 
91     clitk::ResizeImageLike<MaskImageType>(AscendingAorta, m_Working_Support, GetBackgroundValue());
92   DescendingAorta = 
93     clitk::ResizeImageLike<MaskImageType>(DescendingAorta, m_Working_Support, GetBackgroundValue());
94
95   // Crop superior part (when AscendingAorta and DescendingAorta join)
96   MaskImagePointType p;
97   clitk::FindExtremaPointInAGivenDirection<MaskImageType>(AscendingAorta, 
98                                                           GetBackgroundValue(), 2, false, p);
99   double max = p[2]+AscendingAorta->GetSpacing()[2];
100   AscendingAorta = 
101     clitk::CropImageRemoveGreaterThan<MaskImageType>(AscendingAorta, 2, max, false, GetBackgroundValue());
102   DescendingAorta = 
103     clitk::CropImageRemoveGreaterThan<MaskImageType>(DescendingAorta, 2, max, false, GetBackgroundValue());
104
105   // Crop inferior part, where LeftPulmonaryArtery start
106   MaskImagePointer AscendingAortaCopy = clitk::Clone<MaskImageType>(AscendingAorta);
107   MaskImagePointer LeftPulmonaryArtery = GetAFDB()->template GetImage<MaskImageType>("LeftPulmonaryArtery");
108   clitk::FindExtremaPointInAGivenDirection<MaskImageType>(LeftPulmonaryArtery, 
109                                                           GetBackgroundValue(), 2, false, p);
110   max = p[2]+LeftPulmonaryArtery->GetSpacing()[2];
111   AscendingAorta = 
112     clitk::CropImageRemoveLowerThan<MaskImageType>(AscendingAorta, 2, max, false, GetBackgroundValue());
113   DescendingAorta = 
114     clitk::CropImageRemoveLowerThan<MaskImageType>(DescendingAorta, 2, max, false, GetBackgroundValue());
115
116   // Find closest points
117   std::vector<MaskImagePointType> A;
118   std::vector<MaskImagePointType> B;
119   clitk::SliceBySliceBuildLineSegmentAccordingToMinimalDistanceBetweenStructures<MaskImageType>(AscendingAorta, 
120                                                                                                 DescendingAorta, 
121                                                                                                 GetBackgroundValue(), 
122                                                                                                 2, A, B);
123   // Separate according to AB lines
124   // clitk::WriteListOfLandmarks<MaskImageType>(A, "A.txt");
125   // clitk::WriteListOfLandmarks<MaskImageType>(B, "B.txt");
126   clitk::SliceBySliceSetBackgroundFromLineSeparation<MaskImageType>(m_Working_Support, A, B,
127                                                                     GetBackgroundValue(), 
128                                                                     1, KeepPoint); // Keep point along axis 1
129
130   // Now, same principle between AscendingAorta and LeftPulmonaryArtery
131   AscendingAorta = 
132     clitk::ResizeImageLike<MaskImageType>(AscendingAortaCopy, m_Working_Support, GetBackgroundValue());
133   LeftPulmonaryArtery = 
134     clitk::ResizeImageLike<MaskImageType>(LeftPulmonaryArtery, m_Working_Support, GetBackgroundValue());
135   AscendingAorta = 
136     clitk::CropImageRemoveGreaterThan<MaskImageType>(AscendingAorta, 2, max, false, GetBackgroundValue());
137   LeftPulmonaryArtery = 
138     clitk::CropImageRemoveGreaterThan<MaskImageType>(LeftPulmonaryArtery, 2, max, false, GetBackgroundValue());
139   A.clear();
140   B.clear();
141   clitk::SliceBySliceBuildLineSegmentAccordingToMinimalDistanceBetweenStructures<MaskImageType>(AscendingAorta, 
142                                                                                                 LeftPulmonaryArtery, 
143                                                                                                 GetBackgroundValue(), 
144                                                                                                 2, A, B);
145   clitk::SliceBySliceSetBackgroundFromLineSeparation<MaskImageType>(m_Working_Support, A, B,
146                                                                     GetBackgroundValue(), 
147                                                                     1, KeepPoint); // Keep point along axis 1
148
149   // AutoCrop
150   m_Working_Support = clitk::AutoCrop<MaskImageType>(m_Working_Support, GetBackgroundValue());
151
152   // End
153   StopCurrentStep<MaskImageType>(m_Working_Support);
154 }
155 //--------------------------------------------------------------------
156
157