diff --git a/Modules/ImageStatistics/mitkImageStatisticsContainer.h b/Modules/ImageStatistics/mitkImageStatisticsContainer.h index 579c1d0ed7..1f23b047e5 100644 --- a/Modules/ImageStatistics/mitkImageStatisticsContainer.h +++ b/Modules/ImageStatistics/mitkImageStatisticsContainer.h @@ -1,180 +1,179 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKIMAGESTATISTICSCONTAINER #define MITKIMAGESTATISTICSCONTAINER #include #include #include namespace mitk { /**Documentation @brief Container class for storing the computed image statistics. Stored statistics are: - N: number of voxels - Mean - MPP (Mean of positive pixels) - Median - Skewness - Kurtosis - Uniformity - UPP (Uniformity of positive pixels) - Std (Standard Deviation) - Min - Max - RMS (Root Mean Square) - Label (if applicable, the label (unsigned short) of the mask the statistics belong to) - Entropy - MinIndex (Index of Image where the Minimum is located) - MaxIndex (Index of Image where the Maximum is located) - Histogram of Pixel Values*/ class MITKIMAGESTATISTICS_EXPORT StatisticsContainer : public mitk::BaseData { public: mitkClassMacro(StatisticsContainer, mitk::BaseData) itkFactorylessNewMacro(Self) itkCloneMacro(Self) using HistogramType = itk::Statistics::Histogram; using RealType = double; using statisticsOrderedVectorType = std::vector < std::pair >; using LabelIndex = unsigned int; virtual void SetRequestedRegionToLargestPossibleRegion() override {}; virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override { return false; }; virtual bool VerifyRequestedRegion() override { return true; }; virtual void SetRequestedRegion(const itk::DataObject*) override {}; struct StatisticsObject { StatisticsObject() { this->Reset(); } long m_N; RealType m_Volume; RealType m_Mean, m_Min, m_Max, m_Std; RealType m_Skewness; RealType m_Kurtosis; RealType m_RMS; RealType m_MPP; vnl_vector m_MinIndex, m_MaxIndex; RealType m_Median; RealType m_Uniformity; RealType m_UPP; RealType m_Entropy; LabelIndex m_Label; HistogramType::Pointer m_Histogram; RealType GetVariance() const { return m_Std * m_Std; - }; + } statisticsOrderedVectorType GetStatisticsAsOrderedVector() { statisticsOrderedVectorType statisticsAsVector; statisticsAsVector.emplace_back(std::make_pair("Mean", std::to_string(m_Mean))); statisticsAsVector.emplace_back(std::make_pair("Median", std::to_string(m_Median))); statisticsAsVector.emplace_back(std::make_pair("StandardDeviation", std::to_string(m_Std))); statisticsAsVector.emplace_back(std::make_pair("RMS", std::to_string(m_RMS))); statisticsAsVector.emplace_back(std::make_pair("Max", std::to_string(m_Max))); statisticsAsVector.emplace_back(std::make_pair("MaxPosition", convertToString(m_MaxIndex))); statisticsAsVector.emplace_back(std::make_pair("Min", std::to_string(m_Min))); statisticsAsVector.emplace_back(std::make_pair("MinPosition", convertToString(m_MinIndex))); statisticsAsVector.emplace_back(std::make_pair("#Voxel", std::to_string(m_N))); statisticsAsVector.emplace_back(std::make_pair("Volume [mm^3]", std::to_string(m_Volume))); statisticsAsVector.emplace_back(std::make_pair("Skewness", std::to_string(m_Skewness))); statisticsAsVector.emplace_back(std::make_pair("Kurtosis", std::to_string(m_Kurtosis))); statisticsAsVector.emplace_back(std::make_pair("Uniformity", std::to_string(m_Uniformity))); statisticsAsVector.emplace_back(std::make_pair("Entropy", std::to_string(m_Entropy))); statisticsAsVector.emplace_back(std::make_pair("MPP", std::to_string(m_MPP))); statisticsAsVector.emplace_back(std::make_pair("UPP", std::to_string(m_UPP))); return statisticsAsVector; } std::string convertToString(const vnl_vector& index) { std::string result; for (const auto& aValue : index) { if (!result.empty()) { result += "/"; } result += std::to_string(aValue); } return result; } void Reset() { m_N = 0; m_Volume = nan(""); m_Mean = nan(""); m_Min = nan(""); m_Max = nan(""); m_Std = nan(""); m_Skewness = nan(""); m_Kurtosis = nan(""); m_RMS = nan(""); m_MPP = nan(""); m_Median = nan(""); m_Uniformity = nan(""); m_UPP = nan(""); m_Entropy = nan(""); m_MinIndex.set_size(0); m_MaxIndex.set_size(0); m_Label = 0; m_Histogram = HistogramType::New(); - }; + } }; typedef std::map TimeStepMapType; /**Documentation @brief Returns a std::vector& index) const; void SetTimeStepMap(TimeStepMapType map); TimeStepMapType m_TimeStepMap; }; } #endif // MITKIMAGESTATISTICSCONTAINER