diff --git a/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp b/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp index 04137b1574..22679f3e6f 100644 --- a/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp +++ b/Modules/ImageStatistics/mitkImageStatisticsContainer.cpp @@ -1,126 +1,126 @@ /*=================================================================== 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. ===================================================================*/ #include namespace mitk { StatisticsContainer::StatisticsContainer() { this->Reset(); } bool StatisticsContainer::TimeStepExists(TimeStepType timeStep) const { return m_TimeStepMap.find(timeStep) != m_TimeStepMap.end(); } StatisticsContainer::StatisticsObject StatisticsContainer::GetStatisticsForTimeStep(TimeStepType timeStep) const { auto it = m_TimeStepMap.find(timeStep); if (it != m_TimeStepMap.end()) { return it->second; } mitkThrow() << "StatisticsObject for timeStep " << timeStep << " not found!"; } void StatisticsContainer::SetStatisticsForTimeStep(TimeStepType timeStep, StatisticsObject statistics) { if (timeStep < this->GetTimeSteps()) { m_TimeStepMap[timeStep] = statistics; } else { mitkThrow() << "Given timeStep " << timeStep << " out of timeStep geometry bounds. TimeSteps in geometry: " << this->GetTimeSteps(); } } void StatisticsContainer::PrintSelf(std::ostream &os, itk::Indent indent) const { Superclass::PrintSelf(os, indent); for (unsigned int i = 0; i < this->GetTimeSteps(); i++) { auto statistics = GetStatisticsAsOrderedVector(i); os << std::endl << indent << "Statistics instance for timeStep " << i << ":"; for (const auto& aStatisticValue : statistics) { os << std::endl << indent.GetNextIndent() << aStatisticValue.first << ": " << aStatisticValue.second; } } } StatisticsContainer::statisticsOrderedVectorType StatisticsContainer::GetStatisticsAsOrderedVector(TimeStepType timeStep) const { return GetStatisticsForTimeStep(timeStep).GetStatisticsAsOrderedVector(); } unsigned int StatisticsContainer::GetNumberOfTimeSteps()const { return this->GetTimeSteps(); } void StatisticsContainer::Reset() { for (auto iter = m_TimeStepMap.begin(); iter != m_TimeStepMap.end(); iter++) { iter->second.Reset(); } } itk::LightObject::Pointer StatisticsContainer::InternalClone() const { itk::LightObject::Pointer ioPtr = Superclass::InternalClone(); Self::Pointer rval = dynamic_cast(ioPtr.GetPointer()); if (rval.IsNull()) { itkExceptionMacro(<< "downcast to type " << "StatisticsContainer" << " failed."); } - // hopefully this is a deep copy (more sure than before) rval->SetTimeStepMap(m_TimeStepMap); + rval->SetTimeGeometry(this->GetTimeGeometry()->Clone()); + return ioPtr; } void StatisticsContainer::SetTimeStepMap(TimeStepMapType map) { m_TimeStepMap = map; } void StatisticsContainer::Print() { - for (unsigned int i = 0; i < this->GetTimeSteps(); i++) { auto statistics = this->GetStatisticsAsOrderedVector(i); // print all map key value pairs // const auto& val:statMap for (auto it = statistics.begin(); it != statistics.end(); ++it) { std::cout << it->first << ": " << it->second << std::endl; } // print the min and max index std::cout << "Min Index:" << std::endl; for (auto it = m_TimeStepMap[i].m_MinIndex.begin(); it != m_TimeStepMap[i].m_MinIndex.end(); ++it) { std::cout << *it << " "; } std::cout << std::endl; // print the min and max index std::cout << "Max Index:" << std::endl; for (auto it = m_TimeStepMap[i].m_MaxIndex.begin(); it != m_TimeStepMap[i].m_MaxIndex.end(); ++it) { std::cout << *it << " "; } std::cout << std::endl; } } }