Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkTwoTissueCompartmentModelDifferentialEquations.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 mitkTwoTissueCompartmentModelDifferentialEquations_h
14 #define mitkTwoTissueCompartmentModelDifferentialEquations_h
16 
17 namespace mitk{
33 {
34 public:
35 
36  typedef std::vector< double > AIFType;
37 
42  {
43  double Ca_t = InterpolateAIFToCurrentTimeStep(t);
44 
45  dxdt[0] = this->K1*Ca_t-(this->k2+this->k3)*x[0] + this->k4*x[1];
46  dxdt[1] = this->k3*x[0] - this->k4*x[1];
47  }
48 
49  TwoTissueCompartmentModelDifferentialEquations() : K1(0), k2(0), k3(0), k4(0), m_AIF(0), m_AIFTimeGrid(0)
50  {
51  }
52 
54  void initialize(double k_1, double k_2, double k_3, double k_4)
55  {
56  this->K1 = k_1;
57  this->k2 = k_2;
58  this->k3 = k_3;
59  this->k4 = k_4;
60  }
61 
62 
63  void setAIF(AIFType &aif)
64  {
65  this->m_AIF = aif;
66  }
67 
68 
69  void setAIFTimeGrid(AIFType &grid)
70  {
71  this->m_AIFTimeGrid = grid;
72  }
73 
74 private:
75 
76  double K1;
77  double k2;
78  double k3;
79  double k4;
80 
81  AIFType m_AIF;
82  AIFType m_AIFTimeGrid;
83 
84 
89  double InterpolateAIFToCurrentTimeStep(double t)
90  {
91  double lastValue = m_AIF[0];
92  double lastTime = std::numeric_limits<double>::min();
93 
94  AIFType::const_iterator posITime = m_AIFTimeGrid.begin();
95  AIFType::const_iterator posValue = m_AIF.begin();
96 
97  while(t > *posITime)
98  {
99  lastValue = *posValue;
100  lastTime = *posITime;
101  ++posValue;
102  ++posITime;
103  }
104  double weightLast = 1 - (t - lastTime)/(*posITime - lastTime);
105  double weightNext = 1- (*posITime - t)/(*posITime - lastTime);
106  double result = weightLast * lastValue + weightNext * (*posValue);
107 
108  return result;
109  }
110 
111 };
112 }
113 
114 #endif
mitk::TwoTissueCompartmentModelDifferentialEquations
Helper Class for NumericTwoTissueCompartment Model: Defines the differential equations (Mass Balance ...
Definition: mitkTwoTissueCompartmentModelDifferentialEquations.h:32
mitk::TwoTissueCompartmentModelDifferentialEquations::setAIF
void setAIF(AIFType &aif)
Definition: mitkTwoTissueCompartmentModelDifferentialEquations.h:63
mitk::TwoTissueCompartmentModelDifferentialEquations::AIFType
std::vector< double > AIFType
Definition: mitkTwoTissueCompartmentModelDifferentialEquations.h:36
mitk::TwoTissueCompartmentModelDifferentialEquations::initialize
void initialize(double k_1, double k_2, double k_3, double k_4)
Initialize class with parameters K1, k2, k3 and k4 that are free fit parameters.
Definition: mitkTwoTissueCompartmentModelDifferentialEquations.h:54
mitkNumericTwoTissueCompartmentModel.h
mitk::TwoTissueCompartmentModelDifferentialEquations::setAIFTimeGrid
void setAIFTimeGrid(AIFType &grid)
Definition: mitkTwoTissueCompartmentModelDifferentialEquations.h:69
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::TwoTissueCompartmentModelDifferentialEquations::TwoTissueCompartmentModelDifferentialEquations
TwoTissueCompartmentModelDifferentialEquations()
Definition: mitkTwoTissueCompartmentModelDifferentialEquations.h:49
mitk::TwoTissueCompartmentModelDifferentialEquations::operator()
void operator()(const mitk::NumericTwoTissueCompartmentModel::state_type &x, mitk::NumericTwoTissueCompartmentModel::state_type &dxdt, const double t)
Functor for differential equation of Two Tissue Compartment Model Takes current state x = x(t) and ti...
Definition: mitkTwoTissueCompartmentModelDifferentialEquations.h:41
mitk::NumericTwoTissueCompartmentModel::state_type
std::vector< double > state_type
Definition: mitkNumericTwoTissueCompartmentModel.h:36