Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkPASlicedVolumeGenerator.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 #include <mitkException.h>
15 
16 mitk::pa::SlicedVolumeGenerator::SlicedVolumeGenerator(int centralYSlice, bool precorrect,
17  Volume::Pointer precorrectionVolume, bool inverse)
18 {
19  m_CentralYSlice = centralYSlice;
20  m_Precorrect = precorrect;
21  m_Inverse = inverse;
22  m_PrecorrectionVolume = nullptr;
23 
24  if (m_Precorrect)
25  {
26  m_PrecorrectionVolume = precorrectionVolume;
27  }
28 }
29 
31 {
32  m_CentralYSlice = -1;
33  m_Precorrect = false;
34  m_PrecorrectionVolume = nullptr;
35 }
36 
38  ComposedVolume::Pointer composedVolume)
39 {
40  int fluenceComponents = composedVolume->GetNumberOfFluenceComponents();
41 
42  int xDim = composedVolume->GetGroundTruthVolume()->GetAbsorptionVolume()->GetXDim();
43  int zDim = composedVolume->GetGroundTruthVolume()->GetAbsorptionVolume()->GetZDim();
44 
45  auto* imageArray = new double[xDim*zDim*fluenceComponents];
46 
47  for (int fluenceComponentIdx = 0; fluenceComponentIdx < fluenceComponents; fluenceComponentIdx++)
48  for (int z = 0; z < zDim; z++)
49  for (int x = 0; x < xDim; x++)
50  {
51  int index = z * xDim * fluenceComponents + x * fluenceComponents + fluenceComponentIdx;
52  imageArray[index] = composedVolume->GetFluenceValue(fluenceComponentIdx, x, m_CentralYSlice, z);
53 
54  if (m_Precorrect)
55  {
56  imageArray[index] = imageArray[index] / m_PrecorrectionVolume->GetData(x, m_CentralYSlice, z);
57  }
58 
59  if (m_Inverse)
60  {
61  if (std::abs(imageArray[index] - 0) >= mitk::eps)
62  imageArray[index] = 1 / imageArray[index];
63  else
64  imageArray[index] = INFINITY;
65  }
66  }
67 
68  return mitk::pa::Volume::New(imageArray, xDim, fluenceComponents, zDim, composedVolume->GetGroundTruthVolume()->GetSpacing());
69 }
70 
72  ComposedVolume::Pointer composedVolume)
73 {
74  int fluenceComponents = composedVolume->GetNumberOfFluenceComponents();
75 
76  int xDim = composedVolume->GetGroundTruthVolume()->GetAbsorptionVolume()->GetXDim();
77  int zDim = composedVolume->GetGroundTruthVolume()->GetAbsorptionVolume()->GetZDim();
78 
79  auto* imageArray = new double[xDim*zDim*fluenceComponents];
80 
81  for (int fluenceComponentIdx = 0; fluenceComponentIdx < fluenceComponents; fluenceComponentIdx++)
82  for (int z = 0; z < zDim; z++)
83  for (int x = 0; x < xDim; x++)
84  {
85  int y = m_CentralYSlice + composedVolume->GetYOffsetForFluenceComponentInPixels(fluenceComponentIdx);
86  imageArray[z * xDim * fluenceComponents + x * fluenceComponents + fluenceComponentIdx] =
87  composedVolume->GetFluenceValue(fluenceComponentIdx, x, m_CentralYSlice, z)
88  * composedVolume->GetGroundTruthVolume()->GetAbsorptionVolume()->GetData(x, y, z);
89  }
90 
91  return mitk::pa::Volume::New(imageArray, xDim, fluenceComponents, zDim, composedVolume->GetGroundTruthVolume()->GetSpacing());
92 }
93 
95  ComposedVolume::Pointer composedVolume)
96 {
97  int fluenceComponents = composedVolume->GetNumberOfFluenceComponents();
98 
99  int xDim = composedVolume->GetGroundTruthVolume()->GetAbsorptionVolume()->GetXDim();
100  int zDim = composedVolume->GetGroundTruthVolume()->GetAbsorptionVolume()->GetZDim();
101 
102  auto* imageArray = new double[xDim*zDim*fluenceComponents];
103 
104  for (int fluenceComponentIdx = 0; fluenceComponentIdx < fluenceComponents; fluenceComponentIdx++)
105  for (int z = 0; z < zDim; z++)
106  for (int x = 0; x < xDim; x++)
107  {
108  int y = m_CentralYSlice + composedVolume->GetYOffsetForFluenceComponentInPixels(fluenceComponentIdx);
109  imageArray[z * xDim * fluenceComponents + x * fluenceComponents + fluenceComponentIdx] =
110  composedVolume->GetGroundTruthVolume()->GetAbsorptionVolume()->GetData(x, y, z);
111  }
112 
113  return mitk::pa::Volume::New(imageArray, xDim, fluenceComponents, zDim, composedVolume->GetGroundTruthVolume()->GetSpacing());
114 }
mitk::pa::Volume::Pointer GetSlicedGroundTruthImageFromComposedVolume(mitk::pa::ComposedVolume::Pointer composedVolume)
SlicedVolumeGenerator(int centralYSlice, bool precorrect, mitk::pa::Volume::Pointer precorrectionVolume, bool inverse)
mitk::pa::Volume::Pointer GetSlicedSignalImageFromComposedVolume(mitk::pa::ComposedVolume::Pointer composedVolume)
MITKCORE_EXPORT const ScalarType eps
mitk::pa::Volume::Pointer GetSlicedFluenceImageFromComposedVolume(mitk::pa::ComposedVolume::Pointer composedVolume)
mitk::pa::Volume::Pointer m_PrecorrectionVolume
static Volume::Pointer New(double *data, unsigned int xDim, unsigned int yDim, unsigned int zDim, double spacing)
returns smartpointer reference to a new instance of this objects. The given data array will be freed ...