Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkTwoTissueCompartmentModel.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 
14 #include "mitkConvolutionHelper.h"
15 #include <fstream>
16 const std::string mitk::TwoTissueCompartmentModel::MODEL_DISPLAY_NAME = "Two Tissue Compartment Model";
17 
23 
24 const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_K1 = "1/min";
25 const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_k2 = "1/min";
26 const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_k3 = "1/min";
27 const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_k4 = "1/min";
28 const std::string mitk::TwoTissueCompartmentModel::UNIT_PARAMETER_VB = "ml/ml";
29 
35 
37 
38 
39 inline double square(double a)
40 {
41  return a * a;
42 }
43 
45 {
46  return MODEL_DISPLAY_NAME;
47 };
48 
50 {
51  return "Dynamic.PET";
52 };
53 
55 {
56 
57 }
58 
60 {
61 
62 }
63 
66 {
67  ParameterNamesType result;
68 
69  result.push_back(NAME_PARAMETER_K1);
70  result.push_back(NAME_PARAMETER_k2);
71  result.push_back(NAME_PARAMETER_k3);
72  result.push_back(NAME_PARAMETER_k4);
73  result.push_back(NAME_PARAMETER_VB);
74 
75  return result;
76 }
77 
80 {
81  return NUMBER_OF_PARAMETERS;
82 }
83 
86 {
87  ParamterUnitMapType result;
88 
89  result.insert(std::make_pair(NAME_PARAMETER_K1, UNIT_PARAMETER_K1));
90  result.insert(std::make_pair(NAME_PARAMETER_k2, UNIT_PARAMETER_k2));
91  result.insert(std::make_pair(NAME_PARAMETER_k3, UNIT_PARAMETER_k3));
92  result.insert(std::make_pair(NAME_PARAMETER_k4, UNIT_PARAMETER_k4));
93  result.insert(std::make_pair(NAME_PARAMETER_VB, UNIT_PARAMETER_VB));
94 
95  return result;
96 };
97 
100 {
101  if (this->m_TimeGrid.GetSize() == 0)
102  {
103  itkExceptionMacro("No Time Grid Set! Cannot Calculate Signal");
104  }
105 
106  AterialInputFunctionType aterialInputFunction;
107  aterialInputFunction = GetAterialInputFunction(this->m_TimeGrid);
108 
109 
110  unsigned int timeSteps = this->m_TimeGrid.GetSize();
111 
112  //Model Parameters
113  double k1 = (double)parameters[POSITION_PARAMETER_K1] / 60.0;
114  double k2 = (double)parameters[POSITION_PARAMETER_k2] / 60.0;
115  double k3 = (double)parameters[POSITION_PARAMETER_k3] / 60.0;
116  double k4 = (double)parameters[POSITION_PARAMETER_k4] / 60.0;
117  double VB = parameters[POSITION_PARAMETER_VB];
118 
119 
120 
121  double alpha1 = 0.5 * ((k2 + k3 + k4) - sqrt(square(k2 + k3 + k4) - 4 * k2 * k4));
122  double alpha2 = 0.5 * ((k2 + k3 + k4) + sqrt(square(k2 + k3 + k4) - 4 * k2 * k4));
123 
124  //double lambda1 = -alpha1;
125  //double lambda2 = -alpha2;
127  aterialInputFunction, alpha1);
129  aterialInputFunction, alpha2);
130 
131 
132  //Signal that will be returned by ComputeModelFunction
133  mitk::ModelBase::ModelResultType signal(timeSteps);
134  signal.fill(0.0);
135 
136  mitk::ModelBase::ModelResultType::const_iterator exp1Pos = exp1.begin();
137  mitk::ModelBase::ModelResultType::const_iterator exp2Pos = exp2.begin();
138  AterialInputFunctionType::const_iterator aifPos = aterialInputFunction.begin();
139 
140  for (mitk::ModelBase::ModelResultType::iterator signalPos = signal.begin();
141  signalPos != signal.end(); ++exp1Pos, ++exp2Pos, ++signalPos, ++aifPos)
142  {
143  double Ci = k1 / (alpha2 - alpha1) * ((k4 - alpha1 + k3) * (*exp1Pos) + (alpha2 - k4 - k3) *
144  (*exp2Pos));
145  *signalPos = VB * (*aifPos) + (1 - VB) * Ci;
146  }
147 
148  return signal;
149 
150 }
151 
152 
153 
154 
155 itk::LightObject::Pointer mitk::TwoTissueCompartmentModel::InternalClone() const
156 {
158 
159  newClone->SetTimeGrid(this->m_TimeGrid);
160 
161  return newClone.GetPointer();
162 }
163 
164 void mitk::TwoTissueCompartmentModel::PrintSelf(std::ostream& os, ::itk::Indent indent) const
165 {
166  Superclass::PrintSelf(os, indent);
167 
168 
169 }
170 
171 
172 
ParamterUnitMapType GetParameterUnits() const override
static const unsigned int POSITION_PARAMETER_VB
double square(double a)
ModelTraitsInterface::ParametersType ParametersType
Definition: mitkModelBase.h:59
TimeGridType m_TimeGrid
static const unsigned int POSITION_PARAMETER_k3
ParametersSizeType GetNumberOfParameters() const override
std::string GetModelDisplayName() const override
void PrintSelf(std::ostream &os, ::itk::Indent indent) const override
const AterialInputFunctionType GetAterialInputFunction(TimeGridType currentTimeGrid) const
static const unsigned int POSITION_PARAMETER_k4
ModelResultType ComputeModelfunction(const ParametersType &parameters) const override
static const unsigned int POSITION_PARAMETER_K1
ModelTraitsInterface::ParametersSizeType ParametersSizeType
Definition: mitkModelBase.h:65
ModelTraitsInterface::ModelResultType ModelResultType
Definition: mitkModelBase.h:55
void PrintSelf(std::ostream &os, ::itk::Indent indent) const override
itk::Array< double > AterialInputFunctionType
static const unsigned int NUMBER_OF_PARAMETERS
ModelTraitsInterface::ParameterNamesType ParameterNamesType
Definition: mitkModelBase.h:64
static const unsigned int POSITION_PARAMETER_k2
itk::LightObject::Pointer InternalClone() const override
itk::Array< double > convoluteAIFWithExponential(mitk::ModelBase::TimeGridType timeGrid, mitk::AIFBasedModelBase::AterialInputFunctionType aif, double lambda)
std::map< ParameterNameType, std::string > ParamterUnitMapType
ParameterNamesType GetParameterNames() const override