Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::ModelBase Class Referenceabstract

Base class for (dynamic) models. More...

#include <mitkModelBase.h>

Inheritance diagram for mitk::ModelBase:
Collaboration diagram for mitk::ModelBase:

Public Types

typedef ModelBase Self
 
typedef itk::Object Superclass
 
typedef itk::SmartPointer< Self > Pointer
 
typedef itk::SmartPointer< const Self > ConstPointer
 
typedef ModelTraitsInterface::ModelResultType ModelResultType
 
typedef ModelTraitsInterface::ParameterValueType ParameterValueType
 
typedef ModelTraitsInterface::ParametersType ParametersType
 
typedef itk::Array< double > TimeGridType
 Type defining the time grid used by models. More...
 
typedef ModelTraitsInterface::ParameterNameType ParameterNameType
 
typedef ModelTraitsInterface::ParameterNamesType ParameterNamesType
 
typedef ModelTraitsInterface::ParametersSizeType ParametersSizeType
 
typedef ModelTraitsInterface::DerivedParameterNamesType DerivedParameterNamesType
 
typedef ModelTraitsInterface::DerivedParametersSizeType DerivedParametersSizeType
 
typedef double StaticParameterValueType
 
typedef std::vector< StaticParameterValueType > StaticParameterValuesType
 
typedef std::map< ParameterNameType, StaticParameterValuesType > StaticParameterMapType
 
typedef double DerivedParameterValueType
 
typedef std::map< ParameterNameType, DerivedParameterValueType > DerivedParameterMapType
 
- Public Types inherited from mitk::ModelTraitsInterface
typedef itk::Array< double > ModelResultType
 Type representing the model output signal as an array of doubles. More...
 
using ParameterValueType = double
 Type of a single parameter value. More...
 
typedef itk::Array< ParameterValueType > ParametersType
 Type representing a vector of parameter values. More...
 
typedef std::string ParameterNameType
 Type used for parameter names. More...
 
typedef std::vector< ParameterNameType > ParameterNamesType
 Type for a list of parameter names. More...
 
typedef ParametersType::SizeValueType ParametersSizeType
 Type for the count of parameters. More...
 
typedef ParameterNamesType DerivedParameterNamesType
 Type for a list of derived parameter names. More...
 
typedef ParametersSizeType DerivedParametersSizeType
 Type for the count of derived parameters. More...
 
typedef std::map< ParameterNameType, double > ParamterScaleMapType
 Map type associating parameter names to their scaling factors. More...
 
typedef std::map< ParameterNameType, std::string > ParamterUnitMapType
 Map type associating parameter names to their unit strings. More...
 
typedef std::map< ParameterNameType, double > DerivedParamterScaleMapType
 Map type associating derived parameter names to their scaling factors. More...
 
typedef std::map< ParameterNameType, std::string > DerivedParamterUnitMapType
 Map type associating derived parameter names to their unit strings. More...
 
typedef std::string FunctionStringType
 Type for the function string representation of the model. More...
 
typedef std::string ModellClassIDType
 Type for the unique class identifier of the model. More...
 

Public Member Functions

virtual const char * GetClassName () const
 
ParamterScaleMapType GetParameterScales () const override
 Default implementation returns a scale of 1.0 for every defined parameter. More...
 
ParamterUnitMapType GetParameterUnits () const override
 Default implementation returns no unit string ("") for every defined parameter. More...
 
DerivedParamterScaleMapType GetDerivedParameterScales () const override
 Default implementation returns a scale of 1.0 for every defined derived parameter. More...
 
DerivedParamterUnitMapType GetDerivedParameterUnits () const override
 Default implementation returns no unit string ("") for every defined derived parameter. More...
 
std::string GetModelDisplayName () const override
 Default implementation returns GetClassID as display name. More...
 
std::string GetModelType () const override
 Default implementation returns "Unknown" as model type. More...
 
FunctionStringType GetFunctionString () const override
 Default implementation returns an empty function string. More...
 
ModellClassIDType GetClassID () const override
 Default implementation returns the class name of the concrete instance as ID. More...
 
std::string GetXName () const override
 Default implementation returns an empty string. More...
 
std::string GetXAxisName () const override
 Default implementation returns an empty string. More...
 
std::string GetXAxisUnit () const override
 Default implementation returns an empty string. More...
 
std::string GetYAxisName () const override
 Default implementation returns an empty string. More...
 
std::string GetYAxisUnit () const override
 Default implementation returns an empty string. More...
 
virtual ParameterNamesType GetStaticParameterNames () const =0
 Returns the names of static parameters used when computing the signal. More...
 
virtual ParametersSizeType GetNumberOfStaticParameters () const =0
 Returns the number of static parameters. More...
 
