X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkImageStatisticsGenericFilter.txx;h=32b31bc1b4ebb0571b87be599f3e9ccc2b215221;hb=b133f36e1414bcf74518050a4a8e36d32d642981;hp=1995198234be2f07e4db47f3921dd9338e97482a;hpb=8b965f85c8e581f12fa9b24bc002aab2bfb7aa9b;p=clitk.git diff --git a/tools/clitkImageStatisticsGenericFilter.txx b/tools/clitkImageStatisticsGenericFilter.txx index 1995198..32b31bc 100644 --- a/tools/clitkImageStatisticsGenericFilter.txx +++ b/tools/clitkImageStatisticsGenericFilter.txx @@ -156,7 +156,7 @@ namespace clitk } else { - std::cerr << "Mask image has a different size/spacing than input. Abort" << std::endl; + std::cerr << "Mask image has a different size/spacing than input. Abort. (Use option to resize)" << std::endl; exit(-1); } } @@ -169,11 +169,21 @@ namespace clitk labelImage->SetRegions(input->GetLargestPossibleRegion()); labelImage->SetOrigin(input->GetOrigin()); labelImage->SetSpacing(input->GetSpacing()); + labelImage->SetDirection(input->GetDirection()); labelImage->Allocate(); labelImage->FillBuffer(m_ArgsInfo.label_arg[0]); } statisticsFilter->SetLabelInput(labelImage); + // Check/compute spacing + const typename LabelImageType::SpacingType& spacing = input->GetSpacing(); + double spacing_cc = (spacing[0]*spacing[1]*spacing[2])/1000; + // std::cout<<"Spacing x : " << spacing[0]<SetUseHistograms(true); statisticsFilter->SetHistogramParameters(m_ArgsInfo.bins_arg, m_ArgsInfo.lower_arg, m_ArgsInfo.upper_arg); } + + // DVH + if(m_ArgsInfo.dvhistogram_given) + { + statisticsFilter->SetUseHistograms(true); + statisticsFilter->SetHistogramParameters(m_ArgsInfo.bins_arg, m_ArgsInfo.lower_arg, m_ArgsInfo.upper_arg); + } + statisticsFilter->Update(); // Output - if (m_Verbose) std::cout<<"N° of pixels: "; - std::cout<GetCount(label)<GetCount(label)<GetMean(label)<GetMean(label)<GetSigma(label)<GetSigma(label)<GetVariance(label)<GetVariance(label)<GetMinimum(label)<GetMinimum(label)<GetMaximum(label)<GetMaximum(label)<GetSum(label)<GetSum(label)<GetBoundingBox(label).size(); i++) - std::cout<GetBoundingBox(label)[i]<<" "; + std::cout<GetBoundingBox(label)[i]<<" "; std::cout<GetBinMin(0,i)<<"\t"<GetMeasurement(i,0)<<"\t"<GetBinMax(0,i)<<"\t"<GetFrequency(i)<GetHistogram(label); + + // Screen + std::cout<<"# Total volume : "; + std::cout<GetCount(label)<<" [No. of voxels]"<GetCount(label))*spacing_cc)<<" [cc]"<GetMean(label)<<" [Gy]"<GetMinimum(label)<<" [Gy]"<GetMaximum(label)<<" [Gy]"<GetFrequency(j)); + } + double cumulativeVolume = popCumulativeVolume + (dvhistogram->GetFrequency(i)); + double percentCumulativeVolume =(cumulativeVolume*100)/(statisticsFilter->GetCount(label)) ; + double ccCumulativeVolume = (popCumulativeVolume + (dvhistogram->GetFrequency(i)))*spacing_cc; + double percentDiffVolume = dvhistogram->GetFrequency(i)*100/(statisticsFilter->GetCount(label)); + if(i == 0) + { + std::cout<GetBinMax(0,i)<<"\t "<GetFrequency(i)<<"\t "<GetFrequency(i))*spacing_cc)<<"\t "<GetBinMax(0,i)<<"\t "<GetFrequency(i)<<"\t "<GetFrequency(i))*spacing_cc)<<"\t "<GetBinMin(0,m_ArgsInfo.bins_arg-i)<<"\t "<GetCount(label)<<" [No. of voxels]"<GetCount(label))*spacing_cc)<<" [cc]"<GetMean(label)<<" [Gy]"<GetMinimum(label)<<" [Gy]"<GetMaximum(label)<<" [Gy]"<GetFrequency(j)); + } + double cumulativeVolume = popCumulativeVolume + (dvhistogram->GetFrequency(i)); + double percentCumulativeVolume =(cumulativeVolume*100)/(statisticsFilter->GetCount(label)) ; + double ccCumulativeVolume = (popCumulativeVolume + (dvhistogram->GetFrequency(i)))*spacing_cc; + double percentDiffVolume = ((dvhistogram->GetFrequency(i))*100)/(statisticsFilter->GetCount(label)); + if(i == 0) + { + dvhistogramFile<GetBinMax(0,i)<<"\t "<GetFrequency(i)<<"\t "<GetFrequency(i))*spacing_cc)<<"\t "<GetBinMax(0,i)<<"\t "<GetFrequency(i)<<"\t "<GetFrequency(i))*spacing_cc)<<"\t "<GetBinMin(0,m_ArgsInfo.bins_arg-i)<<"\t "<