Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkModelBase.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkModelBase_h
14 #define mitkModelBase_h
15 
16 #include <iostream>
17 
18 #include <itkArray.h>
19 #include <itkArray2D.h>
20 #include <itkObject.h>
21 
22 #include <MitkModelFitExports.h>
24 #include <mitkCommon.h>
25 
26 namespace mitk
27 {
55  class MITKMODELFIT_EXPORT ModelBase : public itk::Object, public ModelTraitsInterface
56  {
57  public:
58  typedef ModelBase Self;
59  typedef itk::Object Superclass;
62 
63  itkTypeMacro(ModelBase, itk::Object);
64 
70  typedef itk::Array<double> TimeGridType;
74 
77 
78  typedef double StaticParameterValueType;
79  typedef std::vector<StaticParameterValueType> StaticParameterValuesType;
80  typedef std::map<ParameterNameType, StaticParameterValuesType> StaticParameterMapType;
81 
82  typedef double DerivedParameterValueType;
83  typedef std::map<ParameterNameType, DerivedParameterValueType> DerivedParameterMapType;
84 
87 
90 
93 
96 
98  std::string GetModelDisplayName() const override;
99 
101  std::string GetModelType() const override;
102 
105 
107  ModellClassIDType GetClassID() const override;
108 
110  std::string GetXName() const override;
111 
113  std::string GetXAxisName() const override;
114 
116  std::string GetXAxisUnit() const override;
117 
119  std::string GetYAxisName() const override;
120 
122  std::string GetYAxisUnit() const override;
123 
131 
137 
140 
141 
147 
153 
166  void SetStaticParameters(const StaticParameterMapType& parameters, bool allParameters = true);
167 
175 
187 
194  virtual void SetTimeGrid(const TimeGridType& grid);
195 
200  itkGetConstReferenceMacro(TimeGrid, TimeGridType);
201 
207  ModelResultType GetSignal(const ParametersType& parameters) const;
208 
209  protected:
210 
218  virtual ModelResultType ComputeModelfunction(const ParametersType& parameters) const = 0;
219 
230  virtual bool ValidateModel(std::string& error) const;
231 
240 
246  virtual void SetStaticParameter(const ParameterNameType& name,
247  const StaticParameterValuesType& values) = 0;
248 
255 
257  ~ModelBase() override;
258 
259  ModelBase(const ModelBase& source);
260 
261  void PrintSelf(std::ostream& os, ::itk::Indent indent) const override;
262 
263  //timeGrid in seconds
264 
266 
267  private:
268 
269  void operator=(const Self&); //purposely not implemented
270  };
271 }
272 
273 #endif
#define MITKMODELFIT_EXPORT
Base class for (dynamic) models.
Definition: mitkModelBase.h:56
virtual ModelResultType ComputeModelfunction(const ParametersType &parameters) const =0
Computes the model function for the given parameters.
std::string GetXName() const override
Default implementation returns an empty string.
ModellClassIDType GetClassID() const override
Default implementation returns the class name of the concrete instance as ID.
virtual ParameterNamesType GetStaticParameterNames() const =0
Returns the names of static parameters used when computing the signal.
DerivedParamterUnitMapType GetDerivedParameterUnits() const override
Default implementation returns no unit string ("") for every defined derived parameter.
TimeGridType m_TimeGrid
virtual ParametersSizeType GetNumberOfStaticParameters() const =0
Returns the number of static parameters.
double DerivedParameterValueType
Definition: mitkModelBase.h:82
ModelTraitsInterface::DerivedParameterNamesType DerivedParameterNamesType
Definition: mitkModelBase.h:75
ModelTraitsInterface::DerivedParametersSizeType DerivedParametersSizeType
Definition: mitkModelBase.h:76
virtual bool ValidateModel(std::string &error) const
Validates whether the model is in a valid state to compute the signal.
itk::SmartPointer< const Self > ConstPointer
Definition: mitkModelBase.h:61
virtual DerivedParameterMapType ComputeDerivedParameters(const ParametersType &parameters) const
Computes derived parameters from the given model parameters.
itk::SmartPointer< Self > Pointer
Definition: mitkModelBase.h:60
ModelTraitsInterface::ParametersSizeType ParametersSizeType
Definition: mitkModelBase.h:73
ModelTraitsInterface::ParameterNamesType ParameterNamesType
Definition: mitkModelBase.h:72
std::map< ParameterNameType, DerivedParameterValueType > DerivedParameterMapType
Definition: mitkModelBase.h:83
virtual ParamterUnitMapType GetStaticParameterUnits() const
Default implementation returns no unit string ("") for every defined static parameter.
std::map< ParameterNameType, StaticParameterValuesType > StaticParameterMapType
Definition: mitkModelBase.h:80
~ModelBase() override
ModelBase Self
Definition: mitkModelBase.h:58
ModelTraitsInterface::ParameterValueType ParameterValueType
Definition: mitkModelBase.h:66
ModelBase(const ModelBase &source)
itk::Object Superclass
Definition: mitkModelBase.h:59
StaticParameterMapType GetStaticParameters() const
Retrieves the static parameters of the model (e.g. for serialization).
std::string GetModelType() const override
Default implementation returns "Unknown" as model type.
ParamterScaleMapType GetParameterScales() const override
Default implementation returns a scale of 1.0 for every defined parameter.
virtual StaticParameterValuesType GetStaticParameterValue(const ParameterNameType &name) const =0
Retrieves a single static parameter value by name.
virtual void SetStaticParameter(const ParameterNameType &name, const StaticParameterValuesType &values)=0
Sets a single static parameter by name.
std::string GetYAxisName() const override
Default implementation returns an empty string.
std::vector< StaticParameterValueType > StaticParameterValuesType
Definition: mitkModelBase.h:79
virtual void SetTimeGrid(const TimeGridType &grid)
Sets the time grid of the model.
std::string GetXAxisName() const override
Default implementation returns an empty string.
ModelResultType GetSignal(const ParametersType &parameters) const
Computes and returns the model signal for the given parameters.
DerivedParameterNamesType GetDerivedParameterNames() const override
Returns the names of derived parameters that can be computed by the model.
FunctionStringType GetFunctionString() const override
Default implementation returns an empty function string.
ModelTraitsInterface::ParameterNameType ParameterNameType
Definition: mitkModelBase.h:71
ParamterUnitMapType GetParameterUnits() const override
Default implementation returns no unit string ("") for every defined parameter.
void PrintSelf(std::ostream &os, ::itk::Indent indent) const override
double StaticParameterValueType
Definition: mitkModelBase.h:78
std::string GetXAxisUnit() const override
Default implementation returns an empty string.
DerivedParamterScaleMapType GetDerivedParameterScales() const override
Default implementation returns a scale of 1.0 for every defined derived parameter.
void SetStaticParameters(const StaticParameterMapType &parameters, bool allParameters=true)
Sets the static parameters of the model before it is used.
DerivedParametersSizeType GetNumberOfDerivedParameters() const override
Returns the number of derived parameters that can be computed by the model.
DerivedParameterMapType GetDerivedParameters(const ParametersType &parameters) const
Computes all derived parameters for the given model parameters.
ModelTraitsInterface::ModelResultType ModelResultType
Definition: mitkModelBase.h:63
itk::Array< double > TimeGridType
Type defining the time grid used by models.
Definition: mitkModelBase.h:70
std::string GetYAxisUnit() const override
Default implementation returns an empty string.
ModelTraitsInterface::ParametersType ParametersType
Definition: mitkModelBase.h:67
std::string GetModelDisplayName() const override
Default implementation returns GetClassID as display name.
Pure virtual interface that defines the traits (metadata) of a model used for fitting.
std::map< ParameterNameType, double > ParamterScaleMapType
Map type associating parameter names to their scaling factors.
std::string FunctionStringType
Type for the function string representation of the model.
ParametersType::SizeValueType ParametersSizeType
Type for the count of parameters.
itk::Array< double > ModelResultType
Type representing the model output signal as an array of doubles.
ParametersSizeType DerivedParametersSizeType
Type for the count of derived parameters.
std::map< ParameterNameType, std::string > ParamterUnitMapType
Map type associating parameter names to their unit strings.
std::string ModellClassIDType
Type for the unique class identifier of the model.
itk::Array< ParameterValueType > ParametersType
Type representing a vector of parameter values.
std::string ParameterNameType
Type used for parameter names.
std::map< ParameterNameType, std::string > DerivedParamterUnitMapType
Map type associating derived parameter names to their unit strings.
double ParameterValueType
Type of a single parameter value.
std::map< ParameterNameType, double > DerivedParamterScaleMapType
Map type associating derived parameter names to their scaling factors.
ParameterNamesType DerivedParameterNamesType
Type for a list of derived parameter names.
std::vector< ParameterNameType > ParameterNamesType
Type for a list of parameter names.
Find image slices visible on a given plane.