Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkLinearModel.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 "mitkLinearModel.h"
14 
16 {
17  return "Linear Model";
18 };
19 
21 {
22  return "Generic";
23 };
24 
26 {
27  return "slope*x+offset";
28 };
29 
30 std::string mitk::LinearModel::GetXName() const
31 {
32  return "x";
33 };
34 
37 {
38  ParameterNamesType result;
39  result.push_back("slope");
40  result.push_back("offset");
41  return result;
42 };
43 
46 {
47  return 2;
48 };
49 
52 {
53  ParameterNamesType result;
54  result.push_back("x-intercept");
55  return result;
56 };
57 
60 {
61  return 1;
62 };
63 
66 {
67  ModelResultType signal(m_TimeGrid.GetSize());
68 
69  TimeGridType::const_iterator timeGridEnd = m_TimeGrid.end();
70  ModelResultType::iterator signalPos = signal.begin();
71 
72  for (TimeGridType::const_iterator gridPos = m_TimeGrid.begin(); gridPos != timeGridEnd;
73  ++gridPos, ++signalPos)
74  {
75  *signalPos = parameters[0] * (*gridPos) + parameters[1];
76  }
77 
78  return signal;
79 };
80 
82 {
83  ParameterNamesType result;
84 
85  return result;
86 }
87 
89 {
90  return 0;
91 }
92 
94  const StaticParameterValuesType& /*values*/)
95 {
96  //do nothing
97 };
98 
100  const ParameterNameType& /*name*/) const
101 {
103 
104  //do nothing
105 
106  return result;
107 };
108 
110  const mitk::ModelBase::ParametersType& parameters) const
111 {
113  double intercept = -1 * parameters[1] / parameters[0];
114  result.insert(std::make_pair("x-intercept", intercept));
115  return result;
116 };
117 
118 itk::LightObject::Pointer mitk::LinearModel::InternalClone() const
119 {
121 
122  newClone->SetTimeGrid(this->m_TimeGrid);
123 
124  return newClone.GetPointer();
125 };
std::string GetXName() const override
std::string GetModelDisplayName() const override
ModelTraitsInterface::ParametersType ParametersType
Definition: mitkModelBase.h:59
TimeGridType m_TimeGrid
ModelResultType ComputeModelfunction(const ParametersType &parameters) const override
ParametersSizeType GetNumberOfDerivedParameters() const override
ParametersSizeType GetNumberOfStaticParameters() const override
void SetStaticParameter(const ParameterNameType &name, const StaticParameterValuesType &values) override
std::string GetModelType() const override
ParameterNamesType GetParameterNames() const override
std::vector< StaticParameterValueType > StaticParameterValuesType
Definition: mitkModelBase.h:71
std::map< ParameterNameType, DerivedParameterValueType > DerivedParameterMapType
Definition: mitkModelBase.h:75
ModelTraitsInterface::ModelResultType ModelResultType
Definition: mitkModelBase.h:55
static Pointer New()
itk::LightObject::Pointer InternalClone() const override
ModelTraitsInterface::ParameterNamesType ParameterNamesType
Definition: mitkModelBase.h:64
Superclass::ParameterNameType ParameterNameType
ParameterNamesType GetDerivedParameterNames() const override
FunctionStringType GetFunctionString() const override
DerivedParameterMapType ComputeDerivedParameters(const mitk::ModelBase::ParametersType &parameters) const override
ParametersSizeType GetNumberOfParameters() const override
Superclass::ParametersSizeType ParametersSizeType
StaticParameterValuesType GetStaticParameterValue(const ParameterNameType &name) const override
ParameterNamesType GetStaticParameterNames() const override