Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkPAPropertyCalculator.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 
14 // us
15 #include <usModule.h>
16 #include <usModuleResource.h>
17 #include <usGetModuleContext.h>
18 #include <usModuleContext.h>
19 #include <usModuleResourceStream.h>
20 
23  TissueType tissueType, int wavelength, double bloodOxygenInFraction)
24 {
25  Properties returnValue;
26 
27  if (!m_Valid)
28  {
29  mitkThrow() << "PhotoacousticPropertyGenerator was not loaded properly.";
30  return returnValue;
31  }
32 
33  double bloodOxygenation = bloodOxygenInFraction;
34  double bloodVolumeFraction;
35  double waterVolumeFraction;
36  double fatVolumeFraction;
37  double melanosomesVolumeFraction;
38  double musp500;
39  double fray;
40  double bmie;
41  double g;
42 
43  switch (tissueType)
44  {
45  case AIR:
46  returnValue.mua = 1e-4;
47  returnValue.mus = 1.0;
48  returnValue.g = 1.0;
49  return returnValue;
50  case BLOOD:
51  bloodVolumeFraction = 1.0;
52  waterVolumeFraction = 0.95;
53  fatVolumeFraction = 0.02;
54  melanosomesVolumeFraction = 0;
55  musp500 = 10;
56  fray = 0;
57  bmie = 1;
58  g = 0.9;
59  break;
60  case EPIDERMIS:
61  bloodVolumeFraction = 0;
62  bloodOxygenation = 0;
63  waterVolumeFraction = 0.75;
64  fatVolumeFraction = 0.01;
65  melanosomesVolumeFraction = 0.02;
66  musp500 = 40;
67  fray = 0;
68  bmie = 1;
69  g = 0.9;
70  break;
71  case FAT:
72  bloodVolumeFraction = 0.01;
73  bloodOxygenation = 0.75;
74  waterVolumeFraction = 0.5;
75  fatVolumeFraction = 0.6;
76  melanosomesVolumeFraction = 0;
77  musp500 = 17.47;
78  fray = 0.2;
79  bmie = 0.5;
80  g = 0.9;
81  break;
82  case STANDARD_TISSUE:
83  default:
84  bloodVolumeFraction = 0.02;
85  bloodOxygenation = 0.75;
86  waterVolumeFraction = 0.8;
87  fatVolumeFraction = 0.05;
88  melanosomesVolumeFraction = 0;
89  musp500 = 25;
90  fray = 0.25;
91  bmie = 1;
92  g = 0.9;
93  break;
94  }
95 
96  // We want the reduced scattering coefficient directly.
97  double musp = musp500 * (fray * pow(wavelength / 500.0, -4.0) + ((1 - fray) * pow(wavelength / 500.0, -bmie)));
98  returnValue.mus = musp;
99  returnValue.mus = 15;//musp;
100 
101  double mua = bloodVolumeFraction*bloodOxygenation*m_SpectralLibMap[ChromophoreType::OXYGENATED][wavelength] +
102  bloodVolumeFraction*(1 - bloodOxygenation)*m_SpectralLibMap[ChromophoreType::DEOXYGENATED][wavelength] +
103  waterVolumeFraction*m_SpectralLibMap[ChromophoreType::WATER][wavelength] +
104  fatVolumeFraction*m_SpectralLibMap[ChromophoreType::FATTY][wavelength] +
105  melanosomesVolumeFraction*m_SpectralLibMap[ChromophoreType::MELANIN][wavelength];
106 
107  returnValue.mua = mua;
108 
109  returnValue.g = g;
110 
111  return returnValue;
112 }
113 
115 {
116  us::ModuleResource resource = us::GetModuleContext()->GetModule()->GetResource("spectralLIB.dat");
117 
118  if (resource.IsValid())
119  {
120  us::ModuleResourceStream resourceStream(resource);
121  std::string line;
122  int wavelength = 300;
123  int counter = 0;
124  while (std::getline(resourceStream, line, '\t'))
125  {
126  int currentLineIdx = counter % 6;
127  if (currentLineIdx == 0)
128  wavelength = std::stoi(line);
129  else
130  {
131  std::istringstream lineStream(line);
132  double tempDouble;
133  lineStream >> tempDouble;
134  m_SpectralLibMap[currentLineIdx][wavelength] = tempDouble;
135  }
136  ++counter;
137  }
138  }
139  else
140  {
141  m_Valid = false;
142  }
143 
144  m_Valid = true;
145 }
146 
148 {
149  m_SpectralLibMap.clear();
150  m_Valid = false;
151 }
152 
154  ChromophoreType ChromophoreType, int wavelength)
155 {
156  return m_SpectralLibMap[ChromophoreType][wavelength];
157 }
static char * line
Definition: svm.cpp:2870
#define mitkThrow()
Module * GetModule() const
double GetAbsorptionForWavelength(ChromophoreType chromophoreType, int wavelength)
std::map< int, std::map< int, double > > m_SpectralLibMap
Properties CalculatePropertyForSpecificWavelength(TissueType tissueType, int wavelength, double oxygenSaturatonInFraction=0)
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.