virtual ParamterUnitMapType GetStaticParameterUnits () const
 Default implementation returns no unit string ("") for every defined static parameter. More...
 
DerivedParameterNamesType GetDerivedParameterNames () const override
 Returns the names of derived parameters that can be computed by the model. More...
 
DerivedParametersSizeType GetNumberOfDerivedParameters () const override
 Returns the number of derived parameters that can be computed by the model. More...
 
void SetStaticParameters (const StaticParameterMapType &parameters, bool allParameters=true)
 Sets the static parameters of the model before it is used. More...
 
StaticParameterMapType GetStaticParameters () const
 Retrieves the static parameters of the model (e.g. for serialization). More...
 
DerivedParameterMapType GetDerivedParameters (const ParametersType &parameters) const
 Computes all derived parameters for the given model parameters. More...
 
virtual void SetTimeGrid (const TimeGridType &grid)
 Sets the time grid of the model. More...
 
virtual const TimeGridType & GetTimeGrid ()
 Gets the time grid of the model. More...
 
ModelResultType GetSignal (const ParametersType &parameters) const
 Computes and returns the model signal for the given parameters. More...
 
- Public Member Functions inherited from mitk::ModelTraitsInterface
virtual ParameterNamesType GetParameterNames () const =0
 Returns the names of parameters that must be defined when using the model to compute the signal (GetSignal()). More...
 
virtual ParametersSizeType GetNumberOfParameters () const =0
 Returns the number of parameters that must be defined when using the model to compute the signal (GetSignal()). More...
 

Protected Member Functions

virtual ModelResultType ComputeModelfunction (const ParametersType &parameters) const =0
 Computes the model function for the given parameters. More...
 
virtual bool ValidateModel (std::string &error) const
 Validates whether the model is in a valid state to compute the signal. More...
 
virtual DerivedParameterMapType ComputeDerivedParameters (const ParametersType &parameters) const
 Computes derived parameters from the given model parameters. More...
 
virtual void SetStaticParameter (const ParameterNameType &name, const StaticParameterValuesType &values)=0
 Sets a single static parameter by name. More...
 
virtual StaticParameterValuesType GetStaticParameterValue (const ParameterNameType &name) const =0
 Retrieves a single static parameter value by name. More...
 
 ModelBase ()
 
 ~ModelBase () override
 
 ModelBase (const ModelBase &source)
 
void PrintSelf (std::ostream &os, ::itk::Indent indent) const override
 
- Protected Member Functions inherited from mitk::ModelTraitsInterface
 ModelTraitsInterface ()
 
virtual ~ModelTraitsInterface ()
 

Protected Attributes

TimeGridType m_TimeGrid
 

Detailed Description

Base class for (dynamic) models.

A model can be used to calculate its signal given the discrete time grid of the signal and the parameters of the model.

A model has 3 types of parameters:

  • parameters
  • static parameters
  • derived parameters

"Parameters" and "static parameters" are used to compute the signal of the model. "Parameters" are the ones that will be changed for/by model fitting. "Static parameters" are used to configure the model for fitting but are itself not part of the fitting scope (compare itk::Transform parameters and static parameters). "Derived parameters" are model specific parameters computed from "Parameters" e.g. (DerivedParam1 = Param1/Param2). It may be implemented if e.g. for practical usage not the fitted parameters are needed but derivation of them.

Remarks
If you implement your own model calls regard const correctness and do not change or undermine the constness of this base class. It is important because in case of fitting models are used in a multi threaded environment and must be thread safe. Thus the getter and computation functions are implemented as const and thread safe methods.
See also
ModelTraitsInterface, ModelFactoryBase, ModelParameterizerBase

Definition at line 55 of file mitkModelBase.h.

Member Typedef Documentation

◆ ConstPointer

Definition at line 61 of file mitkModelBase.h.

◆ DerivedParameterMapType

◆ DerivedParameterNamesType

◆ DerivedParametersSizeType

◆ DerivedParameterValueType

Definition at line 82 of file mitkModelBase.h.

◆ ModelResultType

◆ ParameterNamesType

◆ ParameterNameType

◆ ParametersSizeType

◆ ParametersType

◆ ParameterValueType

◆ Pointer

Definition at line 60 of file mitkModelBase.h.

◆ Self

Definition at line 58 of file mitkModelBase.h.

◆ StaticParameterMapType

◆ StaticParameterValuesType

◆ StaticParameterValueType

Definition at line 78 of file mitkModelBase.h.

◆ Superclass

typedef itk::Object mitk::ModelBase::Superclass

Definition at line 59 of file mitkModelBase.h.

◆ TimeGridType

typedef itk::Array<double> mitk::ModelBase::TimeGridType

