Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkImageStatisticsTreeModel Class Reference

Tree model that represents mitk::ImageStatisticsContainer data in the Qt model/view framework. More...

#include <QmitkImageStatisticsTreeModel.h>

Inheritance diagram for QmitkImageStatisticsTreeModel:
Collaboration diagram for QmitkImageStatisticsTreeModel:

Signals

void dataAvailable ()
 Emitted when new statistics data becomes available in the model. More...
 
void modelChanged ()
 Emitted when the model rebuild is finished (usually shortly after dataAvailable()). More...
 

Public Member Functions

 QmitkImageStatisticsTreeModel (QObject *parent=nullptr)
 Constructs the tree model. More...
 
 ~QmitkImageStatisticsTreeModel () override
 Destructor. Disconnects from the data storage. More...
 
void SetImageNodes (const std::vector< mitk::DataNode::ConstPointer > &nodes)
 Sets the image nodes whose statistics should be displayed. More...
 
void SetMaskNodes (const std::vector< mitk::DataNode::ConstPointer > &nodes)
 Sets the mask nodes whose statistics should be displayed. More...
 
void Clear ()
 Clears all image nodes, mask nodes, statistics, and resets the model. More...
 
void SetIgnoreZeroValueVoxel (bool _arg)
 Sets whether zero-valued voxels should be ignored when selecting statistics. More...
 
bool GetIgnoreZeroValueVoxel () const
 Returns whether zero-valued voxels are currently being ignored. More...
 
void SetHistogramNBins (unsigned int nbins)
 Sets the number of histogram bins used to select matching statistics. More...
 
unsigned int GetHistogramNBins () const
 Returns the current number of histogram bins. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Returns the item flags for the given model index. More...
 
QVariant data (const QModelIndex &index, int role) const override
 Returns the data for the given index and role. More...
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const override
 Returns the header data for the given section and orientation. More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of child rows under the given parent. More...
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of columns (statistic names count + 1). More...
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 Returns the model index for the specified row, column, and parent. More...
 
QModelIndex parent (const QModelIndex &child) const override
 Returns the parent model index of the given child. More...
 
- Public Member Functions inherited from QmitkAbstractDataStorageModel
 ~QmitkAbstractDataStorageModel () override
 
void SetDataStorage (mitk::DataStorage *dataStorage)
 Sets the data storage and registers node event listeners. More...
 
mitk::DataStorage::Pointer GetDataStorage () const
 Returns a locked pointer to the current data storage. More...
 
void SetNodePredicate (const mitk::NodePredicateBase *nodePredicate)
 Sets the node predicate and triggers a model update. More...
 
const mitk::NodePredicateBase * GetNodePredicate () const
 Returns the currently set node predicate. More...
 

Protected Member Functions

void DataStorageChanged () override
 
void NodePredicateChanged () override
 
void NodeAdded (const mitk::DataNode *node) override
 
void NodeChanged (const mitk::DataNode *node) override
 
void NodeRemoved (const mitk::DataNode *node) override
 
- Protected Member Functions inherited from QmitkAbstractDataStorageModel
 QmitkAbstractDataStorageModel (QObject *parent=nullptr)
 
 QmitkAbstractDataStorageModel (mitk::DataStorage *dataStorage, QObject *parent=nullptr)
 

Additional Inherited Members

- Protected Attributes inherited from QmitkAbstractDataStorageModel
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
 
mitk::NodePredicateBase::ConstPointer m_NodePredicate
 

Detailed Description

Tree model that represents mitk::ImageStatisticsContainer data in the Qt model/view framework.

This model queries the data storage for ImageStatisticsContainer objects matching the configured image nodes, mask nodes, histogram bin count, and zero-voxel ignore flag. The results are presented in a hierarchical tree structure:

  • Level 1: Image
  • Level 2: Mask (if present)
  • Level 3: Label instances (if the mask has multiple labels)
  • Level 4: Time steps (if more than one exists)
See also
QmitkAbstractDataStorageModel
mitk::ImageStatisticsContainer
QmitkImageStatisticsWidget

Definition at line 42 of file QmitkImageStatisticsTreeModel.h.

Constructor & Destructor Documentation

◆ QmitkImageStatisticsTreeModel()

QmitkImageStatisticsTreeModel::QmitkImageStatisticsTreeModel ( QObject *  parent = nullptr)

Constructs the tree model.

Parameters
[in]parentOptional parent QObject.

◆ ~QmitkImageStatisticsTreeModel()

QmitkImageStatisticsTreeModel::~QmitkImageStatisticsTreeModel ( )
override

Destructor. Disconnects from the data storage.

Member Function Documentation

◆ Clear()

void QmitkImageStatisticsTreeModel::Clear ( )

Clears all image nodes, mask nodes, statistics, and resets the model.

◆ columnCount()

int QmitkImageStatisticsTreeModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

Returns the number of columns (statistic names count + 1).

