Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
Medical Imaging Interaction Toolkit
mitkGenericParamModel.cpp
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 #include "mitkGenericParamModel.h"
14 #include "mitkFormulaParser.h"
15 
16 const std::string mitk::GenericParamModel::NAME_STATIC_PARAMETER_number = "number_of_parameters";
17 
19 {
20  return "Generic Parameter Model";
21 };
22 
24 {
25  return "Generic";
26 };
27 
29 {
30  return m_FunctionString;
31 };
32 
34 {
35  return "x";
36 };
37 
38 mitk::GenericParamModel::GenericParamModel(): m_FunctionString(""), m_NumberOfParameters(1)
39 {
40 };
41 
44 {
45  ParameterNamesType result;
46  result.push_back("a");
47 
48  if (m_NumberOfParameters > 1)
49  {
50  result.push_back("b");
51  }
52  if (m_NumberOfParameters > 2)
53  {
54  result.push_back("c");
55  }
56  if (m_NumberOfParameters > 3)
57  {
58  result.push_back("d");
59  }
60  if (m_NumberOfParameters > 4)
61  {
62  result.push_back("e");
63  }
64  if (m_NumberOfParameters > 5)
65  {
66  result.push_back("f");
67  }
68  if (m_NumberOfParameters > 6)
69  {
70  result.push_back("g");
71  }
72  if (m_NumberOfParameters > 7)
73  {
74  result.push_back("h");
75  }
76  if (m_NumberOfParameters > 8)
77  {
78  result.push_back("i");
79  }
80  if (m_NumberOfParameters > 9)
81  {
82  result.push_back("j");
83  }
84 
85  return result;
86 };
87 
90 {
91  return m_NumberOfParameters;
92 };
93 
96 {
97  unsigned int timeSteps = m_TimeGrid.GetSize();
98  ModelResultType signal(timeSteps);
99 
100  std::map<std::string, double> parameterMap;
101  parameterMap.insert(std::make_pair(GetXName(), 0.0));
102 
103  auto paramNames = this->GetParameterNames();
104  for (ParametersType::size_type i = 0; i < parameters.size(); ++i)
105  {
106  parameterMap.insert(std::make_pair(paramNames[i], parameters[i]));
107  }
108 
109  FormulaParser formulaParser(&parameterMap);
110 
111  TimeGridType::const_iterator timeGridEnd = m_TimeGrid.end();
112  ModelResultType::iterator signalPos = signal.begin();
113 
114  for (TimeGridType::const_iterator gridPos = m_TimeGrid.begin(); gridPos != timeGridEnd;
115  ++gridPos, ++signalPos)
116  {
117  parameterMap[GetXName()] = *gridPos;
118  *signalPos = formulaParser.parse(m_FunctionString);
119  }
120 
121  return signal;
122 };
123 
125 const
126 {
127  ParameterNamesType result;
128  result.push_back(NAME_STATIC_PARAMETER_number);
129  return result;
130 }
131 
134 {
135  return 1;
136 }
137 
139  const StaticParameterValuesType& values)
140 {
141  if (name == NAME_STATIC_PARAMETER_number)
142  {
143  SetNumberOfParameters(values[0]);
144  }
145 };
146 
149  const ParameterNameType& name) const
150 {
152 
153  if (name == NAME_STATIC_PARAMETER_number)
154  {
155  result.push_back(m_NumberOfParameters);
156  }
157 
158  return result;
159 };
160 
161 itk::LightObject::Pointer mitk::GenericParamModel::InternalClone() const
162 {
164 
165  newClone->SetTimeGrid(this->m_TimeGrid);
166  newClone->SetNumberOfParameters(this->m_NumberOfParameters);
167 
168  return newClone.GetPointer();
169 };
Superclass::ParametersSizeType ParametersSizeType
Superclass::ParameterNameType ParameterNameType
ModelTraitsInterface::ParametersType ParametersType
Definition: mitkModelBase.h:59
TimeGridType m_TimeGrid
This class offers the functionality to evaluate simple mathematical formula strings (e...
FunctionStringType GetFunctionString() const override
ParameterNamesType GetStaticParameterNames() const override
static const std::string NAME_STATIC_PARAMETER_number
ParametersSizeType GetNumberOfStaticParameters() const override
ValueType parse(const std::string &input)
Evaluates the input string and returns the resulting value.
ParameterNamesType GetParameterNames() const override
std::vector< StaticParameterValueType > StaticParameterValuesType
Definition: mitkModelBase.h:71
void SetStaticParameter(const ParameterNameType &name, const StaticParameterValuesType &values) override
ModelTraitsInterface::ModelResultType ModelResultType
Definition: mitkModelBase.h:55
std::string GetModelType() const override
ModelResultType ComputeModelfunction(const ParametersType &parameters) const override
ModelTraitsInterface::ParameterNamesType ParameterNamesType
Definition: mitkModelBase.h:64
virtual void SetNumberOfParameters(ParametersSizeType _arg)
std::string GetXName() const override
std::string GetModelDisplayName() const override
StaticParameterValuesType GetStaticParameterValue(const ParameterNameType &name) const override
ParametersSizeType GetNumberOfParameters() const override
static Pointer New()
itk::LightObject::Pointer InternalClone() const override