Type defining the time grid used by models.

Remarks
The model time grid has a resolution in seconds, not milliseconds like the time geometry.

Definition at line 70 of file mitkModelBase.h.

Constructor & Destructor Documentation

◆ ModelBase() [1/2]

mitk::ModelBase::ModelBase ( )
protected

◆ ~ModelBase()

mitk::ModelBase::~ModelBase ( )
overrideprotected

◆ ModelBase() [2/2]

mitk::ModelBase::ModelBase ( const ModelBase &  source)
protected

Member Function Documentation

◆ ComputeDerivedParameters()

virtual DerivedParameterMapType mitk::ModelBase::ComputeDerivedParameters ( const ParametersType &  parameters) const
protectedvirtual

Computes derived parameters from the given model parameters.

Helper function called by GetDerivedParameters(). Implement in derived classes to realize the concrete computation of derived parameters.

Remarks
Default implementation has no derived parameters.

Reimplemented in mitk::StandardToftsModel, mitk::ExtendedToftsModel, mitk::TwoStepLinearModel, mitk::ThreeStepLinearModel, mitk::TestModel, mitk::LinearModel, and mitk::ExponentialDecayModel.

◆ ComputeModelfunction()

virtual ModelResultType mitk::ModelBase::ComputeModelfunction ( const ParametersType &  parameters) const
protectedpure virtual

◆ GetClassID()

ModellClassIDType mitk::ModelBase::GetClassID ( ) const
overridevirtual

Default implementation returns the class name of the concrete instance as ID.

Implements mitk::ModelTraitsInterface.

◆ GetClassName()

◆ GetDerivedParameterNames()

DerivedParameterNamesType mitk::ModelBase::GetDerivedParameterNames ( ) const
overridevirtual

Returns the names of derived parameters that can be computed by the model.

Remarks
Default implementation has no derived parameters.

Implements mitk::ModelTraitsInterface.

Reimplemented in mitk::StandardToftsModel, mitk::ExtendedToftsModel, mitk::TwoStepLinearModel, mitk::ThreeStepLinearModel, and mitk::TestModel.

◆ GetDerivedParameters()

DerivedParameterMapType mitk::ModelBase::GetDerivedParameters ( const ParametersType &  parameters) const

Computes all derived parameters for the given model parameters.

To change the derived parameter computation, ComputeDerivedParameters must be (re)implemented.

Parameters
parametersThe parameters of the model for which the derived parameters should be computed.
Returns
A map of derived parameter names to their computed values.
Precondition
parameters must have the correct size.
Remarks
Default implementation has no derived parameters.

◆ GetDerivedParameterScales()

DerivedParamterScaleMapType mitk::ModelBase::GetDerivedParameterScales ( ) const
overridevirtual

Default implementation returns a scale of 1.0 for every defined derived parameter.

Implements mitk::ModelTraitsInterface.

◆ GetDerivedParameterUnits()

DerivedParamterUnitMapType mitk::ModelBase::GetDerivedParameterUnits ( ) const
overridevirtual

Default implementation returns no unit string ("") for every defined derived parameter.

Implements mitk::ModelTraitsInterface.

Reimplemented in mitk::StandardToftsModel, mitk::ExtendedToftsModel, mitk::TwoStepLinearModel, and mitk::ThreeStepLinearModel.

◆ GetFunctionString()

FunctionStringType mitk::ModelBase::GetFunctionString ( ) const
overridevirtual

Default implementation returns an empty function string.

Implements mitk::ModelTraitsInterface.

Reimplemented in mitk::TwoStepLinearModel, mitk::ThreeStepLinearModel, and mitk::TestModel.

◆ GetModelDisplayName()

◆ GetModelType()

◆ GetNumberOfDerivedParameters()

DerivedParametersSizeType mitk::ModelBase::GetNumberOfDerivedParameters ( ) const
overridevirtual

Returns the number of derived parameters that can be computed by the model.

Remarks
Default implementation has no derived parameters.

Implements mitk::ModelTraitsInterface.

Reimplemented in mitk::StandardToftsModel, mitk::ExtendedToftsModel, mitk::TwoStepLinearModel, mitk::ThreeStepLinearModel, and mitk::TestModel.

◆ GetNumberOfStaticParameters()

virtual ParametersSizeType mitk::ModelBase::GetNumberOfStaticParameters ( ) const
pure virtual

◆ GetParameterScales()

ParamterScaleMapType mitk::ModelBase::GetParameterScales ( ) const
overridevirtual

Default implementation returns a scale of 1.0 for every defined parameter.

Implements mitk::ModelTraitsInterface.

Reimplemented in mitk::TestModel.

◆ GetParameterUnits()

◆ GetSignal()

