X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkExtractLymphStation_Supports.txx;h=2cde97dd98b7465ae1addea1e6bcfc11965a4281;hb=15e781be4b87a75be8fe01e56da5eb4435c97786;hp=ad2e95792efec4095f1a999fbc86d9291c8aead2;hpb=32539f6a33f6a97a8493a1fa11360d09be843a4c;p=clitk.git diff --git a/segmentation/clitkExtractLymphStation_Supports.txx b/segmentation/clitkExtractLymphStation_Supports.txx index ad2e957..2cde97d 100644 --- a/segmentation/clitkExtractLymphStation_Supports.txx +++ b/segmentation/clitkExtractLymphStation_Supports.txx @@ -8,8 +8,6 @@ void clitk::ExtractLymphStationsFilter:: ExtractStationSupports() { - DD("ExtractStationSupports"); - // Get initial Mediastinum m_Working_Support = m_Mediastinum = this->GetAFDB()->template GetImage("Mediastinum", true); @@ -23,10 +21,10 @@ ExtractStationSupports() m_CarinaZ, true, GetBackgroundValue()); m_ListOfSupports["Support_Superior_to_Carina"] = m_Support_Superior_to_Carina; m_ListOfSupports["Support_Inferior_to_Carina"] = m_Support_Inferior_to_Carina; - writeImage(m_Support_Inferior_to_Carina, "seg/Support_Inf_Carina.mhd"); - this->GetAFDB()->SetImageFilename("Support_Inf_Carina", "seg/Support_Inf_Carina.mhd"); - writeImage(m_Support_Superior_to_Carina, "seg/Support_Sup_Carina.mhd"); - this->GetAFDB()->SetImageFilename("Support_Sup_Carina", "seg/Support_Sup_Carina.mhd"); + writeImage(m_Support_Inferior_to_Carina, "seg/Support_Inf_Carina.mha"); + this->GetAFDB()->SetImageFilename("Support_Inf_Carina", "seg/Support_Inf_Carina.mha"); + writeImage(m_Support_Superior_to_Carina, "seg/Support_Sup_Carina.mha"); + this->GetAFDB()->SetImageFilename("Support_Sup_Carina", "seg/Support_Sup_Carina.mha"); // S1RL Support_SupInf_S1RL(); @@ -59,45 +57,45 @@ ExtractStationSupports() m_ListOfSupports["S11"] = clitk::Clone(m_Support_Inferior_to_Carina); // Store image filenames into AFDB - writeImage(m_ListOfSupports["S1R"], "seg/Support_S1R.mhd"); - this->GetAFDB()->SetImageFilename("Support_S1R", "seg/Support_S1R.mhd"); - writeImage(m_ListOfSupports["S1L"], "seg/Support_S1L.mhd"); - this->GetAFDB()->SetImageFilename("Support_S1L", "seg/Support_S1L.mhd"); + writeImage(m_ListOfSupports["S1R"], "seg/Support_S1R.mha"); + this->GetAFDB()->SetImageFilename("Support_S1R", "seg/Support_S1R.mha"); + writeImage(m_ListOfSupports["S1L"], "seg/Support_S1L.mha"); + this->GetAFDB()->SetImageFilename("Support_S1L", "seg/Support_S1L.mha"); - writeImage(m_ListOfSupports["S2L"], "seg/Support_S2L.mhd"); - this->GetAFDB()->SetImageFilename("Support_S2L", "seg/Support_S2L.mhd"); - writeImage(m_ListOfSupports["S2R"], "seg/Support_S2R.mhd"); - this->GetAFDB()->SetImageFilename("Support_S2R", "seg/Support_S2R.mhd"); + writeImage(m_ListOfSupports["S2L"], "seg/Support_S2L.mha"); + this->GetAFDB()->SetImageFilename("Support_S2L", "seg/Support_S2L.mha"); + writeImage(m_ListOfSupports["S2R"], "seg/Support_S2R.mha"); + this->GetAFDB()->SetImageFilename("Support_S2R", "seg/Support_S2R.mha"); - writeImage(m_ListOfSupports["S3P"], "seg/Support_S3P.mhd"); - this->GetAFDB()->SetImageFilename("Support_S3P", "seg/Support_S3P.mhd"); - writeImage(m_ListOfSupports["S3A"], "seg/Support_S3A.mhd"); - this->GetAFDB()->SetImageFilename("Support_S3A", "seg/Support_S3A.mhd"); + writeImage(m_ListOfSupports["S3P"], "seg/Support_S3P.mha"); + this->GetAFDB()->SetImageFilename("Support_S3P", "seg/Support_S3P.mha"); + writeImage(m_ListOfSupports["S3A"], "seg/Support_S3A.mha"); + this->GetAFDB()->SetImageFilename("Support_S3A", "seg/Support_S3A.mha"); - writeImage(m_ListOfSupports["S4L"], "seg/Support_S4L.mhd"); - this->GetAFDB()->SetImageFilename("Support_S4L", "seg/Support_S4L.mhd"); - writeImage(m_ListOfSupports["S4R"], "seg/Support_S4R.mhd"); - this->GetAFDB()->SetImageFilename("Support_S4R", "seg/Support_S4R.mhd"); + writeImage(m_ListOfSupports["S4L"], "seg/Support_S4L.mha"); + this->GetAFDB()->SetImageFilename("Support_S4L", "seg/Support_S4L.mha"); + writeImage(m_ListOfSupports["S4R"], "seg/Support_S4R.mha"); + this->GetAFDB()->SetImageFilename("Support_S4R", "seg/Support_S4R.mha"); - writeImage(m_ListOfSupports["S5"], "seg/Support_S5.mhd"); - this->GetAFDB()->SetImageFilename("Support_S5", "seg/Support_S5.mhd"); - writeImage(m_ListOfSupports["S6"], "seg/Support_S6.mhd"); - this->GetAFDB()->SetImageFilename("Support_S6", "seg/Support_S6.mhd"); + writeImage(m_ListOfSupports["S5"], "seg/Support_S5.mha"); + this->GetAFDB()->SetImageFilename("Support_S5", "seg/Support_S5.mha"); + writeImage(m_ListOfSupports["S6"], "seg/Support_S6.mha"); + this->GetAFDB()->SetImageFilename("Support_S6", "seg/Support_S6.mha"); - writeImage(m_ListOfSupports["S7"], "seg/Support_S7.mhd"); - this->GetAFDB()->SetImageFilename("Support_S7", "seg/Support_S7.mhd"); + writeImage(m_ListOfSupports["S7"], "seg/Support_S7.mha"); + this->GetAFDB()->SetImageFilename("Support_S7", "seg/Support_S7.mha"); - writeImage(m_ListOfSupports["S8"], "seg/Support_S8.mhd"); - this->GetAFDB()->SetImageFilename("Support_S8", "seg/Support_S8.mhd"); + writeImage(m_ListOfSupports["S8"], "seg/Support_S8.mha"); + this->GetAFDB()->SetImageFilename("Support_S8", "seg/Support_S8.mha"); - writeImage(m_ListOfSupports["S9"], "seg/Support_S9.mhd"); - this->GetAFDB()->SetImageFilename("Support_S9", "seg/Support_S9.mhd"); + writeImage(m_ListOfSupports["S9"], "seg/Support_S9.mha"); + this->GetAFDB()->SetImageFilename("Support_S9", "seg/Support_S9.mha"); - writeImage(m_ListOfSupports["S10"], "seg/Support_S10.mhd"); - this->GetAFDB()->SetImageFilename("Support_S10", "seg/Support_S10.mhd"); + writeImage(m_ListOfSupports["S10"], "seg/Support_S10.mha"); + this->GetAFDB()->SetImageFilename("Support_S10", "seg/Support_S10.mha"); - writeImage(m_ListOfSupports["S11"], "seg/Support_S11.mhd"); - this->GetAFDB()->SetImageFilename("Support_S11", "seg/Support_S11.mhd"); + writeImage(m_ListOfSupports["S11"], "seg/Support_S11.mha"); + this->GetAFDB()->SetImageFilename("Support_S11", "seg/Support_S11.mha"); WriteAFDB(); } //-------------------------------------------------------------------- @@ -204,8 +202,10 @@ Support_SupInf_S2R_S2L() MaskImagePointer BrachioCephalicVein = this->GetAFDB()->template GetImage("BrachioCephalicVein"); MaskImagePointType p; clitk::FindExtremaPointInAGivenDirection(BrachioCephalicVein, GetBackgroundValue(), 2, true, p); - // I add slightly more than a slice - double CaudalMarginOfLeftBrachiocephalicVeinZ=p[2]+ 1.1*m_Working_Support->GetSpacing()[2]; + + // I add slightly more than a slice --> NO !! + double CaudalMarginOfLeftBrachiocephalicVeinZ=p[2];//+ 1.1*m_Working_Support->GetSpacing()[2]; + this->GetAFDB()->SetDouble("CaudalMarginOfLeftBrachiocephalicVeinZ", CaudalMarginOfLeftBrachiocephalicVeinZ); MaskImagePointer S2R = clitk::CropImageRemoveLowerThan(m_Working_Support, 2, @@ -266,7 +266,6 @@ Support_SupInf_S2R_S2L() - //-------------------------------------------------------------------- template void @@ -313,24 +312,32 @@ Support_SupInf_S4R_S4L() */ StartNewStep("[Support] Sup-Inf limits of 4R/4L"); - // Start from the support, remove 2R and 2L + // Start from the support MaskImagePointer S4RL = clitk::Clone(m_Working_Support); + MaskImagePointer S4R = clitk::Clone(S4RL); + MaskImagePointer S4L = clitk::Clone(S4RL); + + // Keep only what is lower than S2 MaskImagePointer S2R = m_ListOfSupports["S2R"]; MaskImagePointer S2L = m_ListOfSupports["S2L"]; - clitk::AndNot(S4RL, S2R, GetBackgroundValue()); - clitk::AndNot(S4RL, S2L, GetBackgroundValue()); - S4RL = clitk::AutoCrop(S4RL, GetBackgroundValue()); + MaskImagePointType p; + // Right part + clitk::FindExtremaPointInAGivenDirection(S2R, GetBackgroundValue(), + 2, true, p); + S4R = clitk::CropImageRemoveGreaterThan(S4R, 2, + p[2], true, GetBackgroundValue()); + // Left part + clitk::FindExtremaPointInAGivenDirection(S2L, GetBackgroundValue(), + 2, true, p); + S4L = clitk::CropImageRemoveGreaterThan(S4L, 2, + p[2], true, GetBackgroundValue()); - // Copy, stop 4R at AzygousVein and 4L at LeftPulmonaryArtery - MaskImagePointer S4R = clitk::Clone(S4RL); - MaskImagePointer S4L = clitk::Clone(S4RL); - // Get AzygousVein and limit according to LowerBorderAzygousVein MaskImagePointer LowerBorderAzygousVein = this->GetAFDB()->template GetImage("LowerBorderAzygousVein"); std::vector c; clitk::ComputeCentroids(LowerBorderAzygousVein, GetBackgroundValue(), c); - S4R = clitk::CropImageRemoveLowerThan(S4RL, 2, + S4R = clitk::CropImageRemoveLowerThan(S4R, 2, c[1][2], true, GetBackgroundValue()); S4R = clitk::AutoCrop(S4R, GetBackgroundValue()); m_ListOfSupports["S4R"] = S4R; @@ -339,10 +346,9 @@ Support_SupInf_S4R_S4L() // Limit according to LeftPulmonaryArtery MaskImagePointer LeftPulmonaryArtery = this->GetAFDB()->template GetImage("LeftPulmonaryArtery"); - MaskImagePointType p; clitk::FindExtremaPointInAGivenDirection(LeftPulmonaryArtery, GetBackgroundValue(), 2, false, p); - S4L = clitk::CropImageRemoveLowerThan(S4RL, 2, + S4L = clitk::CropImageRemoveLowerThan(S4L, 2, p[2], true, GetBackgroundValue()); S4L = clitk::AutoCrop(S4L, GetBackgroundValue()); m_ListOfSupports["S4L"] = S4L; @@ -423,7 +429,7 @@ LimitsWithTrachea(MaskImageType * input, int extremaDirection, int lineDirection GetBackgroundValue(), 2, extremaDirection, false, // Left lineDirection, // Vertical line - 1, // margins + -1, // margins tracheaLeftPositionsA, tracheaLeftPositionsB); // Do not consider trachea above the limit @@ -519,7 +525,7 @@ Support_S3A() MaskImagePointType p; p[0] = p[1] = p[2] = 0.0; // to avoid warning clitk::FindExtremaPointInAGivenDirection(Sternum, GetBackgroundValue(), 2, false, p); - + p[2] += Sternum->GetSpacing()[2]; // we add one slice to stop 3A at the same slice than Sternum stop S3A = clitk::CropImageRemoveGreaterThan(S3A, 2, //m_ApexOfTheChest @@ -538,20 +544,22 @@ void clitk::ExtractLymphStationsFilter:: Support_S5() { - StartNewStep("[Support] Sup-Inf limits S5 with aorta"); + StartNewStep("[Support] Sup-Inf limits S5 with Aorta and MainPulmonaryArtery"); // Initial S5 support - MaskImagePointer S5 = clitk::Clone(this->GetAFDB()->template GetImage("Mediastinum", true)); + MaskImagePointer S5 = + clitk::Clone(this->GetAFDB()->template GetImage("Mediastinum", true)); // Sup limits with Aorta double sup = FindInferiorBorderOfAorticArch(); // Inf limits with "upper rim of the left main pulmonary artery" // For the moment only, it will change. - MaskImagePointer PulmonaryTrunk = this->GetAFDB()->template GetImage("PulmonaryTrunk"); + MaskImagePointer MainPulmonaryArtery = this->GetAFDB()->template GetImage("MainPulmonaryArtery"); MaskImagePointType p; p[0] = p[1] = p[2] = 0.0; // to avoid warning - clitk::FindExtremaPointInAGivenDirection(PulmonaryTrunk, GetBackgroundValue(), 2, false, p); + clitk::FindExtremaPointInAGivenDirection(MainPulmonaryArtery, GetBackgroundValue(), 2, false, p); + p[2] += MainPulmonaryArtery->GetSpacing()[2]; // Cut Sup/Inf S5 = clitk::CropImageAlongOneAxis(S5, 2, p[2], sup, true, GetBackgroundValue());