]> Creatis software - clitk.git/commitdiff
add lower limits for lung (experimental)
authordsarrut <dsarrut>
Mon, 4 Oct 2010 07:54:23 +0000 (07:54 +0000)
committerdsarrut <dsarrut>
Mon, 4 Oct 2010 07:54:23 +0000 (07:54 +0000)
segmentation/clitkExtractMediastinum.cxx
segmentation/clitkExtractMediastinum.ggo
segmentation/clitkExtractMediastinumFilter.h
segmentation/clitkExtractMediastinumFilter.txx
segmentation/clitkExtractMediastinumGenericFilter.txx

index 8a1feec57573b75b23e50b04537f21f339ff41b6..065c6cebfb1a3ec389a3f027d30cf0a2d6bfbfdd 100644 (file)
@@ -33,10 +33,11 @@ int main(int argc, char * argv[])
   FilterType::Pointer filter = FilterType::New();
 
   filter->SetArgsInfo(args_info);
-  filter->Update();
 
-  if (filter->HasError()) {
-    std::cout << filter->GetLastError() << std::endl;
+  try {
+    filter->Update();
+  } catch(std::runtime_error e) {
+    std::cout << e.what() << std::endl;
   }
 
   return EXIT_SUCCESS;
index 2f57caea2f948dab924ea1c7d8ebfcd9ae66de01..92bff77da7d6461c2192693de213b5ede452b53f 100644 (file)
@@ -27,10 +27,11 @@ option "tracheaBG"     -    "Trachea Background"              int           default
 option "output"        o       "Output lungs mask filename"      string        yes
 
 section "Step 1 : Left/Right limits with lungs"
-
 option "spacing"     - "Intermediate resampling spacing"         double no default="6"
-option "fuzzy1"             -  "Fuzzy relative position threshold"       double no default="0.6"
+option "fuzzy1"             -  "Fuzzy relative position threshold"       double no default="0.4"
 
 section "Step 2 : Ant/Post limits with bones"
-
 option "fuzzy2"             -  "Fuzzy relative position threshold"       double no default="0.6"
+
+section "Step 3 : Inf limits with Lung"
+option "fuzzy3"             -  "Fuzzy relative position threshold"       double no default="0.2"
index f02833dd9017131cb7928c82501d4389d19ea7f4..0c4e444a1c56b6db006a320f15d8f97eeb2d1657 100644 (file)
@@ -118,6 +118,10 @@ namespace clitk {
     itkGetConstMacro(FuzzyThreshold2, double);
     GGO_DefineOption(fuzzy2, SetFuzzyThreshold2, double);
 
+    itkSetMacro(FuzzyThreshold3, double);
+    itkGetConstMacro(FuzzyThreshold3, double);
+    GGO_DefineOption(fuzzy3, SetFuzzyThreshold3, double);
+
   protected:
     ExtractMediastinumFilter();
     virtual ~ExtractMediastinumFilter() {}
@@ -142,6 +146,7 @@ namespace clitk {
     double m_IntermediateSpacing;
     double m_FuzzyThreshold1;
     double m_FuzzyThreshold2;
+    double m_FuzzyThreshold3;
     
   private:
     ExtractMediastinumFilter(const Self&); //purposely not implemented
index fde335c28ada90f738bc5051673d7554027e2546..1f0d5f2b2bafe8fc2fae98947883f0a1948d318d 100644 (file)
@@ -54,8 +54,9 @@ ExtractMediastinumFilter():
   SetForegroundValue(1);
 
   SetIntermediateSpacing(6);
-  SetFuzzyThreshold1(0.6);
-  SetFuzzyThreshold2(0.7);
+  SetFuzzyThreshold1(0.4);
+  SetFuzzyThreshold2(0.6);
+  SetFuzzyThreshold3(0.2);
 }
 //--------------------------------------------------------------------
 
@@ -133,6 +134,7 @@ SetArgsInfo(ArgsInfoType mArgsInfo)
   SetIntermediateSpacing_GGO(mArgsInfo);
   SetFuzzyThreshold1_GGO(mArgsInfo);
   SetFuzzyThreshold2_GGO(mArgsInfo);
+  SetFuzzyThreshold3_GGO(mArgsInfo);
 }
 //--------------------------------------------------------------------
 
@@ -252,16 +254,19 @@ GenerateData()
   ImageConstPointer bones_ant;
   ImageConstPointer bones_post;
 
-  // Find ant-post coordinate of trachea (assume the first point is a
+  // Find ant-post coordinate of trachea (assume the carena position is a
   // good estimation of the ant-post position of the trachea)
   typedef clitk::ExtractAirwayTreeInfoFilter<ImageType> AirwayFilter;
   typename AirwayFilter::Pointer airwayfilter = AirwayFilter::New();
+  airwayfilter->SetVerboseStep(false);
+  airwayfilter->SetWriteStep(false);
   airwayfilter->SetInput(trachea);
   airwayfilter->Update();
   DD(airwayfilter->GetFirstTracheaPoint());
-  ImagePointType point_trachea = airwayfilter->GetFirstTracheaPoint();
+  ImagePointType point_trachea = airwayfilter->GetCarinaPoint();
   ImageIndexType index_trachea;
   bones->TransformPhysicalPointToIndex(point_trachea, index_trachea);
+  DD(point_trachea);
   DD(index_trachea);
   
   // Split bone image first into two parts (ant and post)
@@ -285,8 +290,8 @@ GenerateData()
   //  cropFilter->ResetPipeline();// = CropFilterType::New();  
   cropFilter = CropFilterType::New();  
   ImageIndexType index = region.GetIndex();
-  size[1] =  bones->GetLargestPossibleRegion().GetSize()[1] - size[1];
   index[1] = bones->GetLargestPossibleRegion().GetIndex()[1] + size[1]-1;
+  size[1] =  bones->GetLargestPossibleRegion().GetSize()[1] - size[1];
   DD(size);
   region.SetIndex(index);
   region.SetSize(size);
@@ -331,6 +336,24 @@ GenerateData()
   output = clitk::KeepLabels<ImageType>(output, GetBackgroundValue(), 
                                         GetForegroundValue(), 1, 1, 0);
 
+
+  // Step : Lower limits from lung (need separate lung ?)
+  StartNewStep("Lower limits with lungs");
+  relPosFilter = RelPosFilterType::New();
+  relPosFilter->SetCurrentStepBaseId(this->GetCurrentStepId());
+  relPosFilter->VerboseStepOff();
+  relPosFilter->WriteStepOff();
+  relPosFilter->SetInput(output); 
+  DD(output->GetLargestPossibleRegion().GetIndex());
+  //  relPosFilter->SetInputObject(left_lung); 
+  relPosFilter->SetInputObject(lung); 
+  relPosFilter->SetOrientationType(RelPosFilterType::SupTo);
+  relPosFilter->SetIntermediateSpacing(GetIntermediateSpacing());
+  relPosFilter->SetFuzzyThreshold(GetFuzzyThreshold3());
+  relPosFilter->Update();
+  output = relPosFilter->GetOutput();
+  DD(output->GetLargestPossibleRegion());
+
   output = clitk::AutoCrop<ImageType>(output, GetBackgroundValue()); 
   //  cropFilter = CropFilterType::New();
   //cropFilter->SetInput(output);
index 8632222cbec0b974a1926566e8d8018344a7a652..b5cfaba3194fc995d97f6fa738e91e277aa31b47 100644 (file)
@@ -88,13 +88,6 @@ void clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::UpdateWithInputImageT
 
   // Go !
   filter->Update();
-  
-  // Check if error
-  if (filter->HasError()) {
-    SetLastError(filter->GetLastError());
-    // No output
-    return;
-  }
 
   // Write/Save results
   typename ImageType::Pointer output = filter->GetOutput();