diff --git a/Modules/IGT/IGTFilters/mitkNavigationDataEvaluationFilter.cpp b/Modules/IGT/IGTFilters/mitkNavigationDataEvaluationFilter.cpp index b49cc29ea5..e2385cc939 100644 --- a/Modules/IGT/IGTFilters/mitkNavigationDataEvaluationFilter.cpp +++ b/Modules/IGT/IGTFilters/mitkNavigationDataEvaluationFilter.cpp @@ -1,225 +1,226 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 16011 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkNavigationDataEvaluationFilter.h" #include mitk::NavigationDataEvaluationFilter::NavigationDataEvaluationFilter() : mitk::NavigationDataToNavigationDataFilter() { } mitk::NavigationDataEvaluationFilter::~NavigationDataEvaluationFilter() { } void mitk::NavigationDataEvaluationFilter::GenerateData() { this->CreateOutputsForAllInputs(); // make sure that we have the same number of outputs as inputs this->CreateMembersForAllInputs(); /* update outputs with tracking data from tools */ for (unsigned int i = 0; i < this->GetNumberOfOutputs() ; ++i) { //first copy outputs to inputs mitk::NavigationData* output = this->GetOutput(i); assert(output); const mitk::NavigationData* input = this->GetInput(i); assert(input); if (input->IsDataValid() == false) {output->SetDataValid(false);} else {output->Graft(input);} //then save statistics if(input->IsDataValid()) { m_LoggedPositions[i].push_back(input->GetPosition()); m_LoggedQuaternions[i].push_back(input->GetOrientation()); } else { m_InavildSamples[i]++; } } } void mitk::NavigationDataEvaluationFilter::CreateMembersForAllInputs() { while(this->m_LoggedPositions.size() < this->GetNumberOfInputs()) { std::pair > newElement(m_LoggedPositions.size(),std::vector()); m_LoggedPositions.insert(newElement); } while(this->m_LoggedQuaternions.size() < this->GetNumberOfInputs()) { std::pair > newElement(m_LoggedQuaternions.size(),std::vector()); m_LoggedQuaternions.insert(newElement); } while(this->m_InavildSamples.size() < this->GetNumberOfInputs()) { std::pair newElement(m_LoggedQuaternions.size(),0); m_InavildSamples.insert(newElement); } } void mitk::NavigationDataEvaluationFilter::ResetStatistic() { for (int i = 0; i < m_LoggedPositions.size(); i++) m_LoggedPositions[i] = std::vector(); for (int i = 0; i < m_LoggedQuaternions.size(); i++) m_LoggedQuaternions[i] = std::vector(); for (int i = 0; i < m_InavildSamples.size(); i++) m_InavildSamples[i] = 0; } int mitk::NavigationDataEvaluationFilter::GetNumberOfAnalysedNavigationData(int input) { return this->m_LoggedPositions[input].size(); } mitk::Point3D mitk::NavigationDataEvaluationFilter::GetPositionMean(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionMean(); } mitk::Vector3D mitk::NavigationDataEvaluationFilter::GetPositionStandardDeviation(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionStandardDeviation(); } mitk::Vector3D mitk::NavigationDataEvaluationFilter::GetPositionSampleStandardDeviation(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionSampleStandardDeviation(); } mitk::Quaternion mitk::NavigationDataEvaluationFilter::GetQuaternionMean(int input) { return GetMean(m_LoggedQuaternions[input]); } mitk::Quaternion mitk::NavigationDataEvaluationFilter::GetQuaternionStandardDeviation(int input) { mitk::Quaternion returnValue; std::vector list1 = std::vector(); std::vector list2 = std::vector(); std::vector list3 = std::vector(); std::vector list4 = std::vector(); for (int i=0; iGetStabw(list1); +returnValue[1] = myCalculator->GetStabw(list2); +returnValue[2] = myCalculator->GetStabw(list3); +returnValue[3] = myCalculator->GetStabw(list4); return returnValue; } double mitk::NavigationDataEvaluationFilter::GetPositionErrorMean(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionErrorMean(); } double mitk::NavigationDataEvaluationFilter::GetPositionErrorStandardDeviation(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionErrorStandardDeviation(); } double mitk::NavigationDataEvaluationFilter::GetPositionErrorSampleStandardDeviation(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionErrorSampleStandardDeviation(); } double mitk::NavigationDataEvaluationFilter::GetPositionErrorRMS(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionErrorRMS(); } double mitk::NavigationDataEvaluationFilter::GetPositionErrorMedian(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionErrorMedian(); } double mitk::NavigationDataEvaluationFilter::GetPositionErrorMax(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionErrorMax(); } double mitk::NavigationDataEvaluationFilter::GetPositionErrorMin(int input) { mitk::PointSetStatisticsCalculator::Pointer myCalculator = mitk::PointSetStatisticsCalculator::New(VectorToPointSet(m_LoggedPositions[input])); return myCalculator->GetPositionErrorMin(); } int mitk::NavigationDataEvaluationFilter::GetNumberOfInvalidSamples(int input) { return m_InavildSamples[input]; } double mitk::NavigationDataEvaluationFilter::GetPercentageOfInvalidSamples(int input) { return (m_InavildSamples[input]/(m_InavildSamples[input]+((double)m_LoggedPositions[input].size())))*100.0; } mitk::Quaternion mitk::NavigationDataEvaluationFilter::GetMean(std::vector list) { //calculate mean mitk::Quaternion mean; mean[0] = 0; mean[1] = 0; mean[2] = 0; mean[3] = 0; for (int i=0; i pSet) { mitk::PointSet::Pointer returnValue = mitk::PointSet::New(); for (int i=0; iInsertPoint(i,pSet.at(i)); return returnValue; } \ No newline at end of file diff --git a/Modules/ImageStatistics/mitkPointSetStatisticsCalculator.h b/Modules/ImageStatistics/mitkPointSetStatisticsCalculator.h index f1f53e5015..4cff5cedba 100644 --- a/Modules/ImageStatistics/mitkPointSetStatisticsCalculator.h +++ b/Modules/ImageStatistics/mitkPointSetStatisticsCalculator.h @@ -1,110 +1,116 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12 Mai 2009) $ Version: $Revision: 17179 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef _MITK_PointSetSTATISTICSCALCULATOR_H #define _MITK_PointSetSTATISTICSCALCULATOR_H #include #include "ImageStatisticsExports.h" #include namespace mitk { /** * \brief Class for calculating statistics (like standard derivation, RMS, mean, etc.) for a PointSet. */ class ImageStatistics_EXPORT PointSetStatisticsCalculator : public itk::Object { public: mitkClassMacro( PointSetStatisticsCalculator, itk::Object ); itkNewMacro( PointSetStatisticsCalculator ); mitkNewMacro1Param(PointSetStatisticsCalculator,mitk::PointSet::Pointer) /** @brief Sets the point set which will be analysed. */ void SetPointSet(mitk::PointSet::Pointer pSet); /** @return Returns the mean position of the analysed point set.*/ mitk::Point3D GetPositionMean(); /** @return Returns the standard derivation of each component (x, y and z) of the analysed point set.*/ mitk::Vector3D GetPositionStandardDeviation(); /** @return Returns the sample standard derivation of each component (x, y and z) of the analysed point set.*/ mitk::Vector3D GetPositionSampleStandardDeviation(); /** @return Returns the mean distance to the mean postion (=mean error) of the analysed point set. */ double GetPositionErrorMean(); /** @return Returns the standard derivation of the errors of all positions of the analysed point set. */ double GetPositionErrorStandardDeviation(); /** @return Returns the sample standard derivation of the errors of all positions of the analysed point set. */ double GetPositionErrorSampleStandardDeviation(); /** @return Returns the RMS of the errors of all positions of the analysed point set. */ double GetPositionErrorRMS(); /** @return Returns the median of the errors of all positions of the analysed point set. */ double GetPositionErrorMedian(); /** @return Returns the maximum of the errors of all positions of the analysed point set. */ double GetPositionErrorMax(); /** @return Returns the minimum of the errors of all positions of the analysed point set. */ double GetPositionErrorMin(); - + //##################################################################################################### + + //this both methods are used by another class an so they are public... perhaps we want to move them + //out of this class because they have nothing to do with point sets. + + /** @return returns the standard derivation of the given list (NOT of the point set).*/ + double GetStabw(std::vector list); + + /** @return returns the sample standard derivation of the given list (NOT of the point set).*/ + double GetSampleStabw(std::vector list); + + //##################################################################################################### protected: PointSetStatisticsCalculator(); PointSetStatisticsCalculator(mitk::PointSet::Pointer); virtual ~PointSetStatisticsCalculator(); /** @return Returns a list with the distances to the mean of the list */ std::vector GetErrorList(std::vector list); mitk::Point3D GetMean(std::vector list); /** @brief Converts a point set to a vector of Point3D. */ std::vector PointSetToVector(mitk::PointSet::Pointer pSet); mitk::PointSet::Pointer m_PointSet; double GetMean(std::vector list); double GetMedian(std::vector list); double GetMax(std::vector list); double GetMin(std::vector list); - - /** @return returns the standard derivation of the list */ - double GetStabw(std::vector list); - - /** @return returns the sample standard derivation of the list */ - double GetSampleStabw(std::vector list); + }; } #endif // #define _MITK_PointSetSTATISTICSCALCULATOR_H \ No newline at end of file