From 9e9bff2490b1ebdfb57c8e1bf4e359a51b12b77c Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Thu, 3 Nov 2011 18:07:31 +0100 Subject: [PATCH] clitkExtractLung - new option - doNotSeparateLungs --- segmentation/clitkExtractLung.ggo | 3 + segmentation/clitkExtractLungFilter.h | 7 ++ segmentation/clitkExtractLungFilter.txx | 84 ++++++++++--------- .../clitkExtractLungGenericFilter.txx | 5 ++ 4 files changed, 58 insertions(+), 41 deletions(-) diff --git a/segmentation/clitkExtractLung.ggo b/segmentation/clitkExtractLung.ggo index 12dd3e7..98ddbd8 100644 --- a/segmentation/clitkExtractLung.ggo +++ b/segmentation/clitkExtractLung.ggo @@ -61,4 +61,7 @@ section "Step 6 : fill holes" option "doNotFillHoles" - "Do not fill holes if set" flag on option "dir" d "Directions (axes) to perform filling (defaults to 2,1,0)" int multiple no +section "Step 7 : lung separation (labelling)" +option "doNotSeparateLungs" - "Do not separate lungs if set" flag off + option "noAutoCrop" - "If set : do no crop final mask to BoundingBox" flag off diff --git a/segmentation/clitkExtractLungFilter.h b/segmentation/clitkExtractLungFilter.h index fa472ba..23fbbc7 100644 --- a/segmentation/clitkExtractLungFilter.h +++ b/segmentation/clitkExtractLungFilter.h @@ -191,6 +191,11 @@ namespace clitk { itkGetConstMacro(FillHolesFlag, bool); itkBooleanMacro(FillHolesFlag); + // Separate lungs + itkSetMacro(SeparateLungsFlag, bool); + itkGetConstMacro(SeparateLungsFlag, bool); + itkBooleanMacro(SeparateLungsFlag); + // Step Auto Crop itkSetMacro(AutoCrop, bool); itkGetConstMacro(AutoCrop, bool); @@ -250,6 +255,8 @@ namespace clitk { bool m_FillHolesFlag; InputImageSizeType m_FillHolesDirections; + bool m_SeparateLungsFlag; + // Main functions virtual void GenerateOutputInformation(); virtual void GenerateInputRequestedRegion(); diff --git a/segmentation/clitkExtractLungFilter.txx b/segmentation/clitkExtractLungFilter.txx index 0954c2a..d2bff5e 100644 --- a/segmentation/clitkExtractLungFilter.txx +++ b/segmentation/clitkExtractLungFilter.txx @@ -414,49 +414,51 @@ GenerateOutputInformation() StopCurrentStep(working_mask); } - //-------------------------------------------------------------------- - //-------------------------------------------------------------------- - StartNewStep("Separate Left/Right lungs"); - PrintMemory(GetVerboseMemoryFlag(), "Before Separate"); - // Initial label - working_mask = Labelize(working_mask, - GetBackgroundValue(), - false, - GetMinimalComponentSize()); - - PrintMemory(GetVerboseMemoryFlag(), "After Labelize"); - - // Count the labels - typedef itk::StatisticsImageFilter StatisticsImageFilterType; - typename StatisticsImageFilterType::Pointer statisticsImageFilter=StatisticsImageFilterType::New(); - statisticsImageFilter->SetInput(working_mask); - statisticsImageFilter->Update(); - unsigned int initialNumberOfLabels = statisticsImageFilter->GetMaximum(); - working_mask = statisticsImageFilter->GetOutput(); + if (GetSeparateLungsFlag()) { + //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + StartNewStep("Separate Left/Right lungs"); + PrintMemory(GetVerboseMemoryFlag(), "Before Separate"); + // Initial label + working_mask = Labelize(working_mask, + GetBackgroundValue(), + false, + GetMinimalComponentSize()); + + PrintMemory(GetVerboseMemoryFlag(), "After Labelize"); + + // Count the labels + typedef itk::StatisticsImageFilter StatisticsImageFilterType; + typename StatisticsImageFilterType::Pointer statisticsImageFilter=StatisticsImageFilterType::New(); + statisticsImageFilter->SetInput(working_mask); + statisticsImageFilter->Update(); + unsigned int initialNumberOfLabels = statisticsImageFilter->GetMaximum(); + working_mask = statisticsImageFilter->GetOutput(); + + PrintMemory(GetVerboseMemoryFlag(), "After count label"); - PrintMemory(GetVerboseMemoryFlag(), "After count label"); - - // Decompose the first label - if (initialNumberOfLabels<2) { - // Structuring element radius - typename ImageType::SizeType radius; - for (unsigned int i=0;i DecomposeAndReconstructFilterType; - typename DecomposeAndReconstructFilterType::Pointer decomposeAndReconstructFilter=DecomposeAndReconstructFilterType::New(); - decomposeAndReconstructFilter->SetInput(working_mask); - decomposeAndReconstructFilter->SetVerbose(false); - decomposeAndReconstructFilter->SetRadius(radius); - decomposeAndReconstructFilter->SetMaximumNumberOfLabels(2); - decomposeAndReconstructFilter->SetMinimumObjectSize(this->GetMinimalComponentSize()); - decomposeAndReconstructFilter->SetMinimumNumberOfIterations(1); - decomposeAndReconstructFilter->SetBackgroundValue(this->GetBackgroundValue()); - decomposeAndReconstructFilter->SetForegroundValue(this->GetForegroundValue()); - decomposeAndReconstructFilter->SetFullyConnected(true); - decomposeAndReconstructFilter->SetNumberOfNewLabels(1); - decomposeAndReconstructFilter->Update(); - working_mask = decomposeAndReconstructFilter->GetOutput(); + // Decompose the first label + if (initialNumberOfLabels<2) { + // Structuring element radius + typename ImageType::SizeType radius; + for (unsigned int i=0;i DecomposeAndReconstructFilterType; + typename DecomposeAndReconstructFilterType::Pointer decomposeAndReconstructFilter=DecomposeAndReconstructFilterType::New(); + decomposeAndReconstructFilter->SetInput(working_mask); + decomposeAndReconstructFilter->SetVerbose(false); + decomposeAndReconstructFilter->SetRadius(radius); + decomposeAndReconstructFilter->SetMaximumNumberOfLabels(2); + decomposeAndReconstructFilter->SetMinimumObjectSize(this->GetMinimalComponentSize()); + decomposeAndReconstructFilter->SetMinimumNumberOfIterations(1); + decomposeAndReconstructFilter->SetBackgroundValue(this->GetBackgroundValue()); + decomposeAndReconstructFilter->SetForegroundValue(this->GetForegroundValue()); + decomposeAndReconstructFilter->SetFullyConnected(true); + decomposeAndReconstructFilter->SetNumberOfNewLabels(1); + decomposeAndReconstructFilter->Update(); + working_mask = decomposeAndReconstructFilter->GetOutput(); + } + PrintMemory(GetVerboseMemoryFlag(), "After decomposeAndReconstructFilter"); } - PrintMemory(GetVerboseMemoryFlag(), "After decomposeAndReconstructFilter"); // Retain labels ('1' is largset lung, so right. '2' is left) typedef itk::ThresholdImageFilter ThresholdImageFilterType; diff --git a/segmentation/clitkExtractLungGenericFilter.txx b/segmentation/clitkExtractLungGenericFilter.txx index 2dd396f..b40dc28 100644 --- a/segmentation/clitkExtractLungGenericFilter.txx +++ b/segmentation/clitkExtractLungGenericFilter.txx @@ -108,6 +108,11 @@ SetOptionsFromArgsInfoToFilter(FilterType * f) f->SetFillHolesFlag(false); else f->SetFillHolesFlag(true); + + if (mArgsInfo.doNotSeparateLungs_given) + f->SetSeparateLungsFlag(false); + else + f->SetSeparateLungsFlag(true); } //-------------------------------------------------------------------- -- 2.45.1