From e6b1c38b8b871b4fbd9bf602ecff48d289e9f12f Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Mon, 26 Sep 2011 09:07:31 +0200 Subject: [PATCH] Adapted with RelativePostion list management --- segmentation/clitkExtractLymphStation_2RL.txx | 481 +++--------------- segmentation/clitkExtractLymphStation_3A.txx | 106 +--- segmentation/clitkExtractLymphStation_3P.txx | 26 +- segmentation/clitkExtractLymphStation_7.txx | 10 +- segmentation/clitkExtractLymphStation_8.txx | 2 +- 5 files changed, 124 insertions(+), 501 deletions(-) diff --git a/segmentation/clitkExtractLymphStation_2RL.txx b/segmentation/clitkExtractLymphStation_2RL.txx index 260e50a..e31f2d5 100644 --- a/segmentation/clitkExtractLymphStation_2RL.txx +++ b/segmentation/clitkExtractLymphStation_2RL.txx @@ -17,12 +17,6 @@ void clitk::ExtractLymphStationsFilter:: ExtractStation_2RL_SetDefaultValues() { - SetFuzzyThreshold("2RL", "CommonCarotidArtery", 0.7); - SetFuzzyThreshold("2RL", "BrachioCephalicArtery", 0.7); - SetFuzzyThreshold("2RL", "BrachioCephalicVein", 0.3); - SetFuzzyThreshold("2RL", "Aorta", 0.7); - SetFuzzyThreshold("2RL", "SubclavianArteryRight", 0.5); - SetFuzzyThreshold("2RL", "SubclavianArteryLeft", 0.8); } //-------------------------------------------------------------------- @@ -35,215 +29,40 @@ ExtractStation_2RL() { if ((!CheckForStation("2R")) && (!CheckForStation("2L"))) return; - ExtractStation_2RL_SI_Limits(); - ExtractStation_2RL_Post_Limits(); - - ExtractStation_2RL_Ant_Limits2(); - //ExtractStation_2RL_Ant_Limits(); - - ExtractStation_2RL_LR_Limits(); - ExtractStation_2RL_Remove_Structures(); - ExtractStation_2RL_SeparateRL(); - - // Store image filenames into AFDB - writeImage(m_ListOfStations["2R"], "seg/Station2R.mhd"); - writeImage(m_ListOfStations["2L"], "seg/Station2L.mhd"); - GetAFDB()->SetImageFilename("Station2R", "seg/Station2R.mhd"); - GetAFDB()->SetImageFilename("Station2L", "seg/Station2L.mhd"); - WriteAFDB(); - -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -template -void -clitk::ExtractLymphStationsFilter:: -ExtractStation_2RL_SI_Limits() -{ - // Apex of the chest or Sternum & Carina. - StartNewStep("[Station 2RL] Inf/Sup limits with Sternum and TopOfAorticArch/CaudalMarginOfLeftBrachiocephalicVein"); + StartNewStep("Stations 2RL"); + StartSubStep(); - /* Rod says: "For the inferior border, unlike in Atlas – UM, there - is now a difference between 2R and 2L. 2R stops at the - intersection of the caudal margin of the innominate vein with the - trachea. 2L extends less inferiorly to the superior border of the - aortic arch." */ - - /* Get TopOfAorticArch and CaudalMarginOfLeftBrachiocephalicVein - - TopOfAorticArch -> can be obtain from Aorta -> most sup part. - - CaudalMarginOfLeftBrachiocephalicVein -> must inf part of BrachicephalicVein - */ - MaskImagePointer Aorta = GetAFDB()->template GetImage("Aorta"); - MaskImagePointType p = Aorta->GetOrigin(); // initialise to avoid warning - clitk::FindExtremaPointInAGivenDirection(Aorta, GetBackgroundValue(), 2, false, p); - double TopOfAorticArchZ=p[2]; - GetAFDB()->SetDouble("TopOfAorticArchZ", TopOfAorticArchZ); - - MaskImagePointer BrachioCephalicVein = GetAFDB()->template GetImage("BrachioCephalicVein"); - clitk::FindExtremaPointInAGivenDirection(BrachioCephalicVein, GetBackgroundValue(), 2, true, p); - double CaudalMarginOfLeftBrachiocephalicVeinZ=p[2]; - GetAFDB()->SetDouble("CaudalMarginOfLeftBrachiocephalicVeinZ", CaudalMarginOfLeftBrachiocephalicVeinZ); - - // First, cut on the most inferior part. Add one slice because this - // inf slice should not be included. - double inf = std::min(CaudalMarginOfLeftBrachiocephalicVeinZ, TopOfAorticArchZ) + m_Working_Support->GetSpacing()[2]; - - // Get Sternum and search for the upper position - MaskImagePointer Sternum = GetAFDB()->template GetImage("Sternum"); - - // Search most sup point - clitk::FindExtremaPointInAGivenDirection(Sternum, GetBackgroundValue(), 2, false, p); - double m_SternumZ = p[2]; - // +Sternum->GetSpacing()[2]; // One more slice, because it is below this point // NOT HERE ?? WHY DIFFERENT FROM 3A ?? - - //* Crop support : - m_Working_Support = - clitk::CropImageAlongOneAxis(m_Working_Support, 2, - inf, m_SternumZ, true, - GetBackgroundValue()); - - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -template -void -clitk::ExtractLymphStationsFilter:: -ExtractStation_2RL_Ant_Limits() -{ - // ----------------------------------------------------- - /* Rod says: "The anterior border, as with the Atlas – UM, is - posterior to the vessels (right subclavian vein, left - brachiocephalic vein, right brachiocephalic vein, left subclavian - artery, left common carotid artery and brachiocephalic trunk). - These vessels are not included in the nodal station. The anterior - border is drawn to the midpoint of the vessel and an imaginary - line joins the middle of these vessels. Between the vessels, - station 2 is in contact with station 3a." */ - - // ----------------------------------------------------- - StartNewStep("[Station 2RL] Ant limits with CommonCarotidArtery"); - - // Get CommonCarotidArtery - MaskImagePointer CommonCarotidArtery = GetAFDB()->template GetImage("CommonCarotidArtery"); - - // Remove Ant to CommonCarotidArtery - typedef SliceBySliceRelativePositionFilter SliceRelPosFilterType; - typename SliceRelPosFilterType::Pointer sliceRelPosFilter = SliceRelPosFilterType::New(); - sliceRelPosFilter->VerboseStepFlagOff(); - sliceRelPosFilter->WriteStepFlagOff(); - sliceRelPosFilter->SetInput(m_Working_Support); - sliceRelPosFilter->SetInputObject(CommonCarotidArtery); - sliceRelPosFilter->SetDirection(2); - sliceRelPosFilter->SetFuzzyThreshold(GetFuzzyThreshold("2RL", "CommonCarotidArtery")); - sliceRelPosFilter->AddOrientationTypeString("NotAntTo"); - sliceRelPosFilter->IntermediateSpacingFlagOn(); - sliceRelPosFilter->SetIntermediateSpacing(2); - sliceRelPosFilter->UniqueConnectedComponentBySliceOff(); - sliceRelPosFilter->UseASingleObjectConnectedComponentBySliceFlagOff(); - sliceRelPosFilter->AutoCropFlagOn(); - sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn(); - sliceRelPosFilter->RemoveObjectFlagOff(); - sliceRelPosFilter->Update(); - m_Working_Support = sliceRelPosFilter->GetOutput(); - - // End - StopCurrentStep(m_Working_Support); + // Get the current support + StartNewStep("[Station 2RL] Get the current 2RL suppport"); + m_ListOfStations["2R"] = m_ListOfSupports["S2R"]; + m_ListOfStations["2L"] = m_ListOfSupports["S2L"]; + StopCurrentStep(m_ListOfStations["2R"]); + + // Do the same limits for R & L + m_Working_Support = m_ListOfStations["2R"]; + ExtractStation_2RL_Ant_Limits("2R"); + ExtractStation_2RL_Remove_Structures(" 2R"); m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; - - // ----------------------------------------------------- - // Remove Ant to H line from the Ant most part of the - // CommonCarotidArtery until we reach the first slice of - // BrachioCephalicArtery - StartNewStep("[Station 2RL] Ant limits with CommonCarotidArtery, H line"); - // First, find the first slice of BrachioCephalicArtery - MaskImagePointer BrachioCephalicArtery = GetAFDB()->template GetImage("BrachioCephalicArtery"); - MaskImagePointType p = BrachioCephalicArtery->GetOrigin(); // initialise to avoid warning - clitk::FindExtremaPointInAGivenDirection(BrachioCephalicArtery, GetBackgroundValue(), 2, false, p); - double TopOfBrachioCephalicArteryZ=p[2] + BrachioCephalicArtery->GetSpacing()[2]; // Add one slice - - // Remove CommonCarotidArtery below this point - CommonCarotidArtery = clitk::CropImageRemoveLowerThan(CommonCarotidArtery, 2, TopOfBrachioCephalicArteryZ, true, GetBackgroundValue()); - - // Find most Ant points - std::vector ccaAntPositionA; - std::vector ccaAntPositionB; - clitk::SliceBySliceBuildLineSegmentAccordingToExtremaPosition(CommonCarotidArtery, - GetBackgroundValue(), 2, - 1, true, // Ant - 0, // Horizontal line - -3, // margin - ccaAntPositionA, - ccaAntPositionB); - // Cut ant to this line - clitk::SliceBySliceSetBackgroundFromLineSeparation(m_Working_Support, - ccaAntPositionA, - ccaAntPositionB, - GetBackgroundValue(), 1, 10); - - // End - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; + m_Working_Support = m_ListOfStations["2L"]; + ExtractStation_2RL_Ant_Limits("2L"); + ExtractStation_2RL_Remove_Structures(" 2L"); m_ListOfStations["2L"] = m_Working_Support; - // ----------------------------------------------------- - // Ant limit with the BrachioCephalicArtery - StartNewStep("[Station 2RL] Ant limits with BrachioCephalicArtery line"); + // Remove superior part to BrachioCephalicVein (used then by RelPos) + ExtractStation_2RL_Cut_BrachioCephalicVein_superiorly_when_it_split(); - // Remove Ant to BrachioCephalicArtery - m_Working_Support = - clitk::SliceBySliceRelativePosition(m_Working_Support, BrachioCephalicArtery, 2, - GetFuzzyThreshold("2RL", "BrachioCephalicArtery"), "NotAntTo", false, 2, true, false); - // End - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; - - // ----------------------------------------------------- - // Ant limit with the BrachioCephalicArtery H line - StartNewStep("[Station 2RL] Ant limits with BrachioCephalicArtery, Horizontal line"); + // Generic RelativePosition processes + m_ListOfStations["2R"] = this->ApplyRelativePositionList("Station_2R", m_ListOfStations["2R"]); + m_ListOfStations["2L"] = this->ApplyRelativePositionList("Station_2L", m_ListOfStations["2L"]); - // Find most Ant points - std::vector bctAntPositionA; - std::vector bctAntPositionB; - clitk::SliceBySliceBuildLineSegmentAccordingToExtremaPosition(BrachioCephalicArtery, - GetBackgroundValue(), 2, - 1, true, // Ant - 0, // Horizontal line - -1, // margin - bctAntPositionA, - bctAntPositionB); - // Cut ant to this line - clitk::SliceBySliceSetBackgroundFromLineSeparation(m_Working_Support, - bctAntPositionA, - bctAntPositionB, - GetBackgroundValue(), 1, 10); - // End - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; - - // ----------------------------------------------------- - // Ant limit with the BrachioCephalicVein - StartNewStep("[Station 2RL] Ant limits with BrachioCephalicVein"); - - // Remove Ant to BrachioCephalicVein - MaskImagePointer BrachioCephalicVein = GetAFDB()->template GetImage("BrachioCephalicVein"); - m_Working_Support = - clitk::SliceBySliceRelativePosition(m_Working_Support, BrachioCephalicVein, 2, - GetFuzzyThreshold("2RL", "BrachioCephalicVein"), "NotAntTo", false, 2, true, false); - // End - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; + // Store image filenames into AFDB + writeImage(m_ListOfStations["2R"], "seg/Station2R.mhd"); + writeImage(m_ListOfStations["2L"], "seg/Station2L.mhd"); + GetAFDB()->SetImageFilename("Station2R", "seg/Station2R.mhd"); + GetAFDB()->SetImageFilename("Station2L", "seg/Station2L.mhd"); + WriteAFDB(); + StopSubStep(); } //-------------------------------------------------------------------- @@ -252,10 +71,10 @@ ExtractStation_2RL_Ant_Limits() template void clitk::ExtractLymphStationsFilter:: -ExtractStation_2RL_Ant_Limits2() +ExtractStation_2RL_Ant_Limits(std::string s) { // ----------------------------------------------------- - StartNewStep("[Station 2RL] Ant limits with vessels centroids"); + StartNewStep("[Station "+s+"] Ant limits with vessels centroids"); // WARNING, as I used "And" after, empty slice in binarizedContour // lead to remove part of the support, although we want to keep @@ -268,7 +87,6 @@ ExtractStation_2RL_Ant_Limits2() binarizedContour = clitk::ResizeImageLike(binarizedContour, m_Working_Support, GetForegroundValue()); - // remove from support typedef clitk::BooleanOperatorLabelImageFilter BoolFilterType; typename BoolFilterType::Pointer boolFilter = BoolFilterType::New(); @@ -280,11 +98,9 @@ ExtractStation_2RL_Ant_Limits2() boolFilter->SetOperationType(BoolFilterType::And); boolFilter->Update(); m_Working_Support = boolFilter->GetOutput(); - + // End StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; } //-------------------------------------------------------------------- @@ -293,35 +109,43 @@ ExtractStation_2RL_Ant_Limits2() template void clitk::ExtractLymphStationsFilter:: -ExtractStation_2RL_Post_Limits() +ExtractStation_2RL_Cut_BrachioCephalicVein_superiorly_when_it_split() { - StartNewStep("[Station 2RL] Post limits with post wall of Trachea"); - - // Get Trachea - MaskImagePointer Trachea = GetAFDB()->template GetImage("Trachea"); + // ----------------------------------------------------- + StartNewStep("[Station 2RL] Cut BrachioCephalicVein superiorly (when it split)"); - // Resize like the current support (to have the same number of slices) - Trachea = clitk::ResizeImageLike(Trachea, m_Working_Support, GetBackgroundValue()); - - // Find extrema post positions - std::vector tracheaPostPositionsA; - std::vector tracheaPostPositionsB; - clitk::SliceBySliceBuildLineSegmentAccordingToExtremaPosition(Trachea, - GetBackgroundValue(), 2, - 1, false, // Post - 0, // Horizontal line - 1, - tracheaPostPositionsA, - tracheaPostPositionsB); - // Cut post to this line - clitk::SliceBySliceSetBackgroundFromLineSeparation(m_Working_Support, - tracheaPostPositionsA, - tracheaPostPositionsB, - GetBackgroundValue(), 1, -10); - // END - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; + // Get BrachioCephalicVein + MaskImagePointer BrachioCephalicVein = GetAFDB()->template GetImage("BrachioCephalicVein"); + + // Remove the part superior to the slice where BrachioCephalicVein + // divide in two CCL + std::vector BCV_slices; + clitk::ExtractSlices(BrachioCephalicVein, 2, BCV_slices); + bool stop = false; + uint i=0; + while (!stop) { + // Count the number of CCL + int nb; + clitk::LabelizeAndCountNumberOfObjects(BCV_slices[i], GetBackgroundValue(), true, 1, nb); + if (nb>1) stop = true; + i++; + } + // Convert slice into coordinate + MaskImagePointType p; + MaskImageIndexType index; + index[0] = index[1] = 0; + index[2] = i; + BrachioCephalicVein->TransformIndexToPhysicalPoint(index, p); + BrachioCephalicVein = + clitk::CropImageRemoveGreaterThan(BrachioCephalicVein, 2, + p[2], true, + GetBackgroundValue()); + + // Now, insert this image in the AFDB (but do not store on disk) + GetAFDB()->template SetImage("BrachioCephalicVein_ForS2RL", "bidon", + BrachioCephalicVein, false); + // End + StopCurrentStep(BrachioCephalicVein); } //-------------------------------------------------------------------- @@ -355,173 +179,18 @@ Build3DMeshFrom2DContour(const std::vector & points) template void clitk::ExtractLymphStationsFilter:: -ExtractStation_2RL_LR_Limits() +ExtractStation_2RL_Remove_Structures(std::string s) { - // --------------------------------------------------------------------------- - StartNewStep("[Station 2RL] Left/Right limits with Aorta"); - MaskImagePointer Aorta = GetAFDB()->template GetImage("Aorta"); - // DD(GetFuzzyThreshold("2RL", "BrachioCephalicVein")); - m_Working_Support = - clitk::SliceBySliceRelativePosition(m_Working_Support, Aorta, 2, - GetFuzzyThreshold("2RL", "Aorta"), - "RightTo", false, 2, true, false); - // END - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; - - // --------------------------------------------------------------------------- - StartNewStep("[Station 2RL] Left/Right limits with SubclavianArtery (Right)"); - - // SliceBySliceRelativePosition + select CCL most at Right - MaskImagePointer SubclavianArtery = GetAFDB()->template GetImage("SubclavianArtery"); - typedef SliceBySliceRelativePositionFilter SliceRelPosFilterType; - typename SliceRelPosFilterType::Pointer sliceRelPosFilter = SliceRelPosFilterType::New(); - sliceRelPosFilter->VerboseStepFlagOff(); - sliceRelPosFilter->WriteStepFlagOff(); - sliceRelPosFilter->SetInput(m_Working_Support); - sliceRelPosFilter->SetInputObject(SubclavianArtery); - sliceRelPosFilter->SetDirection(2); - sliceRelPosFilter->SetFuzzyThreshold(GetFuzzyThreshold("2RL", "SubclavianArteryRight")); - sliceRelPosFilter->AddOrientationTypeString("NotRightTo"); - sliceRelPosFilter->IntermediateSpacingFlagOn(); - sliceRelPosFilter->SetIntermediateSpacing(2); - sliceRelPosFilter->UniqueConnectedComponentBySliceOff(); - sliceRelPosFilter->UseASingleObjectConnectedComponentBySliceFlagOff(); - - sliceRelPosFilter->CCLSelectionFlagOn(); // select one CCL by slice - sliceRelPosFilter->SetCCLSelectionDimension(0); // select according to X (0) axis - sliceRelPosFilter->SetCCLSelectionDirection(-1); // select most at Right - sliceRelPosFilter->CCLSelectionIgnoreSingleCCLFlagOn(); // ignore if only one CCL - - sliceRelPosFilter->AutoCropFlagOn(); - sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn(); - sliceRelPosFilter->RemoveObjectFlagOff(); - sliceRelPosFilter->Update(); - m_Working_Support = sliceRelPosFilter->GetOutput(); - - // END - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; - - - // --------------------------------------------------------------------------- - StartNewStep("[Station 2RL] Left/Right limits with SubclavianArtery (Left)"); - - // SliceBySliceRelativePosition + select CCL most at Right - sliceRelPosFilter = SliceRelPosFilterType::New(); - sliceRelPosFilter->VerboseStepFlagOff(); - sliceRelPosFilter->WriteStepFlagOff(); - sliceRelPosFilter->SetInput(m_Working_Support); - sliceRelPosFilter->SetInputObject(SubclavianArtery); - sliceRelPosFilter->SetDirection(2); - sliceRelPosFilter->SetFuzzyThreshold(GetFuzzyThreshold("2RL", "SubclavianArteryLeft")); - sliceRelPosFilter->AddOrientationTypeString("NotLeftTo"); - sliceRelPosFilter->IntermediateSpacingFlagOn(); - sliceRelPosFilter->SetIntermediateSpacing(2); - sliceRelPosFilter->UniqueConnectedComponentBySliceOff(); - sliceRelPosFilter->UseASingleObjectConnectedComponentBySliceFlagOff(); - - sliceRelPosFilter->CCLSelectionFlagOn(); // select one CCL by slice - sliceRelPosFilter->SetCCLSelectionDimension(0); // select according to X (0) axis - sliceRelPosFilter->SetCCLSelectionDirection(+1); // select most at Left - sliceRelPosFilter->CCLSelectionIgnoreSingleCCLFlagOff(); // do not ignore if only one CCL - - sliceRelPosFilter->AutoCropFlagOn(); - sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn(); - sliceRelPosFilter->RemoveObjectFlagOff(); - sliceRelPosFilter->Update(); - m_Working_Support = sliceRelPosFilter->GetOutput(); - - // END - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; -} -//-------------------------------------------------------------------- - -//-------------------------------------------------------------------- -template -void -clitk::ExtractLymphStationsFilter:: -ExtractStation_2RL_Remove_Structures() -{ - Remove_Structures("2RL", "BrachioCephalicVein"); - Remove_Structures("2RL", "CommonCarotidArtery"); - Remove_Structures("2RL", "SubclavianArtery"); - Remove_Structures("2RL", "Thyroid"); - Remove_Structures("2RL", "Aorta"); - - // END - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support; + // m_Working_Support must be set + Remove_Structures(s, "BrachioCephalicVein"); + Remove_Structures(s, "BrachioCephalicArtery"); + Remove_Structures(s, "CommonCarotidArteryLeft"); + Remove_Structures(s, "CommonCarotidArteryRight"); + Remove_Structures(s, "SubclavianArteryLeft"); + Remove_Structures(s, "SubclavianArteryRight"); + Remove_Structures(s, "Thyroid"); + Remove_Structures(s, "Aorta"); } //-------------------------------------------------------------------- -//-------------------------------------------------------------------- -template -void -clitk::ExtractLymphStationsFilter:: -ExtractStation_2RL_SeparateRL() -{ - // --------------------------------------------------------------------------- - StartNewStep("[Station 2RL] Separate 2R/2L according to Trachea"); - - /*Rod says: - - "For station 2 there is a shift, dividing 2R from 2L, from midline - to the left paratracheal border." - - Algo: - - Consider Trachea SliceBySlice - - find extrema at Left - - add margins towards Right - - remove what is at Left of this line - */ - - // Get Trachea - MaskImagePointer Trachea = GetAFDB()->template GetImage("Trachea"); - - // Resize like the current support (to have the same number of slices) - Trachea = clitk::ResizeImageLike(Trachea, m_Working_Support, GetBackgroundValue()); - - // Find extrema post positions - std::vector tracheaLeftPositionsA; - std::vector tracheaLeftPositionsB; - clitk::SliceBySliceBuildLineSegmentAccordingToExtremaPosition(Trachea, - GetBackgroundValue(), 2, - 0, false, // Left - 1, // Vertical line - 1, // margins - tracheaLeftPositionsA, - tracheaLeftPositionsB); - // Copy support for R and L - typedef itk::ImageDuplicator DuplicatorType; - DuplicatorType::Pointer duplicator = DuplicatorType::New(); - duplicator->SetInputImage(m_Working_Support); - duplicator->Update(); - MaskImageType::Pointer m_Working_Support2 = duplicator->GetOutput(); - - // Cut post to this line for Right part - clitk::SliceBySliceSetBackgroundFromLineSeparation(m_Working_Support, - tracheaLeftPositionsA, - tracheaLeftPositionsB, - GetBackgroundValue(), 0, -10); - writeImage(m_Working_Support, "R.mhd"); - - // Cut post to this line for Left part - clitk::SliceBySliceSetBackgroundFromLineSeparation(m_Working_Support2, - tracheaLeftPositionsA, - tracheaLeftPositionsB, - GetBackgroundValue(), 0, +10); - writeImage(m_Working_Support2, "L.mhd"); - - // END - StopCurrentStep(m_Working_Support); - m_ListOfStations["2R"] = m_Working_Support; - m_ListOfStations["2L"] = m_Working_Support2; -} -//-------------------------------------------------------------------- diff --git a/segmentation/clitkExtractLymphStation_3A.txx b/segmentation/clitkExtractLymphStation_3A.txx index 8bcabc5..ba2fa62 100644 --- a/segmentation/clitkExtractLymphStation_3A.txx +++ b/segmentation/clitkExtractLymphStation_3A.txx @@ -5,8 +5,6 @@ void clitk::ExtractLymphStationsFilter:: ExtractStation_3A_SetDefaultValues() { - SetFuzzyThreshold("3A", "Sternum", 0.5); - SetFuzzyThreshold("3A", "SubclavianArtery", 0.5); } //-------------------------------------------------------------------- @@ -28,21 +26,14 @@ ExtractStation_3A() m_ListOfStations["3A"] = m_Working_Support; StopCurrentStep(m_Working_Support); - ExtractStation_3A_AntPost_S5(); - ExtractStation_3A_AntPost_S6(); + ExtractStation_3A_Post_Left_Limits_With_Aorta_S5_Support(); + ExtractStation_3A_Post_Limits_With_Dilated_Aorta_S6_Support(); ExtractStation_3A_AntPost_Superiorly(); ExtractStation_3A_Remove_Structures(); - - Remove_Structures("3A", "Aorta"); - Remove_Structures("3A", "SubclavianArteryLeft"); - Remove_Structures("3A", "SubclavianArteryRight"); - Remove_Structures("3A", "Thyroid"); - Remove_Structures("3A", "CommonCarotidArteryLeft"); - Remove_Structures("3A", "CommonCarotidArteryRight"); - Remove_Structures("3A", "BrachioCephalicArtery"); - - ExtractStation_3A_PostToBones(); + // Generic RelativePosition processes + m_ListOfStations["3A"] = this->ApplyRelativePositionList("Station_3A", m_ListOfStations["3A"]); + // Keep a single CCL m_ListOfStations["3A"] = clitk::SliceBySliceKeepMainCCL(m_ListOfStations["3A"], @@ -63,22 +54,11 @@ ExtractStation_3A() template void clitk::ExtractLymphStationsFilter:: -ExtractStation_3A_AntPost_S5() +ExtractStation_3A_Post_Left_Limits_With_Aorta_S5_Support() { - StartNewStep("[Station 3A] Post limits around S5"); - - // First remove post to SVC - MaskImagePointer SVC = GetAFDB()->template GetImage ("SVC"); - - // Trial in 3D -> difficulties superiorly. Stay slice by slice. - // Slice by slice not post to SVC. Use initial spacing - m_Working_Support = - clitk::SliceBySliceRelativePosition(m_Working_Support, SVC, 2, - GetFuzzyThreshold("3A", "SVC"), - "NotPostTo", true, - SVC->GetSpacing()[0], false, false); + StartNewStep("[Station 3A] Post limits in S5 support according to Aorta"); - // Consider Aorta, remove Left/Post part ; only around S5 + // Consider Aorta, remove Left/Post part ; only around S5 // Get S5 support and Aorta MaskImagePointer S5 = m_ListOfSupports["S5"]; MaskImagePointer Aorta = GetAFDB()->template GetImage ("Aorta"); @@ -142,9 +122,9 @@ ExtractStation_3A_AntPost_S5() template void clitk::ExtractLymphStationsFilter:: -ExtractStation_3A_AntPost_S6() +ExtractStation_3A_Post_Limits_With_Dilated_Aorta_S6_Support() { - StartNewStep("[Station 3A] Post limits around S6"); + StartNewStep("[Station 3A] Post limits with dilated Aorta"); // Consider Aorta MaskImagePointer Aorta = GetAFDB()->template GetImage ("Aorta"); @@ -160,12 +140,19 @@ ExtractStation_3A_AntPost_S6() radius[2] = 0; // required Aorta = clitk::Dilate(Aorta, radius, GetBackgroundValue(), GetForegroundValue(), false); + // Now, insert this image in the AFDB (but do not store on disk) + GetAFDB()->template SetImage("Aorta_Dilated_Anteriorly", "bidon", + Aorta, false); + /* // Not Post to m_Working_Support = clitk::SliceBySliceRelativePosition(m_Working_Support, Aorta, 2, GetFuzzyThreshold("3A", "Aorta"), "NotPostTo", true, Aorta->GetSpacing()[0], false, false); + + */ + StopCurrentStep(m_Working_Support); m_ListOfStations["3A"] = m_Working_Support; @@ -180,30 +167,6 @@ clitk::ExtractLymphStationsFilter:: ExtractStation_3A_AntPost_Superiorly() { StartNewStep("[Station 3A] Post limits superiorly"); - - /* - MaskImagePointer BrachioCephalicVein = GetAFDB()->template GetImage ("BrachioCephalicVein"); - MaskImagePointer BrachioCephalicArtery = GetAFDB()->template GetImage ("BrachioCephalicArtery"); - MaskImagePointer CommonCarotidArteryLeft = GetAFDB()->template GetImage ("CommonCarotidArteryLeft"); - MaskImagePointer CommonCarotidArteryRight = GetAFDB()->template GetImage ("CommonCarotidArteryRight"); - MaskImagePointer SubclavianArteryLeft = GetAFDB()->template GetImage ("SubclavianArteryLeft"); - MaskImagePointer SubclavianArteryRight = GetAFDB()->template GetImage ("SubclavianArteryRight"); - - // Not Post to -#define RP(STRUCTURE) \ - m_Working_Support = \ - clitk::SliceBySliceRelativePosition(m_Working_Support, STRUCTURE, 2, \ - 0.5, \ - "NotPostTo", true, \ - STRUCTURE->GetSpacing()[0], false, false); - - // RP(BrachioCephalicVein); - RP(BrachioCephalicArtery); - RP(CommonCarotidArteryRight); - RP(CommonCarotidArteryLeft); - RP(SubclavianArteryRight); - RP(SubclavianArteryLeft); - */ // Get or compute the binary mask that separate Ant/Post part // according to vessels @@ -236,13 +199,14 @@ void clitk::ExtractLymphStationsFilter:: ExtractStation_3A_Remove_Structures() { - Remove_Structures("3A", "Aorta"); - Remove_Structures("3A", "SubclavianArteryLeft"); - Remove_Structures("3A", "SubclavianArteryRight"); - Remove_Structures("3A", "Thyroid"); - Remove_Structures("3A", "CommonCarotidArteryLeft"); - Remove_Structures("3A", "CommonCarotidArteryRight"); - Remove_Structures("3A", "BrachioCephalicArtery"); + Remove_Structures(" 3A", "Aorta"); + Remove_Structures(" 3A", "SubclavianArteryLeft"); + Remove_Structures(" 3A", "SubclavianArteryRight"); + Remove_Structures(" 3A", "Thyroid"); + Remove_Structures(" 3A", "CommonCarotidArteryLeft"); + Remove_Structures(" 3A", "CommonCarotidArteryRight"); + Remove_Structures(" 3A", "BrachioCephalicArtery"); + // Remove_Structures("3A", "Bones"); --> should be in extractmediastinum // Remove_Structures("3A", "BrachioCephalicVein"); ? StartNewStep("[Station 3A] Remove part of BrachioCephalicVein"); @@ -297,23 +261,3 @@ ExtractStation_3A_Remove_Structures() //-------------------------------------------------------------------- -//-------------------------------------------------------------------- -template -void -clitk::ExtractLymphStationsFilter:: -ExtractStation_3A_PostToBones() -{ - StartNewStep("[Station 3A] Post limits with bones"); - - // limits with bones - MaskImagePointer Bones = GetAFDB()->template GetImage("Bones"); - m_Working_Support = - clitk::SliceBySliceRelativePosition(m_Working_Support, Bones, 2, - GetFuzzyThreshold("3A", "Bones"), "NotAntTo", - false, 3, true, false); - - StopCurrentStep(m_Working_Support); - m_ListOfStations["3A"] = m_Working_Support; -} -//-------------------------------------------------------------------- - diff --git a/segmentation/clitkExtractLymphStation_3P.txx b/segmentation/clitkExtractLymphStation_3P.txx index 3478b49..a9d073b 100644 --- a/segmentation/clitkExtractLymphStation_3P.txx +++ b/segmentation/clitkExtractLymphStation_3P.txx @@ -25,18 +25,28 @@ ExtractStation_3P() m_Working_Support = m_ListOfSupports["S3P"]; m_ListOfStations["3P"] = m_Working_Support; StopCurrentStep(m_Working_Support); + + /* TODO + LR_sup -> AzygousVein, Aorta + +keep computed object, RelPos then + + + */ + - // LR limits inferiorly - ExtractStation_3P_LR_inf_Limits(); - + ExtractStation_3P_LR_inf_Limits(); + ExtractStation_8_Single_CCL_Limits(); // YES 8 ! + ExtractStation_3P_Remove_Structures(); // after CCL + + // Old stuff // LR limits superiorly => not here for the moment because not // clear in the def // ExtractStation_3P_LR_sup_Limits_2(); //TODO // ExtractStation_3P_LR_sup_Limits(); // old version to change - ExtractStation_8_Single_CCL_Limits(); // YES 8 ! - ExtractStation_3P_Remove_Structures(); // after CCL - + m_ListOfStations["3P"] = this->ApplyRelativePositionList("Station_3P", m_ListOfStations["3P"]); + // Store image filenames into AFDB writeImage(m_ListOfStations["3P"], "seg/Station3P.mhd"); GetAFDB()->SetImageFilename("Station3P", "seg/Station3P.mhd"); @@ -170,7 +180,7 @@ ExtractStation_3P_LR_sup_Limits() relPosFilter->SetBackgroundValue(GetBackgroundValue()); relPosFilter->SetInput(slices_support[i]); relPosFilter->SetInputObject(object); - relPosFilter->AddOrientationTypeString("R"); + relPosFilter->AddOrientationTypeString("RightTo"); relPosFilter->SetInverseOrientationFlag(true); // relPosFilter->SetIntermediateSpacing(3); relPosFilter->SetIntermediateSpacingFlag(false); @@ -186,7 +196,7 @@ ExtractStation_3P_LR_sup_Limits() relPosFilter->SetBackgroundValue(GetBackgroundValue()); relPosFilter->SetInput(slices_support[i]); relPosFilter->SetInputObject(object); - relPosFilter->AddOrientationTypeString("A"); + relPosFilter->AddOrientationTypeString("AntTo"); relPosFilter->SetInverseOrientationFlag(true); // relPosFilter->SetIntermediateSpacing(3); relPosFilter->SetIntermediateSpacingFlag(false); diff --git a/segmentation/clitkExtractLymphStation_7.txx b/segmentation/clitkExtractLymphStation_7.txx index bcf2ccb..d6df428 100644 --- a/segmentation/clitkExtractLymphStation_7.txx +++ b/segmentation/clitkExtractLymphStation_7.txx @@ -354,7 +354,7 @@ ExtractStation_7_RL_Limits_OLD() sliceRelPosFilter->AddOrientationTypeString("NotAntTo"); sliceRelPosFilter->SetIntermediateSpacingFlag(true); sliceRelPosFilter->SetIntermediateSpacing(3); - sliceRelPosFilter->SetUniqueConnectedComponentBySlice(false); + sliceRelPosFilter->SetUniqueConnectedComponentBySliceFlag(false); sliceRelPosFilter->SetAutoCropFlag(false); sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn(); sliceRelPosFilter->Update(); @@ -380,7 +380,7 @@ ExtractStation_7_RL_Limits_OLD() sliceRelPosFilter->AddOrientationTypeString("NotPostTo"); sliceRelPosFilter->SetIntermediateSpacingFlag(true); sliceRelPosFilter->SetIntermediateSpacing(3); - sliceRelPosFilter->SetUniqueConnectedComponentBySlice(false); + sliceRelPosFilter->SetUniqueConnectedComponentBySliceFlag(false); sliceRelPosFilter->SetAutoCropFlag(false); sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn(); sliceRelPosFilter->Update(); @@ -403,7 +403,7 @@ ExtractStation_7_RL_Limits_OLD() sliceRelPosFilter->AddOrientationTypeString("NotAntTo"); sliceRelPosFilter->SetIntermediateSpacingFlag(true); sliceRelPosFilter->SetIntermediateSpacing(3); - sliceRelPosFilter->SetUniqueConnectedComponentBySlice(false); + sliceRelPosFilter->SetUniqueConnectedComponentBySliceFlag(false); sliceRelPosFilter->SetAutoCropFlag(false); sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn(); sliceRelPosFilter->Update(); @@ -421,7 +421,7 @@ ExtractStation_7_RL_Limits_OLD() sliceRelPosFilter->AddOrientationTypeString("NotAntTo"); sliceRelPosFilter->SetIntermediateSpacingFlag(true); sliceRelPosFilter->SetIntermediateSpacing(3); - sliceRelPosFilter->SetUniqueConnectedComponentBySlice(false); + sliceRelPosFilter->SetUniqueConnectedComponentBySliceFlag(false); sliceRelPosFilter->SetAutoCropFlag(false); sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn(); sliceRelPosFilter->Update(); @@ -439,7 +439,7 @@ ExtractStation_7_RL_Limits_OLD() sliceRelPosFilter->AddOrientationTypeString("NotAntTo"); sliceRelPosFilter->SetIntermediateSpacingFlag(true); sliceRelPosFilter->SetIntermediateSpacing(3); - sliceRelPosFilter->SetUniqueConnectedComponentBySlice(false); + sliceRelPosFilter->SetUniqueConnectedComponentBySliceFlag(false); sliceRelPosFilter->SetAutoCropFlag(true); sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn(); sliceRelPosFilter->Update(); diff --git a/segmentation/clitkExtractLymphStation_8.txx b/segmentation/clitkExtractLymphStation_8.txx index 7d5a15c..d4bbfc3 100644 --- a/segmentation/clitkExtractLymphStation_8.txx +++ b/segmentation/clitkExtractLymphStation_8.txx @@ -157,7 +157,7 @@ ExtractStation_8_Ant_Limits() relPosFilter->AddOrientationTypeString("PostTo"); // relPosFilter->InverseOrientationFlagOff(); relPosFilter->SetDirection(2); // Z axis - relPosFilter->UniqueConnectedComponentBySliceOff(); + relPosFilter->UniqueConnectedComponentBySliceFlagOff(); relPosFilter->SetIntermediateSpacing(3); relPosFilter->IntermediateSpacingFlagOn(); relPosFilter->SetFuzzyThreshold(GetFuzzyThreshold("8", "Esophagus")); -- 2.47.1