/*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv Authors belong to: - University of LYON http://www.universite-lyon.fr/ - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the copyright notices for more information. It is distributed under dual licence - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html ======================================================================-====*/ #ifndef clitkCalculateTREGenericFilter_txx #define clitkCalculateTREGenericFilter_txx /* ================================================= * @file clitkCalculateTREGenericFilter.txx * @author * @date * * @brief * ===================================================*/ namespace clitk { //----------------------------- // Read DVF //----------------------------- template void CalculateTREGenericFilter::ReadVectorFields(void) { typedef itk::Vector VectorType; typedef itk::Image DeformationFieldType; typedef itk::ImageFileReader InputReaderType; std::vector dvfs; for (unsigned int i=0; i< m_ArgsInfo.vf_given; i++) { typename InputReaderType::Pointer reader = InputReaderType::New(); reader->SetFileName( m_ArgsInfo.vf_arg[i]); if (m_Verbose) std::cout<<"Reading vector field "<< i <<"..."<Update(); dvfs.push_back( reader->GetOutput() ); } ProcessVectorFields(dvfs, m_ArgsInfo.vf_arg); } //----------------------------- // Process DVF //----------------------------- template void CalculateTREGenericFilter::ProcessVectorFields(std::vector, Dimension>::Pointer > dvfs, char** filenames ) { std::vector new_filenames; for (unsigned int i=0;i(dvfs, new_filenames); } //------------------------------------------------------------------- // Update with the number of dimensions //------------------------------------------------------------------- template void CalculateTREGenericFilter::UpdateWithDim(std::vector, Dimension>::Pointer > dvfs, std::vector filenames) { if (m_Verbose) std::cout << "Image was detected to be "< MeasureListType; typedef itk::Point PointType; typedef clitk::List PointListType; typedef clitk::Lists PointListsType; typedef itk::Vector VectorType; typedef clitk::List VectorListType; typedef clitk::Lists VectorListsType; typedef itk::Vector DeformationVectorType; typedef itk::Image DeformationFieldType; //----------------------------- // Number of inputs //----------------------------- unsigned int numberOfFields=filenames.size(); unsigned int numberOfLists=m_ArgsInfo.input_given; if ( (numberOfLists!=numberOfFields) && (numberOfLists!=1) ) { std::cerr<<"Error: Number of lists (="< GenericVectorInterpolatorType; typename GenericVectorInterpolatorType::Pointer genericInterpolator=GenericVectorInterpolatorType::New(); genericInterpolator->SetArgsInfo(m_ArgsInfo); typedef itk::VectorInterpolateImageFunction InterpolatorType; typename InterpolatorType::Pointer interpolator=genericInterpolator->GetInterpolatorPointer(); //===================================================================================== // Original distance between points //===================================================================================== VectorListsType originalDistanceLists(numberOfFields); //----------------------------- // Calculate original distances //----------------------------- PointType referencePoint; VectorType distance; for (unsigned int phaseIndex=0; phaseIndex StatisticsFilterType; typename StatisticsFilterType::Pointer statisticsFilter=StatisticsFilterType::New(); // Statistics (magnitude) MeasureListType oMeanList, oStdList, oMaxList; ValueType oMean, oStd, oMax; statisticsFilter->GetStatistics(originalDistanceLists, oMean, oStd, oMax, oMeanList, oStdList, oMaxList); // Statistics (per component) VectorListType oMeanXYZList, oStdXYZList,oMaxXYZList; VectorType oMeanXYZ, oStdXYZ, oMaxXYZ; statisticsFilter->GetStatistics(originalDistanceLists, oMeanXYZ, oStdXYZ, oMaxXYZ, oMeanXYZList, oStdXYZList, oMaxXYZList); //----------------------------- // Output //----------------------------- std::vector labels; labels.push_back("MeanX\tSDX"); labels.push_back("MeanY\tSDY"); labels.push_back("MeanZ\tSDZ"); labels.push_back("MeanT\tSDT"); labels.push_back("MaxX"); labels.push_back("MaxY"); labels.push_back("MaxZ"); labels.push_back("MaxT"); // Output to screen if(m_Verbose) { // Numbers of DVF std::cout<<"# Number\tDVF"<SetInputImage( dvfs[phaseIndex]); for (unsigned int pointIndex=0; pointIndexIsInsideBuffer(referencePoint) ) displacement=interpolator->Evaluate(referencePoint); else displacement.Fill(0.0); // Warp warpedPoint=referencePoint+displacement; displacementLists[phaseIndex].push_back(displacement); warpedPointLists[phaseIndex].push_back(warpedPoint); tre=pointLists[phaseIndex][pointIndex]-warpedPoint; treLists[phaseIndex].push_back(tre); } } //----------------------------- // Statistics displacements //----------------------------- // Statistics (magnitude) MeasureListType dmeanList, dstdList, dmaxList; ValueType dmean, dstd, dmax; statisticsFilter->GetStatistics(displacementLists, dmean, dstd, dmax, dmeanList, dstdList, dmaxList); // Statistics (per component) VectorListType dmeanXYZList, dstdXYZList,dmaxXYZList; VectorType dmeanXYZ, dstdXYZ, dmaxXYZ; statisticsFilter->GetStatistics(displacementLists, dmeanXYZ, dstdXYZ, dmaxXYZ,dmeanXYZList, dstdXYZList, dmaxXYZList); //----------------------------- // Statistics TRE //----------------------------- // Statistics (magnitude) MeasureListType meanList, stdList, maxList; ValueType mean, std, max; statisticsFilter->GetStatistics(treLists, mean, std, max, meanList, stdList, maxList); // Statistics (per component) VectorListType meanXYZList, stdXYZList,maxXYZList; VectorType meanXYZ, stdXYZ, maxXYZ; statisticsFilter->GetStatistics(treLists, meanXYZ, stdXYZ, maxXYZ, meanXYZList, stdXYZList, maxXYZList); // Output to screen if(m_Verbose) { std::cout< filenames; for (unsigned int i=0;i > originalDistanceListsMag=originalDistanceLists.Norm(); std::vector filenames; for (unsigned int i=0;i filenames; for (unsigned int i=0;i > displacementListsMag=displacementLists.Norm(); std::vector filenames; for (unsigned int i=0;i filenames; for (unsigned int i=0;i filenames; for (unsigned int i=0;i > treMagLists=treLists.Norm(); std::vector filenames; for (unsigned int i=0;i