X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkExtractLymphStation_3A.txx;h=e973ed02d07655caac505bbbf2c78a24403320dd;hb=e3dfdd2305abb337638468aaca3d9b20718b5026;hp=e5529bf4c1852a86e4975e0a33ec2adffdedd94c;hpb=6c46b5b1d02d65fdb3fdccc8174346b49a05a32f;p=clitk.git diff --git a/segmentation/clitkExtractLymphStation_3A.txx b/segmentation/clitkExtractLymphStation_3A.txx index e5529bf..e973ed0 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); } //-------------------------------------------------------------------- @@ -18,126 +16,49 @@ clitk::ExtractLymphStationsFilter:: ExtractStation_3A() { if (!CheckForStation("3A")) return; - + + StartNewStep("Station 3A"); + StartSubStep(); + // Get the current support StartNewStep("[Station 3A] Get the current 3A suppport"); m_Working_Support = m_ListOfSupports["S3A"]; 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(); + + // Generic RelativePosition processes + m_ListOfStations["3A"] = this->ApplyRelativePositionList("Station_3A", m_ListOfStations["3A"]); - 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", "BrachioCephalicVein"); ? - - - // ExtractStation_3A_Ant_Limits(); --> No, already in support; to remove - // ExtractStation_3A_Post_Limits(); --> No, more complex, see Vessels etc + // Keep a single CCL + m_ListOfStations["3A"] = + clitk::SliceBySliceKeepMainCCL(m_ListOfStations["3A"], + GetBackgroundValue(), + GetForegroundValue()); // Store image filenames into AFDB writeImage(m_ListOfStations["3A"], "seg/Station3A.mhd"); GetAFDB()->SetImageFilename("Station3A", "seg/Station3A.mhd"); WriteAFDB(); + StopSubStep(); } //-------------------------------------------------------------------- -//-------------------------------------------------------------------- -template -void -clitk::ExtractLymphStationsFilter:: -ExtractStation_3A_Ant_Limits() -{ - StartNewStep("[Station 3A] Ant limits with Sternum"); - - // Get Sternum, keep posterior part. - MaskImagePointer Sternum = GetAFDB()->template GetImage("Sternum"); - m_Working_Support = - clitk::SliceBySliceRelativePosition(m_Working_Support, Sternum, 2, - GetFuzzyThreshold("3A", "Sternum"), "PostTo", - false, 3, true, false); - StopCurrentStep(m_Working_Support); - m_ListOfStations["3A"] = m_Working_Support; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -template -void -clitk::ExtractLymphStationsFilter:: -ExtractStation_3A_Post_Limits() -{ - StartNewStep("[Station 3A] Post limits with SubclavianArtery"); - - // Get Sternum, keep posterior part. - MaskImagePointer SubclavianArteryLeft = - GetAFDB()->template GetImage("SubclavianArteryLeft"); - MaskImagePointer SubclavianArteryRight = - GetAFDB()->template GetImage("SubclavianArteryRight"); - - m_Working_Support = - clitk::SliceBySliceRelativePosition(m_Working_Support, SubclavianArteryLeft, 2, - GetFuzzyThreshold("3A", "SubclavianArtery"), "AntTo", - false, 3, true, false); - m_Working_Support = - clitk::SliceBySliceRelativePosition(m_Working_Support, SubclavianArteryRight, 2, - GetFuzzyThreshold("3A", "SubclavianArtery"), "AntTo", - false, 3, true, false); - StopCurrentStep(m_Working_Support); - m_ListOfStations["3A"] = m_Working_Support; -} -//-------------------------------------------------------------------- - //-------------------------------------------------------------------- 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"); + StartNewStep("[Station 3A] Post limits in S5 support according to Aorta"); - // Trial in 3D -> difficulties superiorly. Stay slice by slice. - /* - typedef clitk::AddRelativePositionConstraintToLabelImageFilter RelPosFilterType; - typename RelPosFilterType::Pointer relPosFilter = RelPosFilterType::New(); - relPosFilter->VerboseStepFlagOff(); - relPosFilter->WriteStepFlagOff(); - relPosFilter->SetBackgroundValue(GetBackgroundValue()); - relPosFilter->SetInput(m_Working_Support); - relPosFilter->SetInputObject(SVC); - relPosFilter->AddOrientationTypeString("PostTo"); - relPosFilter->SetInverseOrientationFlag(true); - relPosFilter->SetIntermediateSpacing(4); - relPosFilter->SetIntermediateSpacingFlag(false); - relPosFilter->SetFuzzyThreshold(0.5); - // relPosFilter->AutoCropFlagOff(); // important ! because we join the slices after this loop - relPosFilter->Update(); - m_Working_Support = relPosFilter->GetOutput(); - */ - - // 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); - - // 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"); @@ -146,6 +67,13 @@ ExtractStation_3A_AntPost_S5() // Inferiorly, Aorta has two CCL that merge into a single one when // S6 appears. Loop on Aorta slices, select the most ant one, detect // the most ant point. + + + + // ====> TO BE CHANGED USING AscendingAorta and DescendingAorta + + + std::vector slices; clitk::ExtractSlices(Aorta, 2, slices); std::vector points; @@ -201,9 +129,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"); @@ -219,12 +147,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; @@ -239,30 +174,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 @@ -295,19 +206,22 @@ 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", "LeftSubclavianArtery"); + Remove_Structures(" 3A", "RightSubclavianArtery"); + Remove_Structures(" 3A", "Thyroid"); + Remove_Structures(" 3A", "LeftCommonCarotidArtery"); + Remove_Structures(" 3A", "RightCommonCarotidArtery"); + Remove_Structures(" 3A", "BrachioCephalicArtery"); + // Remove_Structures("3A", "Bones"); --> should be in extractmediastinum // Remove_Structures("3A", "BrachioCephalicVein"); ? StartNewStep("[Station 3A] Remove part of BrachioCephalicVein"); // resize like support, extract slices // while single CCL -> remove // when two remove only the most post + MaskImagePointer BrachioCephalicVein = + GetAFDB()->template GetImage ("BrachioCephalicVein"); BrachioCephalicVein = clitk::ResizeImageLike(BrachioCephalicVein, m_Working_Support, GetBackgroundValue()); @@ -318,27 +232,31 @@ ExtractStation_3A_Remove_Structures() for(uint i=0; i(slices_BCV[i], 0, true, 1); + // Compute centroids std::vector centroids; ComputeCentroids(slices_BCV[i], GetBackgroundValue(), centroids); - if (centroids.size() > 1) { + + // If several centroid, select the one most anterior + if (centroids.size() > 2) { // Only keep the one most post typename MaskSliceType::PixelType label; if (centroids[1][1] > centroids[2][1]) { - label = 1; - } - else { label = 2; } - - HERE - - slices_BCV[i] = clitk::SetBackground(slices_BCV[i], slices_BCV[i], - label, - GetBackgroundValue(), true); + else { + label = 1; + } + // "remove" the CCL + slices_BCV[i] = clitk::SetBackground(slices_BCV[i], + slices_BCV[i], + label, + GetBackgroundValue(), + true); } + // Remove from the support - slices[i] = clitk::AndNot(slices[i], slices_BCV[i], GetBackgroundValue()); + clitk::AndNot(slices[i], slices_BCV[i], GetBackgroundValue()); } // Joint @@ -348,3 +266,5 @@ ExtractStation_3A_Remove_Structures() m_ListOfStations["3A"] = m_Working_Support; } //-------------------------------------------------------------------- + +