Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkImageStatisticsDataGenerator Class Reference

Generates and manages ImageStatisticsContainer results for image/ROI pairs. More...

#include <QmitkImageStatisticsDataGenerator.h>

Inheritance diagram for QmitkImageStatisticsDataGenerator:
Collaboration diagram for QmitkImageStatisticsDataGenerator:

Public Member Functions

 QmitkImageStatisticsDataGenerator (mitk::DataStorage::Pointer storage, QObject *parent=nullptr)
 Constructs the generator with a data storage. More...
 
 QmitkImageStatisticsDataGenerator (QObject *parent=nullptr)
 Constructs the generator without an initial data storage. More...
 
bool IsValidResultAvailable (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const
 Checks whether a valid, up-to-date statistics result exists for the given image/ROI pair. More...
 
mitk::DataNode::Pointer GetLatestResult (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode, bool onlyIfUpToDate=false, bool noWIP=true) const
 Returns the latest statistics result node for a given image/ROI pair and current settings. More...
 
std::string GenerateStatisticsNodeName (const mitk::Image *image, const mitk::BaseData *roi) const
 Generates a unique node name for a statistics result based on image, ROI, and current settings. More...
 
void SetIgnoreZeroValueVoxel (bool _arg)
 Sets whether zero-valued voxels should be ignored in statistics computation. More...
 
bool GetIgnoreZeroValueVoxel () const
 Returns whether zero-valued voxels are currently being ignored. More...
 
void SetHistogramNBins (unsigned int nbins)
 Sets the number of bins for histogram computation. More...
 
unsigned int GetHistogramNBins () const
 Returns the current number of histogram bins. More...
 
- Public Member Functions inherited from QmitkImageAndRoiDataGeneratorBase
ConstNodeVectorType GetImageNodes () const
 Returns the currently set image nodes. More...
 
ConstNodeVectorType GetROINodes () const
 Returns the currently set ROI nodes. More...
 
- Public Member Functions inherited from QmitkDataGeneratorBase
 QmitkDataGeneratorBase (const QmitkDataGeneratorBase &other)=delete
 
QmitkDataGeneratorBase & operator= (const QmitkDataGeneratorBase &other)=delete
 
virtual ~QmitkDataGeneratorBase ()
 
mitk::DataStorage::Pointer GetDataStorage () const
 Returns the data storage used by this generator. More...
 
bool GetAutoUpdate () const
 Returns whether automatic updates are enabled. More...
 
bool IsGenerating () const
 Returns whether data generation jobs are currently running or pending. More...
 
bool Generate () const
 Checks data validity and triggers generation of missing or outdated data. More...
 

Protected Member Functions

bool ChangedNodeIsRelevant (const mitk::DataNode *changedNode) const
 Determines whether a changed data node is relevant and should trigger a regeneration. More...
 
void IndicateFutureResults (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const
 Adds placeholder nodes and WIP dummy data to the data storage for missing or outdated results. More...
 
std::pair< QmitkDataGenerationJobBase *, mitk::DataNode::Pointer > GetNextMissingGenerationJob (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const
 Returns the next generation job and its associated placeholder node. More...
 
void RemoveObsoleteDataNodes (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const
 Removes obsolete result nodes for the given image/ROI pair from the data storage. More...
 
mitk::DataNode::Pointer PrepareResultForStorage (const std::string &label, mitk::BaseData *result, const QmitkDataGenerationJobBase *job) const
 Wraps a generation result in a data node suitable for storage. More...
 
 QmitkImageStatisticsDataGenerator (const QmitkImageStatisticsDataGenerator &)=delete
 
QmitkImageStatisticsDataGenerator & operator= (const QmitkImageStatisticsDataGenerator &)=delete
 
- Protected Member Functions inherited from QmitkImageAndRoiDataGeneratorBase
 QmitkImageAndRoiDataGeneratorBase (mitk::DataStorage::Pointer storage, QObject *parent=nullptr)
 
 QmitkImageAndRoiDataGeneratorBase (QObject *parent=nullptr)
 
InputPairVectorType GetAllImageROICombinations () const override
 Returns all image/ROI pairs for which data generation is needed. More...
 
 QmitkImageAndRoiDataGeneratorBase (const QmitkImageAndRoiDataGeneratorBase &)=delete
 
QmitkImageAndRoiDataGeneratorBase & operator= (const QmitkImageAndRoiDataGeneratorBase &)=delete
 
- Protected Member Functions inherited from QmitkDataGeneratorBase
 QmitkDataGeneratorBase (mitk::DataStorage::Pointer storage, QObject *parent=nullptr)
 Constructs a generator with the given data storage. More...
 
 QmitkDataGeneratorBase (QObject *parent=nullptr)
 Constructs a generator without an initial data storage. More...
 
InputPairVectorType FilterImageROICombinations (InputPairVectorType &&imageROICombinations) const
 Filters image/ROI pairs to only include those whose nodes exist in the data storage. More...
 
std::string GetPairDescription (const InputPairVectorType::value_type &imageAndSeg) const
 Returns a human-readable description of an image/ROI pair for debug logging. More...
 
bool DoGenerate () const
 Core generation loop that checks validity and launches jobs for all image/ROI pairs. More...
 
void EnsureRecheckingAndGeneration () const
 Ensures generation is (re)started, either immediately or by flagging a restart if already running. More...
 

Protected Attributes

bool m_IgnoreZeroValueVoxel
 
unsigned int m_HistogramNBins
 
- Protected Attributes inherited from QmitkImageAndRoiDataGeneratorBase
ConstNodeVectorType m_ImageNodes
 
ConstNodeVectorType m_ROINodes
 
- Protected Attributes inherited from QmitkDataGeneratorBase
mitk::WeakPointer< mitk::DataStorage > m_Storage
 
bool m_AutoUpdate
 
std::mutex m_DataMutex
 
itk::TimeStamp m_GenerationTime
 

Additional Inherited Members

- Public Types inherited from QmitkImageAndRoiDataGeneratorBase
using Superclass = QmitkDataGeneratorBase
 Superclass typedef. More...
 
using ConstNodeVectorType = std::vector< mitk::DataNode::ConstPointer >
 Vector of const data node pointers. More...
 
using NodeVectorType = std::vector< mitk::DataNode::Pointer >
 Vector of mutable data node pointers. More...
 
- Public Types inherited from QmitkDataGeneratorBase
using JobResultMapType = QmitkDataGenerationJobBase::ResultMapType
 Alias for the result map type produced by generation jobs. More...
 
- Public Slots inherited from QmitkImageAndRoiDataGeneratorBase
void SetImageNodes (const ConstNodeVectorType &imageNodes)
 Sets the image nodes for data generation. More...
 
void SetImageNodes (const NodeVectorType &imageNodes)
 Convenience overload accepting mutable node pointers. More...
 
void SetROINodes (const ConstNodeVectorType &roiNodes)
 Sets the ROI nodes for data generation. More...
 
void SetROINodes (const NodeVectorType &roiNodes)
 Convenience overload accepting mutable node pointers. More...
 
- Public Slots inherited from QmitkDataGeneratorBase
void SetDataStorage (mitk::DataStorage *storage)
 Sets the data storage for monitoring, storing WIP placeholders, and final results. More...
 
void SetAutoUpdate (bool autoUpdate)
 Enables or disables automatic update on data changes. More...
 
- Signals inherited from QmitkDataGeneratorBase
void DataGenerationStarted (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode, const QmitkDataGenerationJobBase *job) const
 Emitted when a data generation job is started for outdated or missing data. More...
 
void NewDataAvailable (mitk::DataStorage::SetOfObjects::ConstPointer data) const
 Emitted when new final result data has been produced and added to the data storage. More...
 
void GenerationFinished () const
 Emitted when all generation jobs have finished and all results are up to date. More...
 
void JobError (QString error, const QmitkDataGenerationJobBase *failedJob) const
 Emitted when a generation job encounters an error. More...
 
- Protected Types inherited from QmitkImageAndRoiDataGeneratorBase
using InputPairVectorType = Superclass::InputPairVectorType
 
- Protected Types inherited from QmitkDataGeneratorBase
using InputPairVectorType = std::vector< std::pair< mitk::DataNode::ConstPointer, mitk::DataNode::ConstPointer > >
 Vector of image/ROI node pairs used as input for generation. More...
 
- Protected Slots inherited from QmitkDataGeneratorBase
void OnJobError (QString error, const QmitkDataGenerationJobBase *failedJob) const
 Handles error signals from generation jobs and re-emits JobError. More...
 
void OnFinalResultsAvailable (JobResultMapType results, const QmitkDataGenerationJobBase *job) const
 Handles completed job results, adds them to the data storage, and emits NewDataAvailable. More...
 
- Static Protected Member Functions inherited from QmitkDataGeneratorBase
static mitk::DataNode::Pointer CreateWIPDataNode (mitk::BaseData *dataDummy, const std::string &nodeName)
 Creates a WIP placeholder data node for future results. More...
 

Detailed Description

Generates and manages ImageStatisticsContainer results for image/ROI pairs.

Uses QmitkImageStatisticsCalculationRunnable jobs to compute statistics for each image/ROI combination and ensures their validity. The generator encodes HistogramNBins and IgnoreZeroValueVoxel as properties on the result containers, since these settings are critical criteria for distinguishing statistics results.

For details on the generation orchestration, see QmitkDataGeneratorBase.

See also
QmitkImageAndRoiDataGeneratorBase
QmitkDataGeneratorBase
QmitkImageStatisticsCalculationRunnable
mitk::ImageStatisticsContainer

Definition at line 35 of file QmitkImageStatisticsDataGenerator.h.

Constructor & Destructor Documentation

◆ QmitkImageStatisticsDataGenerator() [1/3]

QmitkImageStatisticsDataGenerator::QmitkImageStatisticsDataGenerator ( mitk::DataStorage::Pointer  storage,
QObject *  parent = nullptr 
)
inline

Constructs the generator with a data storage.

Parameters
[in]storageThe data storage for storing results and observing changes.
[in]parentOptional parent QObject for Qt ownership.

Definition at line 43 of file QmitkImageStatisticsDataGenerator.h.

◆ QmitkImageStatisticsDataGenerator() [2/3]

QmitkImageStatisticsDataGenerator::QmitkImageStatisticsDataGenerator ( QObject *  parent = nullptr)
inline

Constructs the generator without an initial data storage.

Parameters
[in]parentOptional parent QObject for Qt ownership.

Definition at line 49 of file QmitkImageStatisticsDataGenerator.h.

◆ QmitkImageStatisticsDataGenerator() [3/3]

QmitkImageStatisticsDataGenerator::QmitkImageStatisticsDataGenerator ( const QmitkImageStatisticsDataGenerator &  )
protecteddelete

Member Function Documentation

◆ ChangedNodeIsRelevant()

bool QmitkImageStatisticsDataGenerator::ChangedNodeIsRelevant ( const mitk::DataNode *  changedNode) const
protectedvirtual

Determines whether a changed data node is relevant and should trigger a regeneration.

Parameters
[in]changedNodeThe node that was changed in the data storage.
Returns
True if the change is relevant and an update should be triggered.

Reimplemented from QmitkImageAndRoiDataGeneratorBase.

◆ GenerateStatisticsNodeName()

std::string QmitkImageStatisticsDataGenerator::GenerateStatisticsNodeName ( const mitk::Image *  image,
const mitk::BaseData *  roi 
) const

Generates a unique node name for a statistics result based on image, ROI, and current settings.

Parameters
[in]imageThe source image. Must not be nullptr.
[in]roiThe source ROI data (may be nullptr).
Returns
A string containing the generated node name incorporating bin count, zero-ignore flag, and UIDs.
Exceptions
mitk::Exceptionif image is nullptr.

◆ GetHistogramNBins()

unsigned int QmitkImageStatisticsDataGenerator::GetHistogramNBins ( ) const

Returns the current number of histogram bins.

Returns
The number of histogram bins.

◆ GetIgnoreZeroValueVoxel()

bool QmitkImageStatisticsDataGenerator::GetIgnoreZeroValueVoxel ( ) const

Returns whether zero-valued voxels are currently being ignored.

Returns
True if zero-valued voxels are ignored; false otherwise.

◆ GetLatestResult()

mitk::DataNode::Pointer QmitkImageStatisticsDataGenerator::GetLatestResult ( const mitk::DataNode *  imageNode,
const mitk::DataNode *  roiNode,
bool  onlyIfUpToDate = false,
bool  noWIP = true 
) const

Returns the latest statistics result node for a given image/ROI pair and current settings.

Parameters
[in]imageNodeThe image data node. Must not be nullptr and must contain valid data.
[in]roiNodeThe ROI data node (may be nullptr).
[in]onlyIfUpToDateIf true, only returns results that are newer than the source image and ROI.
[in]noWIPIf true, only returns finalized results (not WIP placeholders). If false, may also return a WIP placeholder indicating computation is in progress.
Returns
The result data node, or nullptr if no matching result is found.
Exceptions
mitk::Exceptionif imageNode is nullptr or contains no data.

◆ GetNextMissingGenerationJob()

std::pair<QmitkDataGenerationJobBase*, mitk::DataNode::Pointer> QmitkImageStatisticsDataGenerator::GetNextMissingGenerationJob ( const mitk::DataNode *  imageNode,
const mitk::DataNode *  roiNode 
) const
protectedvirtual

Returns the next generation job and its associated placeholder node.

Note
The caller takes ownership of the returned job instance.
Parameters
[in]imageNodeThe image data node.
[in]roiNodeThe ROI data node (may be nullptr).
Returns
A pair of (job, placeholder node) with three possible outcomes:
  • Both null: nothing to do.
  • Both set: a pending placeholder needs computation; trigger the job.
  • Job null, node set: a job for this node is already in progress; wait for completion.

Implements QmitkDataGeneratorBase.

◆ IndicateFutureResults()

void QmitkImageStatisticsDataGenerator::IndicateFutureResults ( const mitk::DataNode *  imageNode,
const mitk::DataNode *  roiNode 
) const
protectedvirtual

Adds placeholder nodes and WIP dummy data to the data storage for missing or outdated results.

The placeholder nodes will be replaced by real results once generation completes. Derived classes define the detection strategy and dummy data format.

Parameters
[in]imageNodeThe image data node.
[in]roiNodeThe ROI data node (may be nullptr).

Implements QmitkDataGeneratorBase.

◆ IsValidResultAvailable()

bool QmitkImageStatisticsDataGenerator::IsValidResultAvailable ( const mitk::DataNode *  imageNode,
const mitk::DataNode *  roiNode 
) const
virtual

Checks whether a valid, up-to-date statistics result exists for the given image/ROI pair.

Parameters
[in]imageNodeThe image data node.
[in]roiNodeThe ROI data node (may be nullptr).
Returns
True if a valid final result is available; false otherwise.

Implements QmitkDataGeneratorBase.

◆ operator=()

QmitkImageStatisticsDataGenerator& QmitkImageStatisticsDataGenerator::operator= ( const QmitkImageStatisticsDataGenerator &  )
protecteddelete

◆ PrepareResultForStorage()

mitk::DataNode::Pointer QmitkImageStatisticsDataGenerator::PrepareResultForStorage ( const std::string &  label,
mitk::BaseData *  result,
const QmitkDataGenerationJobBase *  job 
) const
protectedvirtual

Wraps a generation result in a data node suitable for storage.

Parameters
[in]labelThe result label from the job's result map.
[in]resultThe generated data to store.
[in]jobThe job that produced the result.
Returns
A data node ready to be added to the data storage.

Implements QmitkDataGeneratorBase.

◆ RemoveObsoleteDataNodes()

void QmitkImageStatisticsDataGenerator::RemoveObsoleteDataNodes ( const mitk::DataNode *  imageNode,
const mitk::DataNode *  roiNode 
) const
protectedvirtual

Removes obsolete result nodes for the given image/ROI pair from the data storage.

Obsolete nodes are interim result nodes that have been superseded by newer results.

Parameters
[in]imageNodeThe image data node.
[in]roiNodeThe ROI data node (may be nullptr).

Implements QmitkDataGeneratorBase.

◆ SetHistogramNBins()

void QmitkImageStatisticsDataGenerator::SetHistogramNBins ( unsigned int  nbins)

Sets the number of bins for histogram computation.

If auto-update is enabled and the value changes, regeneration is triggered.

Parameters
[in]nbinsThe number of histogram bins.

◆ SetIgnoreZeroValueVoxel()

void QmitkImageStatisticsDataGenerator::SetIgnoreZeroValueVoxel ( bool  _arg)

Sets whether zero-valued voxels should be ignored in statistics computation.

If auto-update is enabled and the value changes, regeneration is triggered.

Parameters
[in]_argTrue to ignore zero-valued voxels; false to include them.

Member Data Documentation

◆ m_HistogramNBins

unsigned int QmitkImageStatisticsDataGenerator::m_HistogramNBins
protected

Definition at line 122 of file QmitkImageStatisticsDataGenerator.h.

◆ m_IgnoreZeroValueVoxel

bool QmitkImageStatisticsDataGenerator::m_IgnoreZeroValueVoxel
protected

Definition at line 121 of file QmitkImageStatisticsDataGenerator.h.


The documentation for this class was generated from the following file: