Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkInitialValuesModel Class Reference

Qt table model for defining and editing initial parameter values of a model fit. More...

#include <QmitkInitialValuesModel.h>

Inheritance diagram for QmitkInitialValuesModel:
Collaboration diagram for QmitkInitialValuesModel:

Public Member Functions

 QmitkInitialValuesModel (QObject *parent=nullptr)
 Constructs a QmitkInitialValuesModel. More...
 
 ~QmitkInitialValuesModel () override
 Destructor. More...
 
void setInitialValues (const mitk::ModelTraitsInterface::ParameterNamesType &names, const mitk::ModelTraitsInterface::ParametersType values, const mitk::ModelTraitsInterface::ParamterUnitMapType units)
 Sets the parameter names, default values, and units. More...
 
void setInitialValues (const mitk::ModelTraitsInterface::ParameterNamesType &names)
 Sets the parameter names with all initial values defaulting to zero. More...
 
void addInitialParameterImage (const mitk::DataNode *node, mitk::ModelTraitsInterface::ParametersType::size_type paramIndex)
 Assigns an image as the initial value source for a specific parameter. More...
 
bool hasValidInitialValues () const
 Checks whether all initial values are valid. More...
 
void resetInitialParameterImage ()
 Clears all image-based parameter assignments. More...
 
mitk::InitialParameterizationDelegateBase::Pointer getInitialParametrizationDelegate () const
 Creates and returns a delegate representing the full initial parameterization. More...
 
mitk::ModelTraitsInterface::ParametersType getInitialValues () const
 Returns the current scalar initial values. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Returns item flags for the given model index. More...
 
QVariant data (const QModelIndex &index, int role) const override
 Returns data for the given index and role. More...
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const override
 Returns header data for the specified section. More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of parameters (rows). More...
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Returns the number of columns (always 4). More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 Sets data for a given index. More...
 
bool isModified ()
 Indicates whether the model content has been modified since the last setInitialValues() call. More...
 

Detailed Description

Qt table model for defining and editing initial parameter values of a model fit.

This model manages the initial values used to start a model fitting process. Each parameter can be initialized with either a simple scalar value or an image-based value source. The model provides four columns: parameter name, value type (scalar/image), value, and unit.

The type and value columns are editable. When the type is set to "image", the value column displays the name of the selected data node rather than a numeric value.

See also
QmitkInitialValuesManagerWidget
QmitkInitialValuesDelegate
QmitkInitialValuesTypeDelegate
mitk::InitialParameterizationDelegateBase

Definition at line 42 of file QmitkInitialValuesModel.h.

Constructor & Destructor Documentation

◆ QmitkInitialValuesModel()

QmitkInitialValuesModel::QmitkInitialValuesModel ( QObject *  parent = nullptr)

Constructs a QmitkInitialValuesModel.

Parameters
[in]parentOptional parent QObject.

◆ ~QmitkInitialValuesModel()

QmitkInitialValuesModel::~QmitkInitialValuesModel ( )
inlineoverride

Destructor.

Definition at line 54 of file QmitkInitialValuesModel.h.

Member Function Documentation

◆ addInitialParameterImage()

void QmitkInitialValuesModel::addInitialParameterImage ( const mitk::DataNode *  node,
mitk::ModelTraitsInterface::ParametersType::size_type  paramIndex 
)

Assigns an image as the initial value source for a specific parameter.

Parameters
[in]nodePointer to the data node containing the source image.
[in]paramIndexIndex of the parameter to initialize with the image. Corresponds to the position in the vector defined by setInitialValues().
Precondition
paramIndex must be within bounds of the initial parameterization vector.
node must point to a valid mitk::Image instance.
Exceptions
mitk::Exceptionif node is nullptr or does not contain an image.
Note
Setting an image for an index overwrites any previously set scalar value for that parameter.

◆ columnCount()

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

Returns the number of columns (always 4).

Parameters
[in]parentThe parent model index.
Returns
4 (name, type, value, unit). Returns 0 if parent is valid.

◆ data()

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

Returns data for the given index and role.

Column 0: parameter name. Column 1: type ("scalar" or "image"). Column 2: the scalar value or the name of the selected image node. Column 3: the parameter unit.

Parameters
[in]indexThe model index to query.
[in]roleThe Qt item data role.
Returns
The requested data as QVariant.

◆ flags()

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

Returns item flags for the given model index.

Columns 1 (type) and 2 (value) are editable; columns 0 (name) and 3 (unit) are read-only.

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

◆ getInitialParametrizationDelegate()

mitk::InitialParameterizationDelegateBase::Pointer QmitkInitialValuesModel::getInitialParametrizationDelegate ( ) const

Creates and returns a delegate representing the full initial parameterization.

The returned delegate contains both scalar initial values and any image-based parameterizations that have been configured.

Returns
Smart pointer to an InitialParameterizationDelegateBase.

◆ getInitialValues()

mitk::ModelTraitsInterface::ParametersType QmitkInitialValuesModel::getInitialValues ( ) const

Returns the current scalar initial values.

Returns
The parameter values vector.
Note
This only returns scalar initial values. Image-based parameterizations are not included. Use getInitialParametrizationDelegate() to retrieve the complete parameterization.

◆ hasValidInitialValues()

bool QmitkInitialValuesModel::hasValidInitialValues ( ) const

Checks whether all initial values are valid.

Returns false if any image-based parameter has a null data node pointer.

Returns
True if all initial values are valid, false otherwise.

◆ headerData()

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

Returns header data for the specified section.

Horizontal headers are: "Parameters", "Type", "Value", "Unit".

Parameters
[in]sectionThe column index.
[in]orientationThe header orientation.
[in]roleThe Qt item data role.
Returns
The header data as QVariant.

◆ isModified()

bool QmitkInitialValuesModel::isModified ( )

Indicates whether the model content has been modified since the last setInitialValues() call.

Returns
True if modified, false otherwise.

◆ resetInitialParameterImage()

void QmitkInitialValuesModel::resetInitialParameterImage ( )

Clears all image-based parameter assignments.

Triggers a full model reset. After this call, all parameters revert to their scalar initial values.

◆ rowCount()

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

Returns the number of parameters (rows).

Parameters
[in]parentThe parent model index.
Returns
The number of rows. Returns 0 if parent is valid.

◆ setData()

bool QmitkInitialValuesModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
override

Sets data for a given index.

For column 1 (type), accepts an integer (0 = scalar, 1 = image) and switches the value source accordingly. For column 2 (value), accepts a double for scalar types or a void pointer to a mitk::DataNode for image types.

Parameters
[in]indexThe model index to modify.
[in]valueThe new value to set.
[in]roleThe Qt item data role (only Qt::EditRole is handled).
Returns
True if data was successfully set, false otherwise.

◆ setInitialValues() [1/2]

void QmitkInitialValuesModel::setInitialValues ( const mitk::ModelTraitsInterface::ParameterNamesType &  names)

Sets the parameter names with all initial values defaulting to zero.

Convenience overload that calls setInitialValues() with a zero-filled values vector and empty unit strings.

Parameters
[in]namesList of parameter names.

◆ setInitialValues() [2/2]

void QmitkInitialValuesModel::setInitialValues ( const mitk::ModelTraitsInterface::ParameterNamesType &  names,
const mitk::ModelTraitsInterface::ParametersType  values,
const mitk::ModelTraitsInterface::ParamterUnitMapType  units 
)

Sets the parameter names, default values, and units.

Triggers a full model reset. The modified flag is cleared.

Parameters
[in]namesList of parameter names. The index corresponds to the parameter index in the fitting model.
[in]valuesDefault initial values for the parameters.
[in]unitsMap of parameter names to their unit strings.
Exceptions
mitk::Exceptionif the sizes of names, values, and units do not match.

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