Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkBeamformingSettings.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 "mitkBeamformingUtils.h"
15 #include "itkMutexLock.h"
16 
18  float speedOfSound,
19  float timeSpacing,
20  float angle,
21  bool isPhotoacousticImage,
22  unsigned int samplesPerLine,
23  unsigned int reconstructionLines,
24  unsigned int* inputDim,
25  float reconstructionDepth,
26  bool useGPU,
27  unsigned int GPUBatchSize,
28  Apodization apod,
29  unsigned int apodizationArraySize,
30  BeamformingAlgorithm algorithm,
31  ProbeGeometry geometry,
32  float probeRadius
33 ) :
34  m_PitchInMeters(pitchInMeters),
35  m_SpeedOfSound(speedOfSound),
36  m_TimeSpacing(timeSpacing),
37  m_Angle(angle),
38  m_IsPhotoacousticImage(isPhotoacousticImage),
39  m_SamplesPerLine(samplesPerLine),
40  m_ReconstructionLines(reconstructionLines),
41  m_ReconstructionDepth(reconstructionDepth),
42  m_UseGPU(useGPU),
43  m_GPUBatchSize(GPUBatchSize),
44  m_Apod(apod),
45  m_ApodizationArraySize(apodizationArraySize),
46  m_Algorithm(algorithm),
47  m_Geometry(geometry),
48  m_ProbeRadius(probeRadius),
49  m_MinMaxLines(nullptr)
50 {
51  if (inputDim == nullptr)
52  {
53  MITK_ERROR << "No input dimension given.";
54  mitkThrow() << "No input dimension given.";
55  }
56 
57  switch (GetApod())
58  {
59  case BeamformingSettings::Apodization::Hann:
61  break;
62  case BeamformingSettings::Apodization::Hamm:
64  break;
65  case BeamformingSettings::Apodization::Box:
66  default:
68  break;
69  }
70  m_InputDim = new unsigned int[3]{ inputDim[0], inputDim[1], inputDim[2] };
72 
75 
76  if (m_Geometry == ProbeGeometry::Concave)
77  {
78  float openingAngle = (m_TransducerElements * m_PitchInMeters) / (probeRadius * 2 * itk::Math::pi) * 2 * itk::Math::pi;
79  m_HorizontalExtent = std::sin(openingAngle / 2.f) * probeRadius * 2.f;
80 
81  float elementAngle = 0;
82 
83  for (unsigned int i = 0; i < m_TransducerElements; ++i)
84  {
85  elementAngle = ((i- m_TransducerElements /2.f) * m_PitchInMeters) / (probeRadius * 2 * itk::Math::pi) * 2 * itk::Math::pi;
86  m_ElementHeights[i] = probeRadius - std::cos(elementAngle) * probeRadius;
87  m_ElementPositions[i] = m_HorizontalExtent/2.f + std::sin(elementAngle) * probeRadius;
88  }
89  }
90  else
91  {
93  for (unsigned int i = 0; i < m_TransducerElements; ++i)
94  {
95  m_ElementHeights[i] = 0;
97  }
98  }
99 }
100 
102 {
103  MITK_INFO << "Destructing beamforming settings...";
104  //Free memory
105  if (m_ApodizationFunction != nullptr)
106  {
107  MITK_INFO << "Deleting apodization function...";
108  delete[] m_ApodizationFunction;
109  MITK_INFO << "Deleting apodization function...[Done]";
110  }
111 
112  if (m_InputDim != nullptr)
113  {
114  MITK_INFO << "Deleting input dim...";
115  delete[] m_InputDim;
116  MITK_INFO << "Deleting input dim...[Done]";
117  }
118  if (m_ElementHeights != nullptr || m_ElementPositions != nullptr)
119  {
120  MITK_INFO << "Deleting element geometry...";
121  if (m_ElementHeights != nullptr)
122  delete[] m_ElementHeights;
123 
124  if (m_ElementPositions != nullptr)
125  delete[] m_ElementPositions;
126  MITK_INFO << "Destructing beamforming settings...[Done]";
127  }
128  if (m_MinMaxLines)
129  delete[] m_MinMaxLines;
130 }
131 
133 {
134  if (!m_MinMaxLines)
136  return m_MinMaxLines;
137 }
static float * BoxFunction(int samples)
Function to create a Box apodization window.
static float * VonHannFunction(int samples)
Pointer holding the Von-Hann apodization window for beamforming.
float m_PitchInMeters
Pitch of the used transducer in [m].
#define MITK_INFO
Definition: mitkLogMacros.h:18
#define MITK_ERROR
Definition: mitkLogMacros.h:20
static unsigned short * MinMaxLines(const mitk::BeamformingSettings::Pointer config)
ProbeGeometry
Available geometries for Probes:
static float * HammFunction(int samples)
Function to create a Hamming apodization window.
#define mitkThrow()
BeamformingAlgorithm
Available beamforming algorithms:
virtual Apodization GetApod() const
const float * m_ApodizationFunction
Sets the amount of image slices in batches when GPU is used.
unsigned int m_TransducerElements
How many transducer elements the used transducer had.
Apodization
Available apodization functions:
ProbeGeometry m_Geometry
Sets the used probe geometry.
BeamformingSettings(float pitchInMeters, float speedOfSound, float timeSpacing, float angle, bool isPhotoacousticImage, unsigned int samplesPerLine, unsigned int reconstructionLines, unsigned int *inputDim, float reconstructionDepth, bool useGPU, unsigned int GPUBatchSize, Apodization apod, unsigned int apodizationArraySize, BeamformingAlgorithm algorithm, ProbeGeometry geometry, float probeRadius)
virtual int GetApodizationArraySize() const
const unsigned int * m_InputDim
Sets the dimensions of the inputImage.