ModelResultType mitk::ModelBase::GetSignal ( const ParametersType &  parameters) const

Computes and returns the model signal for the given parameters.

Parameters
parametersThe model parameters.
Returns
The computed model signal.

◆ GetStaticParameterNames()

virtual ParameterNamesType mitk::ModelBase::GetStaticParameterNames ( ) const
pure virtual

Returns the names of static parameters used when computing the signal.

Static parameters are not part of the fitting scope but configure the model.

Returns
A vector of static parameter names.

Implemented in mitk::DescriptivePharmacokineticBrixModel, mitk::AIFBasedModelBase, mitk::TwoStepLinearModel, mitk::ThreeStepLinearModel, mitk::TestModel, mitk::LinearModel, mitk::GenericParamModel, mitk::ExponentialSaturationModel, mitk::ExponentialDecayModel, and mitk::ExpDecayOffsetModel.

◆ GetStaticParameters()

StaticParameterMapType mitk::ModelBase::GetStaticParameters ( ) const

Retrieves the static parameters of the model (e.g. for serialization).

Calls GetStaticParameter for every name defined in GetStaticParameterNames().

Returns
A map of static parameter names to their values.

◆ GetStaticParameterUnits()

virtual ParamterUnitMapType mitk::ModelBase::GetStaticParameterUnits ( ) const
virtual

Default implementation returns no unit string ("") for every defined static parameter.

Reimplemented in mitk::DescriptivePharmacokineticBrixModel, and mitk::AIFBasedModelBase.

◆ GetStaticParameterValue()

virtual StaticParameterValuesType mitk::ModelBase::GetStaticParameterValue ( const ParameterNameType &  name) const
protectedpure virtual

◆ GetTimeGrid()

virtual const TimeGridType& mitk::ModelBase::GetTimeGrid ( )
virtual

Gets the time grid of the model.

Remarks
The resolution of the time grid is in seconds (not in ms like mitk::TimeGeometry).

◆ GetXAxisName()

std::string mitk::ModelBase::GetXAxisName ( ) const
overridevirtual

◆ GetXAxisUnit()

std::string mitk::ModelBase::GetXAxisUnit ( ) const
overridevirtual

◆ GetXName()

std::string mitk::ModelBase::GetXName ( ) const
overridevirtual

Default implementation returns an empty string.

Implements mitk::ModelTraitsInterface.

Reimplemented in mitk::TwoStepLinearModel, mitk::ThreeStepLinearModel, and mitk::TestModel.

◆ GetYAxisName()

std::string mitk::ModelBase::GetYAxisName ( ) const
overridevirtual

◆ GetYAxisUnit()

std::string mitk::ModelBase::GetYAxisUnit ( ) const
overridevirtual

◆ PrintSelf()

void mitk::ModelBase::PrintSelf ( std::ostream &  os,
::itk::Indent  indent 
) const
overrideprotected

◆ SetStaticParameter()

virtual void mitk::ModelBase::SetStaticParameter ( const ParameterNameType &  name,
const StaticParameterValuesType &  values 
)
protectedpure virtual

◆ SetStaticParameters()

void mitk::ModelBase::SetStaticParameters ( const StaticParameterMapType &  parameters,
bool  allParameters = true 
)

Sets the static parameters of the model before it is used.

Checks the validity of the passed map and uses SetStaticParameter to set the values.

Parameters
parametersThe map with the static parameters and their values.
allParametersIf true, an exception will be thrown if the keys of passed parameters do not equal the return of GetStaticParameterNames. Thus if true, one must set all static parameters of the model.
Precondition
Parameters must only contain keys that exist in GetStaticParameterNames().
If allParameters == true, parameters must define all keys of GetStaticParameterNames().

◆ SetTimeGrid()

virtual void mitk::ModelBase::SetTimeGrid ( const TimeGridType &  grid)
virtual

Sets the time grid of the model.

The time grid indicates the time points correlated with the signal the model should produce.

Remarks
The resolution of the time grid is in seconds (not in ms like mitk::TimeGeometry).

◆ ValidateModel()

virtual bool mitk::ModelBase::ValidateModel ( std::string &  error) const
protectedvirtual

Validates whether the model is in a valid state to compute the signal.

Called by GetSignal() before ComputeModelfunction(). The default implementation checks nothing and always returns true. Reimplement to realize special behavior for derived classes.

Parameters
[out]errorSet internally to indicate the error reason if method returns false.
Returns
True if the model is valid and can compute a signal, false otherwise.

Reimplemented in mitk::AIFBasedModelBase.

Member Data Documentation

◆ m_TimeGrid

TimeGridType mitk::ModelBase::m_TimeGrid
protected

Definition at line 265 of file mitkModelBase.h.


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