30 : m_CalculationJob(nullptr)
36 connect(m_CalculationJob, &QmitkImageStatisticsCalculationJob::finished,
this,
37 &QmitkStatisticsCalculator::OnStatisticsCalculationEnds, Qt::QueuedConnection);
42 if (!m_CalculationJob->isFinished())
44 m_CalculationJob->terminate();
45 m_CalculationJob->wait();
47 m_CalculationJob->deleteLater();
57 auto dataStorage = m_DataStorage.
Lock();
59 std::vector<double> lesionVolume;
65 std::sort(controlPoints.begin(), controlPoints.end());
67 for (
const auto& informationType : informationTypes)
69 for (
const auto& controlPoint : controlPoints)
76 specificSegmentation = semanticRelationsDataStorageAccess.
GetSpecificSegmentation(caseID, controlPoint, informationType, lesion);
77 if (
nullptr == specificSegmentation)
85 for (
auto it = parentNodes->Begin(); it != parentNodes->End(); ++it)
87 specificImage = it->Value();
90 volume = GetSegmentationMaskVolume(specificImage, specificSegmentation);
98 lesionVolume.push_back(volume);
114 auto dataStorage = m_DataStorage.
Lock();
116 if (imageNode.IsNull() || segmentationNode.IsNull())
121 m_ImageNode = imageNode;
122 m_SegmentationNode = segmentationNode;
125 auto segmentation =
dynamic_cast<mitk::Image*
>(m_SegmentationNode->GetData());
126 if (
nullptr ==
image ||
nullptr == segmentation)
134 bool imageStatisticsOlderThanInputs =
false;
135 if (imageStatistics && (imageStatistics->GetMTime() <
image->GetMTime() || (imageStatistics->GetMTime() < segmentation->GetMTime())))
137 imageStatisticsOlderThanInputs =
true;
140 if (!imageStatistics || imageStatisticsOlderThanInputs)
145 m_CalculationJob->start();
148 catch (
const std::exception&)
158 statisticsObject = imageStatistics->GetStatisticsForTimeStep(0);
169 m_MaskVolume = boost::get<double>(valueVariant);
180 void QmitkStatisticsCalculator::OnStatisticsCalculationEnds()
188 auto dataStorage = m_DataStorage.
Lock();
196 imageRule->Connect(statistic,
image);
202 maskRule->Connect(statistic, mask);
208 if (
nullptr != imageStatistics)
210 auto allDataNodes = dataStorage->GetAll()->CastToSTLConstContainer();
211 for (
auto node : allDataNodes)
213 auto nodeData = node->GetData();
214 if (
nullptr != nodeData && nodeData->GetUID() == imageStatistics->GetUID())
216 node->SetData(statistic);
223 auto statisticsNodeName = m_ImageNode->GetName();
224 if (m_SegmentationNode)
226 statisticsNodeName +=
"_" + m_SegmentationNode->GetName();
228 statisticsNodeName +=
"_statistics";
230 dataStorage->Add(statisticsNode);
itk::SmartPointer< T > Lock() const
void ComputeLesionVolume(mitk::LesionData &lesionData, const mitk::SemanticTypes::CaseID &caseID)
Compute and store lesion volume for all available control points and information types.
DataNode::Pointer GetSpecificSegmentation(const SemanticTypes::CaseID &caseID, const SemanticTypes::ControlPoint &controlPoint, const SemanticTypes::InformationType &informationType, const SemanticTypes::Lesion &lesion) const
Return the single segmentation node that is defined with the given information type, the given control point and is representing the given lesion. The function uses the 'GetAllSpecificSegmentations'-function to retrieve the specific segmentations and then checks for the represented lesion.
MITKSEMANTICRELATIONS_EXPORT NodePredicateAnd::Pointer GetImagePredicate()
DataNode::Pointer CreateImageStatisticsNode(ImageStatisticsContainer::Pointer statistic, const std::string &name)
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::InformationTypeVector GetAllInformationTypesOfCase(const SemanticTypes::CaseID &caseID)
bool HasStatistic(const std::string &name) const
QmitkStatisticsCalculator()
SemanticTypes::Lesion GetLesion() const
static mitk::ImageStatisticsContainer::ConstPointer GetImageStatistics(const mitk::DataStorage *dataStorage, const mitk::BaseData *image, const mitk::BaseData *mask=nullptr)
Returns the StatisticContainer for the given image and mask.
mitk::ImageStatisticsContainer * GetStatisticsData() const
const mitk::Image * GetStatisticsImage() const
std::vector< ControlPoint > ControlPointVector
mitk::DataStorage::Pointer m_DataStorage
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
bool IsExpired() const noexcept
Image class for storing images.
This class holds the data of each lesion in the lesion tree view. The data is the lesion itself with ...
void Initialize(const mitk::Image *image, const mitk::Image *binaryImage, const mitk::PlanarFigure *planarFig)
const mitk::Image * GetMaskImage() const
mitk::Image::Pointer image
~QmitkStatisticsCalculator() override
void SetLesionVolume(const std::vector< double > &lesionVolume)
The API provides functions to query and manipulate image relations and instances, that are helpful du...
std::vector< InformationType > InformationTypeVector
mitk::Image::Pointer mask
Container class for storing the computed image statistics.
bool GetStatisticsUpdateSuccessFlag() const
StatisticsVariantType GetValueNonConverted(const std::string &name) const
Returns the requested value.
static const std::string VOLUME()
MITKSEMANTICRELATIONS_EXPORT SemanticTypes::ControlPointVector GetAllControlPointsOfCase(const SemanticTypes::CaseID &caseID)