]> Creatis software - clitk.git/blobdiff - segmentation/clitkExtractLymphStation_3A.txx
Add dependence with RelativePosition ggo
[clitk.git] / segmentation / clitkExtractLymphStation_3A.txx
index e5529bf4c1852a86e4975e0a33ec2adffdedd94c..8bcabc593637accf432be590f9a5177c8692d804 100644 (file)
@@ -18,7 +18,10 @@ clitk::ExtractLymphStationsFilter<TImageType>::
 ExtractStation_3A()
 {
   if (!CheckForStation("3A")) return;
-    
+
+  StartNewStep("Station 3A");
+  StartSubStep();   
+
   // Get the current support 
   StartNewStep("[Station 3A] Get the current 3A suppport");
   m_Working_Support = m_ListOfSupports["S3A"];
@@ -28,7 +31,6 @@ ExtractStation_3A()
   ExtractStation_3A_AntPost_S5();
   ExtractStation_3A_AntPost_S6();
   ExtractStation_3A_AntPost_Superiorly();
-
   ExtractStation_3A_Remove_Structures();
 
   Remove_Structures("3A", "Aorta");
@@ -38,67 +40,24 @@ ExtractStation_3A()
   Remove_Structures("3A", "CommonCarotidArteryLeft");
   Remove_Structures("3A", "CommonCarotidArteryRight");
   Remove_Structures("3A", "BrachioCephalicArtery");
-  //  Remove_Structures("3A", "BrachioCephalicVein"); ?
 
-
-  // ExtractStation_3A_Ant_Limits(); --> No, already in support; to remove
-  // ExtractStation_3A_Post_Limits(); --> No, more complex, see Vessels etc
+  ExtractStation_3A_PostToBones();
+  
+  // Keep a single CCL
+  m_ListOfStations["3A"] = 
+    clitk::SliceBySliceKeepMainCCL<MaskImageType>(m_ListOfStations["3A"], 
+                                                  GetBackgroundValue(), 
+                                                  GetForegroundValue());
 
   // Store image filenames into AFDB 
   writeImage<MaskImageType>(m_ListOfStations["3A"], "seg/Station3A.mhd");
   GetAFDB()->SetImageFilename("Station3A", "seg/Station3A.mhd"); 
   WriteAFDB(); 
+  StopSubStep();
 }
 //--------------------------------------------------------------------
 
 
-//--------------------------------------------------------------------
-template <class ImageType>
-void 
-clitk::ExtractLymphStationsFilter<ImageType>::
-ExtractStation_3A_Ant_Limits() 
-{
-  StartNewStep("[Station 3A] Ant limits with Sternum");
-
-  // Get Sternum, keep posterior part.
-  MaskImagePointer Sternum = GetAFDB()->template GetImage<MaskImageType>("Sternum");
-  m_Working_Support = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_Working_Support, Sternum, 2, 
-                                                       GetFuzzyThreshold("3A", "Sternum"), "PostTo", 
-                                                       false, 3, true, false);
-  StopCurrentStep<MaskImageType>(m_Working_Support);
-  m_ListOfStations["3A"] = m_Working_Support;
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template <class ImageType>
-void 
-clitk::ExtractLymphStationsFilter<ImageType>::
-ExtractStation_3A_Post_Limits() 
-{
-  StartNewStep("[Station 3A] Post limits with SubclavianArtery");
-
-  // Get Sternum, keep posterior part.
-  MaskImagePointer SubclavianArteryLeft = 
-    GetAFDB()->template GetImage<MaskImageType>("SubclavianArteryLeft");
-  MaskImagePointer SubclavianArteryRight = 
-    GetAFDB()->template GetImage<MaskImageType>("SubclavianArteryRight");
-
-  m_Working_Support = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_Working_Support, SubclavianArteryLeft, 2, 
-                                                       GetFuzzyThreshold("3A", "SubclavianArtery"), "AntTo", 
-                                                       false, 3, true, false);
-  m_Working_Support = 
-    clitk::SliceBySliceRelativePosition<MaskImageType>(m_Working_Support, SubclavianArteryRight, 2, 
-                                                       GetFuzzyThreshold("3A", "SubclavianArtery"), "AntTo", 
-                                                       false, 3, true, false);
-  StopCurrentStep<MaskImageType>(m_Working_Support);
-  m_ListOfStations["3A"] = m_Working_Support;
-}
-//--------------------------------------------------------------------
-
 
 //--------------------------------------------------------------------
 template <class ImageType>
