]> Creatis software - clitk.git/blob - segmentation/clitkExtractLymphStation_4RL.txx
a4478a6c4621a1b69804e9e8a9ef4e732b520ef3
[clitk.git] / segmentation / clitkExtractLymphStation_4RL.txx
1 //--------------------------------------------------------------------
2 template <class TImageType>
3 void 
4 clitk::ExtractLymphStationsFilter<TImageType>::
5 ExtractStation_4RL_SI_Limits() 
6 {
7   /* SupInf limits : 
8   - top of aortic arch
9   - ends at the upper lobe bronchus or where the right pulmonary artery crosses the midline of the mediastinum
10   */
11
12   // Local variables
13   double m_TopOfAorticArchInMM;
14   double m_UpperLobeBronchusZPositionInMM;
15   double m_RightPulmoArteyrCrossesMidMediastinumZPositionInMM;
16
17   // Get Inputs
18   m_TopOfAorticArchInMM = GetAFDB()->GetPoint3D("topOfAorticArch", 2);
19   DD(m_TopOfAorticArchInMM);
20   m_UpperLobeBronchusZPositionInMM = GetAFDB()->GetPoint3D("rightUpperLobeBronchus", 2);
21   DD(m_UpperLobeBronchusZPositionInMM);
22   m_RightPulmoArteyrCrossesMidMediastinumZPositionInMM = GetAFDB()->GetPoint3D("rightPulmoArteryCrossesMidMediastinum", 2);
23   DD(m_RightPulmoArteyrCrossesMidMediastinumZPositionInMM);
24
25   /* Crop support */
26   StartNewStep("Inf/Sup mediastinum limits with aortic arch/upperLBronchus");
27   double inf = std::max(m_UpperLobeBronchusZPositionInMM, m_RightPulmoArteyrCrossesMidMediastinumZPositionInMM);
28   m_Working_Support = 
29     clitk::CropImageAlongOneAxis<MaskImageType>(m_Support, 2, 
30                                                 inf,
31                                                 m_TopOfAorticArchInMM, true,
32                                                 GetBackgroundValue());
33   StopCurrentStep<MaskImageType>(m_Working_Support);
34
35   m_Station4RL = m_Working_Support;
36 }
37 //--------------------------------------------------------------------
38
39
40 //--------------------------------------------------------------------
41 template <class TImageType>
42 void 
43 clitk::ExtractLymphStationsFilter<TImageType>::
44 ExtractStation_4RL_LR_Limits() 
45 {
46   // 4R first 
47
48   // Left : midline of the trachea
49   // Right : "- upper part : contained within the pleural envelope
50   //- intermediate section : medial to the superior vena cava and the arch of the azygos vein
51   // - very caudal part : right upper lobe pulmonary vein"
52   // AAV ??
53   
54   // Constraint at right from the SVC
55   MaskImagePointer svc = GetAFDB()->template GetImage<MaskImageType>("SVC");
56   typedef clitk::AddRelativePositionConstraintToLabelImageFilter<MaskImageType> RelPosFilterType;
57   typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
58   relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId());
59   relPosFilter->VerboseStepOff();
60   relPosFilter->WriteStepOff();
61   relPosFilter->SetInput(m_Working_Support); 
62   relPosFilter->SetInputObject(svc); 
63   relPosFilter->SetOrientationType(RelPosFilterType::RightTo);
64   relPosFilter->SetIntermediateSpacing(2);
65   relPosFilter->SetFuzzyThreshold(0.3);
66   relPosFilter->Update();
67   m_Working_Support = relPosFilter->GetOutput();
68   m_Station4RL = m_Working_Support;
69   
70   // Left -> midline of the trachea
71   // slice by slice, find X coord of 2D centroid (?)
72   // check with previous line in order to not move too fast
73   
74   // skeleton ? -> need path description ? follow from slice to slice
75   // OR CENTROID at each slice ?
76   
77   // Crop trachea
78   // Extract list of slice from trachea
79   // Loop slice -> Get centroid crop along line (BB limit) -> two supports
80
81   // Crop the trachea like the current support
82   MaskImagePointer crop_trachea = 
83     clitk::ResizeImageLike<MaskImageType>(m_Trachea, m_Working_Support, GetBackgroundValue());
84   writeImage<MaskImageType>(crop_trachea, "croptrachea.mhd");
85
86   // Extract all the slices
87   typedef clitk::ExtractSliceFilter<MaskImageType> ExtractSliceFilterType;
88   typedef typename ExtractSliceFilterType::SliceType SliceType;
89   typename ExtractSliceFilterType::Pointer 
90     extractSliceFilter = ExtractSliceFilterType::New();
91   extractSliceFilter->SetInput(crop_trachea);
92   extractSliceFilter->SetDirection(2);
93   extractSliceFilter->Update();
94   std::vector<typename SliceType::Pointer> trachea_slices;
95   extractSliceFilter->GetOutputSlices(trachea_slices);
96
97
98
99 }
100 //--------------------------------------------------------------------