Medical Imaging Interaction Toolkit  2024.06.99-692c34ce
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 mitkConvertToConcentrationViaT1Functor_h
14 #define mitkConvertToConcentrationViaT1Functor_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), m_flipanglePDW(0.0) {};
29 
30  void initialize(double relaxivity, double TR, double flipangle, double flipanglePDW)
31  {
32  m_relaxivity = relaxivity;
33  m_TR = TR;
34  m_flipangle = flipangle;
35  m_flipanglePDW = flipanglePDW;
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) && (this->m_flipanglePDW == other.m_flipanglePDW);
46  }
47 
48 
49  inline TOutputpixel operator()( const TInputPixel1 & value, const TInputPixel2 & baseline, const TInputPixel3 & pdw)
50  {
51  TOutputpixel concentration(0.0);
52  if (baseline != 0 && pdw != 0 && value != 0)
53  {
54  // calculate signal scaling factor S0 and pre-contrast T1 relaxation time T10
55  const double a = pdw * sin(m_flipangle) / (baseline * sin(m_flipanglePDW));
56  const double b = (a - 1.0) / (a * cos(m_flipanglePDW) - cos(m_flipangle));
57  const double T10 = static_cast<double>((-1.0) * m_TR / log(b));
58  const double lambda = exp((-1.0) * m_TR / T10);
59  const double S0 = pdw * (1.0-lambda * cos(m_flipanglePDW)) / ((1.0 - lambda) * sin(m_flipanglePDW));
60 
61  // calculate T1
62  const double c = (value - S0 * sin(m_flipangle)) / (value * cos(m_flipangle) - S0 * sin(m_flipangle));
63  const double T1 = static_cast<double>((-1.0) * m_TR / log(c));
64 
65  //calculate concentration
66  concentration = static_cast<double>((1.0 / T1 - 1.0 / T10) / (m_relaxivity/1000.0));
67  }
68  else
69  {
70  concentration = 0.0;
71  }
72 
73  return concentration;
74  }
75  private:
76  double m_relaxivity;
77  double m_TR;
78  double m_flipangle;
79  double m_flipanglePDW;
80  };
81 
82 }
83 #endif
mitk::ConvertToConcentrationViaT1CalcFunctor::operator==
bool operator==(const ConvertToConcentrationViaT1CalcFunctor &other) const
Definition: mitkConvertToConcentrationViaT1Functor.h:43
MITKPHARMACOKINETICS_EXPORT
#define MITKPHARMACOKINETICS_EXPORT
Definition: MitkPharmacokineticsExports.h:15
MitkPharmacokineticsExports.h
mitk::ConvertToConcentrationViaT1CalcFunctor::operator()
TOutputpixel operator()(const TInputPixel1 &value, const TInputPixel2 &baseline, const TInputPixel3 &pdw)
Definition: mitkConvertToConcentrationViaT1Functor.h:49
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::ConvertToConcentrationViaT1CalcFunctor::~ConvertToConcentrationViaT1CalcFunctor
~ConvertToConcentrationViaT1CalcFunctor()
Definition: mitkConvertToConcentrationViaT1Functor.h:28
mitk::ConvertToConcentrationViaT1CalcFunctor::initialize
void initialize(double relaxivity, double TR, double flipangle, double flipanglePDW)
Definition: mitkConvertToConcentrationViaT1Functor.h:30
mitk::ConvertToConcentrationViaT1CalcFunctor::ConvertToConcentrationViaT1CalcFunctor
ConvertToConcentrationViaT1CalcFunctor()
Definition: mitkConvertToConcentrationViaT1Functor.h:27
mitk::ConvertToConcentrationViaT1CalcFunctor
Definition: mitkConvertToConcentrationViaT1Functor.h:23
mitk::ConvertToConcentrationViaT1CalcFunctor::operator!=
bool operator!=(const ConvertToConcentrationViaT1CalcFunctor &other) const
Definition: mitkConvertToConcentrationViaT1Functor.h:38