@@ -112,24 +71,6 @@ ExtractStation_3A_AntPost_S5()
   MaskImagePointer SVC = GetAFDB()->template GetImage <MaskImageType>("SVC");
 
   // Trial in 3D -> difficulties superiorly. Stay slice by slice.
-  /*
-  typedef clitk::AddRelativePositionConstraintToLabelImageFilter<MaskImageType> RelPosFilterType;
-  typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New();
-  relPosFilter->VerboseStepFlagOff();
-  relPosFilter->WriteStepFlagOff();
-  relPosFilter->SetBackgroundValue(GetBackgroundValue());
-  relPosFilter->SetInput(m_Working_Support); 
-  relPosFilter->SetInputObject(SVC); 
-  relPosFilter->AddOrientationTypeString("PostTo");
-  relPosFilter->SetInverseOrientationFlag(true);
-  relPosFilter->SetIntermediateSpacing(4);
-  relPosFilter->SetIntermediateSpacingFlag(false);
-  relPosFilter->SetFuzzyThreshold(0.5);
-  //  relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop
-  relPosFilter->Update();
-  m_Working_Support = relPosFilter->GetOutput();
-  */
-  
   // Slice by slice not post to SVC. Use initial spacing
   m_Working_Support = 
     clitk::SliceBySliceRelativePosition<MaskImageType>(m_Working_Support, SVC, 2, 
@@ -308,6 +249,8 @@ ExtractStation_3A_Remove_Structures()
   // resize like support, extract slices
   // while single CCL -> remove
   // when two remove only the most post
+  MaskImagePointer BrachioCephalicVein = 
+    GetAFDB()->template GetImage <MaskImageType>("BrachioCephalicVein");
   BrachioCephalicVein = clitk::ResizeImageLike<MaskImageType>(BrachioCephalicVein, 
                                                               m_Working_Support, 
                                                               GetBackgroundValue());
@@ -318,27 +261,31 @@ ExtractStation_3A_Remove_Structures()
   for(uint i=0; i<slices.size(); i++) {
     // Labelize slices_BCV
     slices_BCV[i] = Labelize<MaskSliceType>(slices_BCV[i], 0, true, 1);
+
     // Compute centroids
     std::vector<typename MaskSliceType::PointType> centroids;
     ComputeCentroids<MaskSliceType>(slices_BCV[i], GetBackgroundValue(), centroids);
-    if (centroids.size() > 1) {
+
+    // If several centroid, select the one most anterior
+    if (centroids.size() > 2) {
       // Only keep the one most post
       typename MaskSliceType::PixelType label;
       if (centroids[1][1] > centroids[2][1]) {
-        label = 1;
-      }
-      else {
         label = 2;
       }
-      
-      HERE
-
-      slices_BCV[i] = clitk::SetBackground<MaskSliceType>(slices_BCV[i], slices_BCV[i], 
-                                                          label, 
-                                                          GetBackgroundValue(), true);
+      else {
+        label = 1;
+      }      
+      // "remove" the CCL 
+      slices_BCV[i] = clitk::SetBackground<MaskSliceType, MaskSliceType>(slices_BCV[i], 
+                                                                         slices_BCV[i], 
+                                                                         label, 
+                                                                         GetBackgroundValue(), 
+                                                                         true);
     }
+    
     // Remove from the support
-    slices[i] = clitk::AndNot(slices[i], slices_BCV[i], GetBackgroundValue());
+    clitk::AndNot<MaskSliceType>(slices[i], slices_BCV[i], GetBackgroundValue());
   }
   
   // Joint
@@ -348,3 +295,25 @@ ExtractStation_3A_Remove_Structures()
   m_ListOfStations["3A"] = m_Working_Support;
 }
 //--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template <class ImageType>
+void 
+clitk::ExtractLymphStationsFilter<ImageType>::
+ExtractStation_3A_PostToBones() 
+{
+  StartNewStep("[Station 3A] Post limits with bones");
+
+  // limits with bones
+  MaskImagePointer Bones = GetAFDB()->template GetImage<MaskImageType>("Bones");  
+  m_Working_Support = 
+    clitk::SliceBySliceRelativePosition<MaskImageType>(m_Working_Support, Bones, 2, 
+                                                       GetFuzzyThreshold("3A", "Bones"), "NotAntTo", 
+                                                       false, 3, true, false);
+  
+  StopCurrentStep<MaskImageType>(m_Working_Support);
+  m_ListOfStations["3A"] = m_Working_Support;
+}
+//--------------------------------------------------------------------