Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
mitkTwoCompartmentExchangeModelDifferentialEquations.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 mitkTwoCompartmentExchangeModelDifferentialEquations_h
14 #define mitkTwoCompartmentExchangeModelDifferentialEquations_h
15 
17 
18 namespace mitk{
31 {
32 public:
33 
34  typedef std::vector< double > AIFType;
35 
40  {
41  double Ca_t = InterpolateAIFToCurrentTimeStep(t);
42 
43 // dxdt[0] = -(this->FVP + this->PSVP)*x[0] - this->PSVP*x[1]+this->FVP*Ca_t;
44  dxdt[0] = (1/this->vp) * ( this->F*(Ca_t - x[0]) - this->PS*(x[0] - x[1]) );
45  dxdt[1] = (1/this->ve) * this->PS * (x[0] - x[1]);
46 
47  }
48 
49  TwoCompartmentExchangeModelDifferentialEquations() : F(0), PS(0), ve(0), vp(0), m_AIF(0), m_AIFTimeGrid(0)
50  {
51  }
52 
54  void initialize(double Fp, double ps, double fi, double fp)
55  {
56  this->F = Fp;
57  this->PS = ps;
58  this->ve = fi;
59  this->vp = fp;
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 F;
77  double PS;
78  double ve;
79  double vp;
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::TwoCompartmentExchangeModelDifferentialEquations::AIFType
std::vector< double > AIFType
Definition: mitkTwoCompartmentExchangeModelDifferentialEquations.h:34
mitk::NumericTwoCompartmentExchangeModel::state_type
std::vector< double > state_type
Definition: mitkNumericTwoCompartmentExchangeModel.h:54
mitkNumericTwoCompartmentExchangeModel.h
mitk::TwoCompartmentExchangeModelDifferentialEquations::operator()
void operator()(const mitk::NumericTwoCompartmentExchangeModel::state_type &x, mitk::NumericTwoCompartmentExchangeModel::state_type &dxdt, const double t)
Functor for differential equation of Physiological Pharmacokinetic Brix Model Takes current state x =...
Definition: mitkTwoCompartmentExchangeModelDifferentialEquations.h:39
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::TwoCompartmentExchangeModelDifferentialEquations::TwoCompartmentExchangeModelDifferentialEquations
TwoCompartmentExchangeModelDifferentialEquations()
Definition: mitkTwoCompartmentExchangeModelDifferentialEquations.h:49
mitk::TwoCompartmentExchangeModelDifferentialEquations::initialize
void initialize(double Fp, double ps, double fi, double fp)
Initialize class with parameters F/Vp, PS/Vp, fi and fp that are free fit parameters.
Definition: mitkTwoCompartmentExchangeModelDifferentialEquations.h:54
mitk::TwoCompartmentExchangeModelDifferentialEquations::setAIF
void setAIF(AIFType &aif)
Definition: mitkTwoCompartmentExchangeModelDifferentialEquations.h:63
mitk::TwoCompartmentExchangeModelDifferentialEquations
Helper Class for NumericTwoCompartmentExchangeModel: Defines the differential equations (Mass Balance...
Definition: mitkTwoCompartmentExchangeModelDifferentialEquations.h:30
mitk::TwoCompartmentExchangeModelDifferentialEquations::setAIFTimeGrid
void setAIFTimeGrid(AIFType &grid)
Definition: mitkTwoCompartmentExchangeModelDifferentialEquations.h:69