Parameters
[in]parentThe parent model index (unused).
Returns
The number of columns.

◆ data()

QVariant QmitkImageStatisticsTreeModel::data ( const QModelIndex &  index,
int  role 
) const
override

Returns the data for the given index and role.

Supports Qt::DisplayRole for statistics values and Qt::DecorationRole for label color icons and WIP hourglass indicators in the first column.

Parameters
[in]indexThe model index to query.
[in]roleThe data role (e.g. Qt::DisplayRole, Qt::DecorationRole).
Returns
The data as QVariant, or an invalid QVariant if not applicable.

◆ dataAvailable

void QmitkImageStatisticsTreeModel::dataAvailable ( )
signal

Emitted when new statistics data becomes available in the model.

◆ DataStorageChanged()

void QmitkImageStatisticsTreeModel::DataStorageChanged ( )
overrideprotectedvirtual

◆ flags()

Qt::ItemFlags QmitkImageStatisticsTreeModel::flags ( const QModelIndex &  index) const
override

Returns the item flags for the given model index.

Parameters
[in]indexThe model index to query.
Returns
The Qt item flags for the index.

◆ GetHistogramNBins()

unsigned int QmitkImageStatisticsTreeModel::GetHistogramNBins ( ) const

Returns the current number of histogram bins.

Returns
The number of histogram bins.

◆ GetIgnoreZeroValueVoxel()

bool QmitkImageStatisticsTreeModel::GetIgnoreZeroValueVoxel ( ) const

Returns whether zero-valued voxels are currently being ignored.

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

◆ headerData()

QVariant QmitkImageStatisticsTreeModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const
override

Returns the header data for the given section and orientation.

The first column header is dynamically generated based on whether masks and multiple time steps are present. Subsequent columns show statistic names.

Parameters
[in]sectionThe column index.
[in]orientationThe header orientation (only Qt::Horizontal is supported).
[in]roleThe data role (only Qt::DisplayRole is supported).
Returns
The header text as QVariant.

◆ index()

QModelIndex QmitkImageStatisticsTreeModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

Returns the model index for the specified row, column, and parent.

Parameters
[in]rowThe row number.
[in]columnThe column number.
[in]parentThe parent model index.
Returns
The model index for the child, or an invalid index if it does not exist.

◆ modelChanged

void QmitkImageStatisticsTreeModel::modelChanged ( )
signal

Emitted when the model rebuild is finished (usually shortly after dataAvailable()).

◆ NodeAdded()

void QmitkImageStatisticsTreeModel::NodeAdded ( const mitk::DataNode *  node)
overrideprotectedvirtual

◆ NodeChanged()

void QmitkImageStatisticsTreeModel::NodeChanged ( const mitk::DataNode *  node)
overrideprotectedvirtual

◆ NodePredicateChanged()

void QmitkImageStatisticsTreeModel::NodePredicateChanged ( )
overrideprotectedvirtual

◆ NodeRemoved()

void QmitkImageStatisticsTreeModel::NodeRemoved ( const mitk::DataNode *  node)
overrideprotectedvirtual

◆ parent()

QModelIndex QmitkImageStatisticsTreeModel::parent ( const QModelIndex &  child) const
override

Returns the parent model index of the given child.

Parameters
[in]childThe child model index.
Returns
The parent model index, or an invalid index if the child is at the root level.

◆ rowCount()

int QmitkImageStatisticsTreeModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Returns the number of child rows under the given parent.

Parameters
[in]parentThe parent model index. Invalid index refers to the root.
Returns
The number of child rows.

◆ SetHistogramNBins()

void QmitkImageStatisticsTreeModel::SetHistogramNBins ( unsigned int  nbins)

Sets the number of histogram bins used to select matching statistics.

Triggers a model reset and rebuild if the value changes.

Parameters
[in]nbinsThe number of histogram bins.

◆ SetIgnoreZeroValueVoxel()

void QmitkImageStatisticsTreeModel::SetIgnoreZeroValueVoxel ( bool  _arg)

Sets whether zero-valued voxels should be ignored when selecting statistics.

Triggers a model reset and rebuild if the value changes.

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

◆ SetImageNodes()

void QmitkImageStatisticsTreeModel::SetImageNodes ( const std::vector< mitk::DataNode::ConstPointer > &  nodes)

Sets the image nodes whose statistics should be displayed.

Internally resolves each image's time steps for the hierarchical model. Triggers a model reset and rebuild.

Parameters
[in]nodesVector of image data nodes.

◆ SetMaskNodes()

void QmitkImageStatisticsTreeModel::SetMaskNodes ( const std::vector< mitk::DataNode::ConstPointer > &  nodes)

Sets the mask nodes whose statistics should be displayed.

Handles the special case where a single-timestep mask is applied to a multi-timestep image. Triggers a model reset and rebuild.

Parameters
[in]nodesVector of mask data nodes.

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