From: dsarrut Date: Mon, 4 Oct 2010 07:54:23 +0000 (+0000) Subject: add lower limits for lung (experimental) X-Git-Tag: v1.2.0~370 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e23e998e1f27aaf0a4a65b019cdfe73784206067;p=clitk.git add lower limits for lung (experimental) --- diff --git a/segmentation/clitkExtractMediastinum.cxx b/segmentation/clitkExtractMediastinum.cxx index 8a1feec..065c6ce 100644 --- a/segmentation/clitkExtractMediastinum.cxx +++ b/segmentation/clitkExtractMediastinum.cxx @@ -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; diff --git a/segmentation/clitkExtractMediastinum.ggo b/segmentation/clitkExtractMediastinum.ggo index 2f57cae..92bff77 100644 --- a/segmentation/clitkExtractMediastinum.ggo +++ b/segmentation/clitkExtractMediastinum.ggo @@ -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" diff --git a/segmentation/clitkExtractMediastinumFilter.h b/segmentation/clitkExtractMediastinumFilter.h index f02833d..0c4e444 100644 --- a/segmentation/clitkExtractMediastinumFilter.h +++ b/segmentation/clitkExtractMediastinumFilter.h @@ -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 diff --git a/segmentation/clitkExtractMediastinumFilter.txx b/segmentation/clitkExtractMediastinumFilter.txx index fde335c..1f0d5f2 100644 --- a/segmentation/clitkExtractMediastinumFilter.txx +++ b/segmentation/clitkExtractMediastinumFilter.txx @@ -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 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(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(output, GetBackgroundValue()); // cropFilter = CropFilterType::New(); //cropFilter->SetInput(output); diff --git a/segmentation/clitkExtractMediastinumGenericFilter.txx b/segmentation/clitkExtractMediastinumGenericFilter.txx index 8632222..b5cfaba 100644 --- a/segmentation/clitkExtractMediastinumGenericFilter.txx +++ b/segmentation/clitkExtractMediastinumGenericFilter.txx @@ -88,13 +88,6 @@ void clitk::ExtractMediastinumGenericFilter::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();