X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkExtractLymphStationsFilter.txx;h=ea514a6d643924af6834d3c3a921b82b98411d05;hb=7d7668046785090bc4ded5d15da5f94586af8a4d;hp=7b2fd2ff91346aa16e10e96de0844af056ff999a;hpb=5e2af376544fce0c6dc46bb3c3227d35b501c1f1;p=clitk.git diff --git a/segmentation/clitkExtractLymphStationsFilter.txx b/segmentation/clitkExtractLymphStationsFilter.txx index 7b2fd2f..ea514a6 100644 --- a/segmentation/clitkExtractLymphStationsFilter.txx +++ b/segmentation/clitkExtractLymphStationsFilter.txx @@ -52,6 +52,15 @@ ExtractLymphStationsFilter(): SetBackgroundValue(0); SetForegroundValue(1); + // Station 8 + SetDistanceMaxToAnteriorPartOfTheSpine(10); + MaskImagePointType p; + p[0] = 15; p[1] = 2; p[2] = 1; + SetEsophagusDiltationForAnt(p); + p[0] = 5; p[1] = 10; p[2] = 1; + SetEsophagusDiltationForRight(p); + SetFuzzyThresholdForS8(0.5); + // Station 7 SetFuzzyThreshold(0.5); SetStation7Filename("station7.mhd"); @@ -59,17 +68,6 @@ ExtractLymphStationsFilter(): //-------------------------------------------------------------------- -//-------------------------------------------------------------------- -template -template -void -clitk::ExtractLymphStationsFilter:: -SetArgsInfo(ArgsInfoType & argsinfo) { - DD("SetArgsInfo"); -} -//-------------------------------------------------------------------- - - //-------------------------------------------------------------------- template void @@ -78,28 +76,49 @@ GenerateOutputInformation() { // Get inputs LoadAFDB(); m_Input = dynamic_cast(itk::ProcessObject::GetInput(0)); - m_Support = GetAFDB()->template GetImage ("mediastinum"); - - // - typedef clitk::BooleanOperatorLabelImageFilter BFilter; - BFilter::Pointer merge = BFilter::New(); + m_Mediastinum = GetAFDB()->template GetImage ("Mediastinum"); + + // Extract Station8 + StartNewStep("Station 8"); + StartSubStep(); + ExtractStation_8(); + StopSubStep(); + + // Compute some interesting points in trachea + // ( ALTERNATIVE -> SKELETON ANALYSIS ? + // Pb : not sufficient for mostXX points ... ) + + /* ==> todo (but why ???) + ComputeTracheaCentroidsAboveCarina(); + ComputeBronchusExtremaPointsBelowCarina(); + */ - // Extract Station7 - ExtractStation_7(); - m_Output = m_Station7; + if (0) { // temporary suppress + // Extract Station7 + StartNewStep("Station 7"); + StartSubStep(); + ExtractStation_7(); + StopSubStep(); - // Extract Station4RL - ExtractStation_4RL(); + // Extract Station4RL + StartNewStep("Station 4RL"); + StartSubStep(); + //ExtractStation_4RL(); + StopSubStep(); + } - writeImage(m_Station4RL, "s4rl.mhd"); + + // + // typedef clitk::BooleanOperatorLabelImageFilter BFilter; + //BFilter::Pointer merge = BFilter::New(); // writeImage(m_Output, "ouput.mhd"); //writeImage(m_Working_Support, "ws.mhd"); /*merge->SetInput1(m_Station7); - merge->SetInput2(m_Station4RL); // support - merge->SetOperationType(BFilter::AndNot); CHANGE OPERATOR - merge->SetForegroundValue(4); - merge->Update(); - m_Output = merge->GetOutput(); + merge->SetInput2(m_Station4RL); // support + merge->SetOperationType(BFilter::AndNot); CHANGE OPERATOR + merge->SetForegroundValue(4); + merge->Update(); + m_Output = merge->GetOutput(); */ } //-------------------------------------------------------------------- @@ -123,17 +142,42 @@ GenerateData() { DD("GenerateData, graft output"); // Final Step -> graft output (if SetNthOutput => redo) - this->GraftOutput(m_Output); + this->GraftOutput(m_ListOfStations["8"]); } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +void +clitk::ExtractLymphStationsFilter:: +ExtractStation_8() { + + // Check if m_ListOfStations["8"] exist. If yes -> use it as initial + // support instead of m_Mediastinum + if (m_ListOfStations["8"]) { + DD("Station 8 support already exist -> use it"); + m_Working_Support = m_ListOfStations["8"]; + } + else m_Working_Support = m_Mediastinum; + + ExtractStation_8_SI_Limits(); + ExtractStation_8_AP_Limits(); + // ExtractStation_8_LR_Limits(); +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- template void clitk::ExtractLymphStationsFilter:: ExtractStation_7() { - DD("ExtractStation_7"); + if (m_ListOfStations["7"]) { + DD("Station 7 support already exist -> use it"); + m_Working_Support = m_ListOfStations["7"]; + } + else m_Working_Support = m_Mediastinum; ExtractStation_7_SI_Limits(); ExtractStation_7_RL_Limits(); ExtractStation_7_Posterior_Limits(); @@ -146,19 +190,83 @@ template void clitk::ExtractLymphStationsFilter:: ExtractStation_4RL() { - DD("ExtractStation_4RL"); - writeImage(m_Support, "essai.mhd"); // OK - /* WARNING ONLY 4R FIRST !!! (not same inf limits) - */ - + */ ExtractStation_4RL_SI_Limits(); ExtractStation_4RL_LR_Limits(); - + ExtractStation_4RL_AP_Limits(); } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +void +clitk::ExtractLymphStationsFilter:: +FindExtremaPointsInBronchus(MaskImagePointer input, + int direction, + double distance_max_from_center_point, + ListOfPointsType & LR, + ListOfPointsType & Ant, + ListOfPointsType & Post) +{ + + // Other solution ==> with auto bounding box ! (but pb to prevent to + // be too distant from the center point + + // Extract slices + std::vector slices; + clitk::ExtractSlices(input, 2, slices); + + // Loop on slices + bool found; + for(uint i=0; i(slices[i], 0, true, 10); + slices[i] = KeepLabels(slices[i], + GetBackgroundValue(), + GetForegroundValue(), 1, 1, true); + */ + + // ------- Find rightmost or leftmost point ------- + MaskSliceType::PointType LRMost; + found = + clitk::FindExtremaPointInAGivenDirection(slices[i], + GetBackgroundValue(), + 0, // axis XY + (direction==0?false:true), // right or left according to direction + LRMost); + // ------- Find postmost point ------- + MaskSliceType::PointType postMost; + found = + clitk::FindExtremaPointInAGivenDirection(slices[i], + GetBackgroundValue(), + 1, false, LRMost, + distance_max_from_center_point, + postMost); + // ------- Find antmost point ------- + MaskSliceType::PointType antMost; + found = + clitk::FindExtremaPointInAGivenDirection(slices[i], + GetBackgroundValue(), + 1, true, LRMost, + distance_max_from_center_point, + antMost); + // Only add point if found + if (found) { + // ------- Convert 2D to 3D points -------- + MaskImageType::PointType p; + clitk::PointsUtils::Convert2DTo3D(LRMost, input, i, p); + LR.push_back(p); + clitk::PointsUtils::Convert2DTo3D(antMost, input, i, p); + Ant.push_back(p); + clitk::PointsUtils::Convert2DTo3D(postMost, input, i, p); + Post.push_back(p); + } + } +} +//-------------------------------------------------------------------- #endif //#define CLITKBOOLEANOPERATORLABELIMAGEFILTER_TXX