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