From: dsarrut Date: Mon, 4 Oct 2010 07:54:45 +0000 (+0000) Subject: read carina position into DB X-Git-Tag: v1.2.0~369 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=df08bfa3c4c20736f7194764643e7104eed63be9;p=clitk.git read carina position into DB --- diff --git a/segmentation/clitkExtractLymphStations.cxx b/segmentation/clitkExtractLymphStations.cxx index cf392f8..ec41a4e 100644 --- a/segmentation/clitkExtractLymphStations.cxx +++ b/segmentation/clitkExtractLymphStations.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/clitkExtractLymphStations.ggo b/segmentation/clitkExtractLymphStations.ggo index 28d78f6..3e493a1 100644 --- a/segmentation/clitkExtractLymphStations.ggo +++ b/segmentation/clitkExtractLymphStations.ggo @@ -13,6 +13,7 @@ option "verboseWarningOff" - "Do not display warning" flag off section "I/O" +option "afdb" a "Input Anatomical Feature DB" string no option "mediastinum" m "Input mediastinum mask filename" string yes option "trachea" t "Input trachea mask filename" string yes option "output" o "Output lungs mask filename" string yes diff --git a/segmentation/clitkExtractLymphStationsFilter.h b/segmentation/clitkExtractLymphStationsFilter.h index e6b11a7..6db26a2 100644 --- a/segmentation/clitkExtractLymphStationsFilter.h +++ b/segmentation/clitkExtractLymphStationsFilter.h @@ -19,7 +19,9 @@ #ifndef CLITKEXTRACTLYMPHSTATIONSFILTER_H #define CLITKEXTRACTLYMPHSTATIONSFILTER_H +// clitk #include "clitkFilterBase.h" +#include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h" namespace clitk { @@ -35,8 +37,9 @@ namespace clitk { template class ITK_EXPORT ExtractLymphStationsFilter: - public clitk::FilterBase, - public itk::ImageToImageFilter + public virtual clitk::FilterBase, + public clitk::FilterWithAnatomicalFeatureDatabaseManagement, + public itk::ImageToImageFilter { public: @@ -61,6 +64,7 @@ namespace clitk { typedef typename ImageType::PixelType ImagePixelType; typedef typename ImageType::SizeType ImageSizeType; typedef typename ImageType::IndexType ImageIndexType; + typedef typename ImageType::PointType ImagePointType; /** Connect inputs */ void SetInputMediastinumLabelImage(const TImageType * image, ImagePixelType bg=0); @@ -85,9 +89,10 @@ namespace clitk { itkGetConstMacro(BackgroundValue, ImagePixelType); itkGetConstMacro(ForegroundValue, ImagePixelType); - itkSetMacro(CarenaZPositionInMM, double); - itkGetConstMacro(CarenaZPositionInMM, double); - GGO_DefineOption(carenaZposition, SetCarenaZPositionInMM, double); + //itkSetMacro(CarinaZPositionInMM, double); + void SetCarinaZPositionInMM(double d) { m_CarinaZPositionInMM = d; Modified(); m_CarinaZPositionInMMIsSet = true; } + itkGetConstMacro(CarinaZPositionInMM, double); + GGO_DefineOption(carenaZposition, SetCarinaZPositionInMM, double); itkSetMacro(MiddleLobeBronchusZPositionInMM, double); itkGetConstMacro(MiddleLobeBronchusZPositionInMM, double); @@ -100,9 +105,7 @@ namespace clitk { itkSetMacro(FuzzyThreshold1, double); itkGetConstMacro(FuzzyThreshold1, double); GGO_DefineOption(fuzzy1, SetFuzzyThreshold1, double); - - - + protected: ExtractLymphStationsFilter(); virtual ~ExtractLymphStationsFilter() {} @@ -125,7 +128,8 @@ namespace clitk { ImagePixelType m_BackgroundValue; ImagePixelType m_ForegroundValue; - double m_CarenaZPositionInMM; + double m_CarinaZPositionInMM; + bool m_CarinaZPositionInMMIsSet; double m_MiddleLobeBronchusZPositionInMM; double m_IntermediateSpacing; double m_FuzzyThreshold1; diff --git a/segmentation/clitkExtractLymphStationsFilter.txx b/segmentation/clitkExtractLymphStationsFilter.txx index aab78d8..919d480 100644 --- a/segmentation/clitkExtractLymphStationsFilter.txx +++ b/segmentation/clitkExtractLymphStationsFilter.txx @@ -44,6 +44,7 @@ template clitk::ExtractLymphStationsFilter:: ExtractLymphStationsFilter(): clitk::FilterBase(), + clitk::FilterWithAnatomicalFeatureDatabaseManagement(), itk::ImageToImageFilter() { this->SetNumberOfRequiredInputs(1); @@ -51,9 +52,9 @@ ExtractLymphStationsFilter(): SetBackgroundValueTrachea(0); SetBackgroundValue(0); SetForegroundValue(1); - SetIntermediateSpacing(6); - SetFuzzyThreshold1(0.6); + SetFuzzyThreshold1(0.6); + m_CarinaZPositionInMMIsSet = false; } //-------------------------------------------------------------------- @@ -64,11 +65,7 @@ void clitk::ExtractLymphStationsFilter:: SetInputMediastinumLabelImage(const TImageType * image, ImagePixelType bg) { this->SetNthInput(0, const_cast(image)); - m_BackgroundValueMediastinum = bg; - SetCarenaZPositionInMM(image->GetOrigin()[2]+image->GetLargestPossibleRegion().GetSize()[2]*image->GetSpacing()[2]); - SetMiddleLobeBronchusZPositionInMM(image->GetOrigin()[2]); - // DD(m_CarenaZPositionInMM); -// DD(m_MiddleLobeBronchusZPositionInMM); + SetBackgroundValueMediastinum(bg); } //-------------------------------------------------------------------- @@ -79,7 +76,7 @@ void clitk::ExtractLymphStationsFilter:: SetInputTracheaLabelImage(const TImageType * image, ImagePixelType bg) { this->SetNthInput(1, const_cast(image)); - m_BackgroundValueTrachea = bg; + SetBackgroundValueTrachea(bg); } //-------------------------------------------------------------------- @@ -95,11 +92,12 @@ SetArgsInfo(ArgsInfoType mArgsInfo) SetVerboseStep_GGO(mArgsInfo); SetWriteStep_GGO(mArgsInfo); SetVerboseWarningOff_GGO(mArgsInfo); - SetCarenaZPositionInMM_GGO(mArgsInfo); + SetAFDBFilename_GGO(mArgsInfo); + SetCarinaZPositionInMM_GGO(mArgsInfo); + m_CarinaZPositionInMMIsSet = false; SetMiddleLobeBronchusZPositionInMM_GGO(mArgsInfo); SetIntermediateSpacing_GGO(mArgsInfo); SetFuzzyThreshold1_GGO(mArgsInfo); - //SetBackgroundValueMediastinum_GGO(mArgsInfo); } //-------------------------------------------------------------------- @@ -114,7 +112,17 @@ GenerateOutputInformation() { // Get input m_mediastinum = dynamic_cast(itk::ProcessObject::GetInput(0)); m_trachea = dynamic_cast(itk::ProcessObject::GetInput(1)); - + + // Get landmarks information + if (!m_CarinaZPositionInMMIsSet) { + ImagePointType carina; + LoadAFDB(); + GetAFDB()->GetPoint3D("Carena", carina); + DD(carina); + m_CarinaZPositionInMM = carina[2]; + } + DD(m_CarinaZPositionInMM); + // ---------------------------------------------------------------- // ---------------------------------------------------------------- // Superior limit = carena @@ -123,10 +131,10 @@ GenerateOutputInformation() { ImageRegionType region = m_mediastinum->GetLargestPossibleRegion(); DD(region); ImageSizeType size = region.GetSize(); ImageIndexType index = region.GetIndex(); - DD(m_CarenaZPositionInMM); + DD(m_CarinaZPositionInMM); DD(m_MiddleLobeBronchusZPositionInMM); index[2] = floor((m_MiddleLobeBronchusZPositionInMM - m_mediastinum->GetOrigin()[2]) / m_mediastinum->GetSpacing()[2]); - size[2] = ceil((m_CarenaZPositionInMM-m_MiddleLobeBronchusZPositionInMM) / m_mediastinum->GetSpacing()[2]); + size[2] = ceil((m_CarinaZPositionInMM-m_MiddleLobeBronchusZPositionInMM) / m_mediastinum->GetSpacing()[2]); region.SetSize(size); region.SetIndex(index); DD(region); @@ -227,7 +235,7 @@ GenerateOutputInformation() { sliceRelPosFilter->SetInput(m_working_image); sliceRelPosFilter->SetInputObject(temp); sliceRelPosFilter->SetDirection(2); - sliceRelPosFilter->SetFuzzyThreshold(0.5); + sliceRelPosFilter->SetFuzzyThreshold(0.6); sliceRelPosFilter->SetOrientationType(SliceRelPosFilterType::RelPosFilterType::RightTo); sliceRelPosFilter->Update(); m_working_image = sliceRelPosFilter->GetOutput(); @@ -247,7 +255,7 @@ GenerateOutputInformation() { sliceRelPosFilter->SetInput(m_working_image); sliceRelPosFilter->SetInputObject(temp); sliceRelPosFilter->SetDirection(2); - sliceRelPosFilter->SetFuzzyThreshold(0.5); + sliceRelPosFilter->SetFuzzyThreshold(0.6); sliceRelPosFilter->SetOrientationType(SliceRelPosFilterType::RelPosFilterType::LeftTo); sliceRelPosFilter->Update(); m_working_image = sliceRelPosFilter->GetOutput(); diff --git a/segmentation/clitkExtractLymphStationsGenericFilter.txx b/segmentation/clitkExtractLymphStationsGenericFilter.txx index 2644c1f..fb6d4da 100644 --- a/segmentation/clitkExtractLymphStationsGenericFilter.txx +++ b/segmentation/clitkExtractLymphStationsGenericFilter.txx @@ -81,14 +81,17 @@ void clitk::ExtractLymphStationsGenericFilter::UpdateWithInputImag filter->SetArgsInfo(mArgsInfo); // Go ! - filter->Update(); + // try { + filter->Update(); + // } + // catch(std::runtime_error e) { - // Check if error - if (filter->HasError()) { - SetLastError(filter->GetLastError()); - // No output - return; - } + // // Check if error + // if (filter->HasError()) { + // SetLastError(filter->GetLastError()); + // // No output + // return; + // } // Write/Save results typename ImageType::Pointer output = filter->GetOutput();