Medical Imaging Interaction Toolkit  2018.4.99-1bab67a2
Medical Imaging Interaction Toolkit
mitkExtendedToftsModel.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 "mitkExtendedToftsModel.h"
14 #include "mitkConvolutionHelper.h"
15 #include <vnl/algo/vnl_fft_1d.h>
16 #include <fstream>
17 
18 const std::string mitk::ExtendedToftsModel::MODEL_DISPLAY_NAME = "Extended Tofts Model";
19 
20 const std::string mitk::ExtendedToftsModel::NAME_PARAMETER_Ktrans = "KTrans";
21 const std::string mitk::ExtendedToftsModel::NAME_PARAMETER_ve = "ve";
22 const std::string mitk::ExtendedToftsModel::NAME_PARAMETER_vp = "vp";
23 
24 const std::string mitk::ExtendedToftsModel::UNIT_PARAMETER_Ktrans = "ml/min/100ml";
25 const std::string mitk::ExtendedToftsModel::UNIT_PARAMETER_ve = "ml/ml";
26 const std::string mitk::ExtendedToftsModel::UNIT_PARAMETER_vp = "ml/ml";
27 
31 
33 
35 {
36  return MODEL_DISPLAY_NAME;
37 };
38 
40 {
41  return "Perfusion.MR";
42 };
43 
45 {
46 
47 }
48 
50 {
51 
52 }
53 
55 {
56  ParameterNamesType result;
57 
58  result.push_back(NAME_PARAMETER_Ktrans);
59  result.push_back(NAME_PARAMETER_ve);
60  result.push_back(NAME_PARAMETER_vp);
61 
62  return result;
63 }
64 
66 const
67 {
68  return NUMBER_OF_PARAMETERS;
69 }
70 
73 {
74  ParamterUnitMapType result;
75 
76  result.insert(std::make_pair(NAME_PARAMETER_Ktrans, UNIT_PARAMETER_Ktrans));
77  result.insert(std::make_pair(NAME_PARAMETER_vp, UNIT_PARAMETER_vp));
78  result.insert(std::make_pair(NAME_PARAMETER_ve, UNIT_PARAMETER_ve));
79 
80  return result;
81 };
82 
83 
84 
87 {
88  ParameterNamesType result;
89  result.push_back("kep");
90  return result;
91 };
92 
95 {
96  return 1;
97 };
98 
100 {
101  ParamterUnitMapType result;
102 
103  result.insert(std::make_pair("kep", "1/min"));
104 
105  return result;
106 };
107 
109  const ParametersType& parameters) const
110 {
111  if (this->m_TimeGrid.GetSize() == 0)
112  {
113  itkExceptionMacro("No Time Grid Set! Cannot Calculate Signal");
114  }
115 
116  AterialInputFunctionType aterialInputFunction;
117  aterialInputFunction = GetAterialInputFunction(this->m_TimeGrid);
118 
119 
120 
121  unsigned int timeSteps = this->m_TimeGrid.GetSize();
122 
123  //Model Parameters
124  double ktrans = parameters[POSITION_PARAMETER_Ktrans] / 6000.0;
125  double ve = parameters[POSITION_PARAMETER_ve];
126  double vp = parameters[POSITION_PARAMETER_vp];
127 
128 
129  double lambda = ktrans / ve;
130 
132  aterialInputFunction, lambda);
133 
134  //Signal that will be returned by ComputeModelFunction
135  mitk::ModelBase::ModelResultType signal(timeSteps);
136  signal.fill(0.0);
137 
138  mitk::ModelBase::ModelResultType::iterator signalPos = signal.begin();
139  mitk::ModelBase::ModelResultType::const_iterator res = convolution.begin();
140 
141 
142  for (AterialInputFunctionType::iterator Cp = aterialInputFunction.begin();
143  Cp != aterialInputFunction.end(); ++res, ++signalPos, ++Cp)
144  {
145  *signalPos = (*Cp) * vp + ktrans * (*res);
146  }
147 
148  return signal;
149 
150 }
151 
152 
154  const mitk::ModelBase::ParametersType& parameters) const
155 {
157  double kep = parameters[POSITION_PARAMETER_Ktrans] / parameters[POSITION_PARAMETER_ve];
158  result.insert(std::make_pair("kep", kep));
159  return result;
160 };
161 
162 itk::LightObject::Pointer mitk::ExtendedToftsModel::InternalClone() const
163 {
165 
166  newClone->SetTimeGrid(this->m_TimeGrid);
167 
168  return newClone.GetPointer();
169 };
170 
171 void mitk::ExtendedToftsModel::PrintSelf(std::ostream& os, ::itk::Indent indent) const
172 {
173  Superclass::PrintSelf(os, indent);
174 
175 
176 };
177 
void PrintSelf(std::ostream &os, ::itk::Indent indent) const override
static const std::string UNIT_PARAMETER_ve
static const std::string NAME_PARAMETER_Ktrans
ModelTraitsInterface::ParametersType ParametersType
Definition: mitkModelBase.h:59
TimeGridType m_TimeGrid
Helper for itk implementation of vnl fourier transformation This namespace provides functions for the...
static const unsigned int POSITION_PARAMETER_ve
static const std::string UNIT_PARAMETER_vp
void PrintSelf(std::ostream &os, ::itk::Indent indent) const override
std::string GetModelDisplayName() const override
DerivedParameterMapType ComputeDerivedParameters(const mitk::ModelBase::ParametersType &parameters) const override
static Pointer New()
static const unsigned int NUMBER_OF_PARAMETERS
const AterialInputFunctionType GetAterialInputFunction(TimeGridType currentTimeGrid) const
ParametersSizeType GetNumberOfDerivedParameters() const override
ModelResultType ComputeModelfunction(const ParametersType &parameters) const override
ModelTraitsInterface::ParametersSizeType ParametersSizeType
Definition: mitkModelBase.h:65
static const std::string NAME_PARAMETER_ve
static const std::string UNIT_PARAMETER_Ktrans
static const std::string MODEL_DISPLAY_NAME
std::map< ParameterNameType, DerivedParameterValueType > DerivedParameterMapType
Definition: mitkModelBase.h:75
ModelTraitsInterface::ModelResultType ModelResultType
Definition: mitkModelBase.h:55
std::string GetModelType() const override
itk::Array< double > AterialInputFunctionType
static const unsigned int POSITION_PARAMETER_Ktrans
ParameterNamesType GetParameterNames() const override
ModelTraitsInterface::ParameterNamesType ParameterNamesType
Definition: mitkModelBase.h:64
ParamterUnitMapType GetParameterUnits() const override
itk::LightObject::Pointer InternalClone() const override
ParametersSizeType GetNumberOfParameters() const override
static const unsigned int POSITION_PARAMETER_vp
ParamterUnitMapType GetDerivedParameterUnits() const override
itk::Array< double > convoluteAIFWithExponential(mitk::ModelBase::TimeGridType timeGrid, mitk::AIFBasedModelBase::AterialInputFunctionType aif, double lambda)
static const std::string NAME_PARAMETER_vp
std::map< ParameterNameType, std::string > ParamterUnitMapType
ParameterNamesType GetDerivedParameterNames() const override