Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkModelFitFunctorBase.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 mitkModelFitFunctorBase_h
14 #define mitkModelFitFunctorBase_h
15 
16 #include <itkObject.h>
17 
18 #include <mitkVector.h>
19 
20 #include <mitkModelBase.h>
22 
23 #include <MitkModelFitExports.h>
24 
25 #include <mutex>
26 
27 namespace mitk
28 {
29 
41  class MITKMODELFIT_EXPORT ModelFitFunctorBase: public ::itk::Object
42  {
43  public:
45  typedef itk::Object Superclass;
48 
49  itkTypeMacro(ModelFitFunctorBase, itk::Object);
50 
52  typedef std::vector<ParameterImagePixelType> InputPixelArrayType;
53  typedef std::vector<ParameterImagePixelType> OutputPixelArrayType;
54 
72  const ModelBase::ParametersType& initialParameters) const;
73 
82  unsigned int GetNumberOfOutputs(const ModelBase* model) const;
83 
85 
88 
91 
97  void RegisterEvaluationParameter(const std::string& parameterName,
98  SVModelFitCostFunction* evaluationCostFunction);
99 
105  const SVModelFitCostFunction* GetEvaluationParameterCostFunction(const std::string& parameterName)
106  const;
107 
109  virtual ParameterNamesType GetCriterionNames() const = 0 ;
110 
117 
118  itkBooleanMacro(DebugParameterMaps);
119  itkSetMacro(DebugParameterMaps, bool);
120  itkGetConstMacro(DebugParameterMaps, bool);
121 
122  protected:
123 
126 
128 
130 
136  virtual OutputPixelArrayType GetCriteria(const ModelBase* model, const ParametersType& parameters,
137  const SignalType& sample) const = 0;
138 
141  const ParametersType& parameters) const;
142 
145  const ParametersType& parameters, const SignalType& sample) const;
146 
147  typedef std::map<std::string, ParameterImagePixelType> DebugParameterMapType;
148 
163  virtual ParametersType DoModelFit(const SignalType& value, const ModelBase* model,
164  const ModelBase::ParametersType& initialParameters,
165  DebugParameterMapType& debugParameters) const = 0;
166 
173 
174  private:
175 
176  typedef std::map<std::string, SVModelFitCostFunction::Pointer> CostFunctionMapType;
177  CostFunctionMapType m_CostFunctionMap;
178  bool m_DebugParameterMaps;
179  mutable std::mutex m_Mutex;
180  };
181 
182 }
183 
184 
185 #endif
#define MITKMODELFIT_EXPORT
Base class for (dynamic) models.
Definition: mitkModelBase.h:56
ModelTraitsInterface::ParameterNamesType ParameterNamesType
Definition: mitkModelBase.h:72
ModelTraitsInterface::ParametersType ParametersType
Definition: mitkModelBase.h:67
itk::Array< double > SignalType
Type representing the observed signal values.
Abstract base class for functors that perform model fitting.
ModelFitCostFunctionInterface::SignalType SignalType
virtual ParameterNamesType GetCriterionNames() const =0
Returns names of the criteria used to fit the model.
void RegisterEvaluationParameter(const std::string &parameterName, SVModelFitCostFunction *evaluationCostFunction)
Registers an evaluation parameter with its cost function.
std::map< std::string, ParameterImagePixelType > DebugParameterMapType
itk::SmartPointer< const Self > ConstPointer
std::vector< ParameterImagePixelType > InputPixelArrayType
virtual ParameterNamesType DefineDebugParameterNames() const =0
Returns names of the debug parameters generated by the functor.
ModelBase::ParametersType ParametersType
virtual ParametersType DoModelFit(const SignalType &value, const ModelBase *model, const ModelBase::ParametersType &initialParameters, DebugParameterMapType &debugParameters) const =0
Internal method that performs the actual model fitting.
OutputPixelArrayType Compute(const InputPixelArrayType &value, const ModelBase *model, const ModelBase::ParametersType &initialParameters) const
Performs model fitting and returns the results.
unsigned int GetNumberOfOutputs(const ModelBase *model) const
Returns the number of outputs the fit functor will produce.
ParameterNamesType GetEvaluationParameterNames() const
Returns names of all evaluation parameters defined by the user.
void ResetEvaluationParameters()
Removes all registered evaluation parameters.
ModelBase::ParameterNamesType ParameterNamesType
itk::SmartPointer< Self > Pointer
ParameterNamesType GetDebugParameterNames() const
Returns names of the debug parameters generated by the functor.
virtual OutputPixelArrayType GetCriteria(const ModelBase *model, const ParametersType &parameters, const SignalType &sample) const =0
Internal method called by Compute() to get the final criterion values that drove the fit.
OutputPixelArrayType GetEvaluationParameters(const ModelBase *model, const ParametersType &parameters, const SignalType &sample) const
Internal method called by Compute() to get evaluation parameters from user-defined cost functions.
std::vector< ParameterImagePixelType > OutputPixelArrayType
OutputPixelArrayType GetDerivedParameters(const ModelBase *model, const ParametersType &parameters) const
Internal method called by Compute() to get derived parameters with the final fit parameters.
const SVModelFitCostFunction * GetEvaluationParameterCostFunction(const std::string &parameterName) const
Returns the cost function associated with the given evaluation parameter.
Base class for all model fit cost functions that return a single scalar cost value.
Find image slices visible on a given plane.
double ScalarType
Scalar type used throughout MITK for geometric computations.