diff --git a/Modules/IGT/IGTFilters/mitkNavigationDataEvaluationFilter.cpp b/Modules/IGT/IGTFilters/mitkNavigationDataEvaluationFilter.cpp index e633e36ca5..9ab77d141c 100644 --- a/Modules/IGT/IGTFilters/mitkNavigationDataEvaluationFilter.cpp +++ b/Modules/IGT/IGTFilters/mitkNavigationDataEvaluationFilter.cpp @@ -1,240 +1,313 @@ /*========================================================================= 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::Point3D returnValue; -returnValue.Fill(0); - -for (int i=0; i listX = std::vector(); +std::vector listY = std::vector(); +std::vector listZ = std::vector(); +for (int i=0; i list1 = std::vector(); +std::vector list2 = std::vector(); +std::vector list3 = std::vector(); +std::vector list4 = std::vector(); +for (int i=0; iGetPositionMean(input); +mitk::Point3D mean = GetMean(m_LoggedPositions[input]); for(int i=0; iGetPositionMean(input); +mitk::Point3D mean = GetMean(m_LoggedPositions[input]); for(int i=0; i list) { -double returnValue = 0.0; -//TODO -return returnValue; +std::sort(list.begin(), list.end()); +if (list.size() % 2 == 0.) //even + { + double element1 = list.at(list.size()/2); + double element2 = list.at(list.size()/2); + return ((element1+element2)/2.0); + } +else //odd + { + return list.at((list.size()+1)/2); + } } -int GetNumberOfInvalidSamples(int input) +std::vector mitk::NavigationDataEvaluationFilter::GetErrorList(std::vector list) { -int returnValue = 0; -//TODO -return returnValue; +std::vector errorList = std::vector(); +mitk::Point3D mean = GetMean(list); +for(int i=0; i list) { -double returnValue = 0.0; -//TODO +//calculate mean +mitk::Point3D mean; +mean.Fill(0); + +for (int i=0; i list) +{ +std::sort(list.begin(), list.end()); +return list.at(list.size()-1); +} + +double mitk::NavigationDataEvaluationFilter::GetMin(std::vector list) +{ +std::sort(list.begin(), list.end()); +return list.at(0); +} + +double mitk::NavigationDataEvaluationFilter::GetStabw(std::vector list) +{ +double returnValue = 0; +double mean = GetMean(list); +for(int i=0; i list) +{ +double mean = 0; +for(int i=0; i list) +{ +//calculate mean +mitk::Quaternion mean; +mean[0] = 0; +mean[1] = 0; +mean[2] = 0; +mean[3] = 0; + +for (int i=0; i #include #include namespace mitk { /**Documentation * \brief NavigationDataEvaluationFilter calculates statistical data (mean value, mean error, etc.) on the input navigation data. * Input navigation data are set 1:1 on output navigation data. * * \ingroup IGT */ class MitkIGT_EXPORT NavigationDataEvaluationFilter : public NavigationDataToNavigationDataFilter { public: mitkClassMacro(NavigationDataEvaluationFilter, NavigationDataToNavigationDataFilter); itkNewMacro(Self); /** @brief Resets all statistics and starts again. */ void ResetStatistic(); - /** @return returns the number of analysed navigation datas for the specified input. */ + /** @return Returns the number of analysed navigation datas for the specified input (without invalid samples). */ int GetNumberOfAnalysedNavigationData(int input); + /** @return Returns the number of invalid samples for the specified input. Invalid samples are ignored for the statistical calculation.*/ int GetNumberOfInvalidSamples(int input); + /** @return Returns the percentage of invalid samples in relation to all samples for the specified input.*/ double GetPercentageOfInvalidSamples(int input); - - + /** @return Returns the mean position of the specified input since the start of the statistic (last call of ResetStatistic()) */ mitk::Point3D GetPositionMean(int input); + /** @return Returns the standard derivation of each component (x, y and z) of the specified input since the start of the statistic (last call of ResetStatistic()) */ mitk::Vector3D GetPositionStandardDerivation(int input); + /** @return Returns the mean quaternion of the specified input since the start of the statistic (last call of ResetStatistic()) */ mitk::Quaternion GetQuaternionMean(int input); + /** @return Returns the standard derivation of each component of the specified input since the start of the statistic (last call of ResetStatistic()) */ mitk::Quaternion GetQuaternionStandardDerivation(int input); - /** @return Returns the mean distance to the mean postion. */ + /** @return Returns the mean distance to the mean postion (=mean error) to the specified input. */ double GetPositionErrorMean(int input); + /** @return Returns the standard derivation of the errors of all positions to the specified input. */ double GetPositionErrorStandardDerication(int input); + /** @return Returns the RMS of the errors of all positions to the specified input. */ double GetPositionErrorRMS(int input); + /** @return Returns the median of the errors of all positions to the specified input. */ double GetPositionErrorMedian(int input); - - double GetQuaternionErrorMean(int input); - double GetQuaternionErrorStandardDerication(int input); - double GetQuaternionErrorRMS(int input); - double GetQuaternionErrorMedian(int input); - - - + /** @return Returns the maximum of the errors of all positions to the specified input. */ + double GetPositionErrorMax(int input); + /** @return Returns the minimum of the errors of all positions to the specified input. */ + double GetPositionErrorMin(int input); + protected: NavigationDataEvaluationFilter(); virtual ~NavigationDataEvaluationFilter(); /**Documentation * \brief filter execute method * * transforms navigation data */ virtual void GenerateData(); /** @brief Creates the member variables which store all the statistical data for every input. */ void CreateMembersForAllInputs(); std::map> m_LoggedPositions; //a map here, to have one list for every navigation data std::map> m_LoggedQuaternions; std::map m_InavildSamples; + + + /** @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); + + mitk::Quaternion GetMean(std::vector list); + + + 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); }; } // namespace mitk #endif /* MITKNavigationDataEvaluationFilter_H_HEADER_INCLUDED_ */ \ No newline at end of file