Medical Imaging Interaction Toolkit  2018.4.99-1bab67a2
Medical Imaging Interaction Toolkit
mitkConvertToConcentrationViaT1Functor.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 MITKCONVERTTOCONCENTRATIONVIAT1CALCFUNCTOR_H
14 #define MITKCONVERTTOCONCENTRATIONVIAT1CALCFUNCTOR_H
15 
16 #include "itkMath.h"
17 
19 
20 namespace mitk {
21 
22  template <class TInputPixel1, class TInputPixel2, class TInputPixel3, class TOutputpixel>
24  {
25 
26  public:
27  ConvertToConcentrationViaT1CalcFunctor(): m_relaxivity(0.0), m_TR(0.0), m_flipangle(0.0) {};
29 
30  void initialize(double relaxivity, double TR, double flipangle)
31  {
32 
33  m_relaxivity = relaxivity;
34  m_TR = TR;
35  m_flipangle = flipangle;
36  }
37 
39  {
40  return !(*this == other);
41 
42  }
44  {
45  return (this->m_relaxivity == other.m_relaxivity) && (this->m_TR == other.m_TR) && (this->m_flipangle == other.m_flipangle);
46  }
47 
48 
49  inline TOutputpixel operator()( const TInputPixel1 & value, const TInputPixel2 & baseline, const TInputPixel3 & nativeT1)
50  {
51  TOutputpixel concentration(0);
52  double R10, R1;
53  if (baseline !=0 && nativeT1 != 0 && value != 0)
54  {
55  double s = (double) value/baseline;
56  R10 = (double) 1/nativeT1;
57  double tmp1 = log(1-s + s*exp(-R10*m_TR) - exp(-R10*m_TR)* cos(m_flipangle));
58  double tmp2 = (1-s*cos(m_flipangle) + s*exp(-R10*m_TR)*cos(m_flipangle) - exp(-R10*m_TR)* cos(m_flipangle));
59 
60  R1 = (double) -1/m_TR * tmp1/tmp2 ;
61 
62  concentration = (double) (R1 - R10)/ m_relaxivity;
63  }
64  else
65  {
66  concentration = 0;
67  }
68 
69  return concentration;
70  }
71  private:
72  double m_relaxivity;
73  double m_TR;
74  double m_flipangle;
75 
76  };
77 
78 }
79 #endif // MITKCONVERTTOCONCENTRATIONVIAT1CALCFUNCTOR_H
TOutputpixel operator()(const TInputPixel1 &value, const TInputPixel2 &baseline, const TInputPixel3 &nativeT1)
std::string tmp2
#define MITKPHARMACOKINETICS_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
float relaxivity(0)
bool operator!=(const ConvertToConcentrationViaT1CalcFunctor &other) const
US_USE_NAMESPACE std::string tmp1
void initialize(double relaxivity, double TR, double flipangle)
bool operator==(const ConvertToConcentrationViaT1CalcFunctor &other) const