PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkPlusUsImagingParameters.cxx
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 #include "PlusConfigure.h"
9 
10 #include <iterator>
11 
12 //----------------------------------------------------------------------------
13 
15 
16 //----------------------------------------------------------------------------
17 
18 const char* vtkPlusUsImagingParameters::US_XML_ELEMENT_TAG = "UsImagingParameters";
19 const char* vtkPlusUsImagingParameters::KEY_CONTRAST = "Contrast";
20 const char* vtkPlusUsImagingParameters::KEY_DEPTH = "DepthMm";
21 const char* vtkPlusUsImagingParameters::KEY_FOCUS_DEPTH = "FocusDepthPercent";
22 const char* vtkPlusUsImagingParameters::KEY_DYNRANGE = "DynRangeDb";
23 const char* vtkPlusUsImagingParameters::KEY_FREQUENCY = "FrequencyMhz";
24 const char* vtkPlusUsImagingParameters::KEY_GAIN = "GainPercent";
25 const char* vtkPlusUsImagingParameters::KEY_TGC = "TimeGainCompensation";
26 const char* vtkPlusUsImagingParameters::KEY_INTENSITY = "Intensity";
27 const char* vtkPlusUsImagingParameters::KEY_POWER = "PowerDb";
28 const char* vtkPlusUsImagingParameters::KEY_SECTOR = "SectorPercent";
29 const char* vtkPlusUsImagingParameters::KEY_ZOOM = "ZoomFactor";
30 const char* vtkPlusUsImagingParameters::KEY_SOUNDVELOCITY = "SoundVelocity";
31 const char* vtkPlusUsImagingParameters::KEY_VOLTAGE = "Voltage";
32 const char* vtkPlusUsImagingParameters::KEY_IMAGESIZE = "ImageSize";
33 
34 //----------------------------------------------------------------------------
37 {
38  this->Parameters[KEY_FREQUENCY] = ParameterInfo("-1");
39  this->Parameters[KEY_DEPTH] = ParameterInfo("-1");
41  this->Parameters[KEY_SECTOR] = ParameterInfo("-1");
42  this->Parameters[KEY_GAIN] = ParameterInfo("-1");
43  this->Parameters[KEY_TGC] = ParameterInfo("-1 -1 -1");
44  this->Parameters[KEY_INTENSITY] = ParameterInfo("-1");
45  this->Parameters[KEY_CONTRAST] = ParameterInfo("-1");
46  this->Parameters[KEY_POWER] = ParameterInfo("-1");
47  this->Parameters[KEY_DYNRANGE] = ParameterInfo("-1");
48  this->Parameters[KEY_ZOOM] = ParameterInfo("-1");
50  this->Parameters[KEY_VOLTAGE] = ParameterInfo("-1");
51  this->Parameters[KEY_IMAGESIZE] = ParameterInfo("-1 -1 -1");
52 }
53 
54 //----------------------------------------------------------------------------
56 {
57  LOG_TRACE("vtkPlusUsImagingParameters::~vtkPlusUsImagingParameters()");
58 }
59 
60 //----------------------------------------------------------------------------
62 {
63  return this->SetValue<double>(KEY_FREQUENCY, aFrequencyMhz);
64 }
65 
66 //----------------------------------------------------------------------------
68 {
69  return this->GetValue<double>(KEY_FREQUENCY, aFrequencyMhz);
70 }
71 
72 //----------------------------------------------------------------------------
74 {
75  double aValue;
76  this->GetValue<double>(KEY_FREQUENCY, aValue);
77  return aValue;
78 }
79 
80 //----------------------------------------------------------------------------
82 {
83  return this->SetValue<double>(KEY_DEPTH, aDepthMm);
84 }
85 
86 //----------------------------------------------------------------------------
88 {
89  return this->GetValue<double>(KEY_DEPTH, aDepthMm);
90 }
91 
92 //----------------------------------------------------------------------------
94 {
95  double aValue;
96  this->GetValue<double>(KEY_DEPTH, aValue);
97  return aValue;
98 }
99 
100 //----------------------------------------------------------------------------
102 {
103  return this->SetValue<double>(KEY_FOCUS_DEPTH, aFocusDepthPercent);
104 }
105 
106 //----------------------------------------------------------------------------
108 {
109  return this->GetValue<double>(KEY_FOCUS_DEPTH, aFocusDepthPercent);
110 }
111 
112 //----------------------------------------------------------------------------
114 {
115  double aValue;
116  this->GetValue<double>(KEY_FOCUS_DEPTH, aValue);
117  return aValue;
118 }
119 
120 //----------------------------------------------------------------------------
122 {
123  return this->SetValue<double>(KEY_GAIN, aGainPercent);
124 }
125 
126 //----------------------------------------------------------------------------
128 {
129  return this->GetValue<double>(KEY_GAIN, aGainPercent);
130 }
131 
132 //----------------------------------------------------------------------------
134 {
135  double aValue;
136  this->GetValue<double>(KEY_GAIN, aValue);
137  return aValue;
138 }
139 
140 //----------------------------------------------------------------------------
142 {
143  std::stringstream result;
144  std::copy(tgc.begin(), tgc.end(), std::ostream_iterator<double>(result, " "));
145 
146  if (this->Parameters[KEY_TGC].Value != result.str())
147  {
148  // If the value changed, then mark it pending
149  this->Parameters[KEY_TGC].Pending = true;
150  }
151  this->Parameters[KEY_TGC].Value = result.str();
152  this->Parameters[KEY_TGC].Set = true;
153  return PLUS_SUCCESS;
154 }
155 
156 //----------------------------------------------------------------------------
158 {
159  std::vector<double> tgcVec(tgc, tgc + length);
160  return this->SetTimeGainCompensation(tgcVec);
161 }
162 
163 //----------------------------------------------------------------------------
165 {
166  ParameterMapConstIterator keyIt = this->Parameters.find(KEY_TGC);
167  if (keyIt != this->Parameters.end() && keyIt->second.Set == false)
168  {
169  return PLUS_FAIL;
170  }
171  else if (keyIt == this->Parameters.end())
172  {
173  return PLUS_FAIL;
174  }
175 
176  std::stringstream ss;
178  ss.str(it->second.Value);
179  std::vector<double> numbers((std::istream_iterator<double>(ss)), std::istream_iterator<double>());
180  tgc = numbers;
181  return PLUS_SUCCESS;
182 }
183 
184 //----------------------------------------------------------------------------
186 {
187  std::vector<double> vec;
188  this->GetTimeGainCompensation(vec);
189  return vec;
190 }
191 
192 //----------------------------------------------------------------------------
194 {
195  return this->SetValue<double>(KEY_INTENSITY, aIntensity);
196 }
197 
198 //----------------------------------------------------------------------------
200 {
201  return this->GetValue<double>(KEY_INTENSITY, aIntensity);
202 }
203 
204 //----------------------------------------------------------------------------
206 {
207  double aValue;
208  this->GetValue<double>(KEY_INTENSITY, aValue);
209  return aValue;
210 }
211 
212 //----------------------------------------------------------------------------
214 {
215  return this->SetValue<double>(KEY_CONTRAST, aContrast);
216 }
217 
218 //----------------------------------------------------------------------------
220 {
221  return this->GetValue<double>(KEY_CONTRAST, aContrast);
222 }
223 
224 //----------------------------------------------------------------------------
226 {
227  double aValue;
228  this->GetValue<double>(KEY_CONTRAST, aValue);
229  return aValue;
230 }
231 
232 //----------------------------------------------------------------------------
234 {
235  return this->SetValue<double>(KEY_POWER, aPower);
236 }
237 
238 //----------------------------------------------------------------------------
240 {
241  return this->GetValue<double>(KEY_POWER, aPower);
242 }
243 
244 //----------------------------------------------------------------------------
246 {
247  double aValue;
248  this->GetValue<double>(KEY_POWER, aValue);
249  return aValue;
250 }
251 
252 //----------------------------------------------------------------------------
254 {
255  return this->SetValue<double>(KEY_DYNRANGE, aDynRangeDb);
256 }
257 
258 //----------------------------------------------------------------------------
260 {
261  return this->GetValue<double>(KEY_DYNRANGE, aDynRangeDb);
262 }
263 
264 //----------------------------------------------------------------------------
266 {
267  double aValue;
268  this->GetValue<double>(KEY_DYNRANGE, aValue);
269  return aValue;
270 }
271 
272 //----------------------------------------------------------------------------
274 {
275  return this->SetValue<double>(KEY_ZOOM, aZoomFactor);
276 }
277 
278 //----------------------------------------------------------------------------
280 {
281  return this->GetValue<double>(KEY_ZOOM, aZoomFactor);
282 }
283 
284 //----------------------------------------------------------------------------
286 {
287  double aValue;
288  this->GetValue<double>(KEY_ZOOM, aValue);
289  return aValue;
290 }
291 
292 //----------------------------------------------------------------------------
294 {
295  return this->SetValue<double>(KEY_SECTOR, aSectorPercent);
296 }
297 
298 //----------------------------------------------------------------------------
300 {
301  return this->GetValue<double>(KEY_SECTOR, aSectorPercent);
302 }
303 
304 //----------------------------------------------------------------------------
306 {
307  double aValue;
308  this->GetValue<double>(KEY_SECTOR, aValue);
309  return aValue;
310 }
311 
312 //----------------------------------------------------------------------------
314 {
315  return this->SetValue<float>(KEY_SOUNDVELOCITY, aSoundVelocity);
316 }
317 
318 //----------------------------------------------------------------------------
320 {
321  return this->GetValue<float>(KEY_SOUNDVELOCITY, aSoundVelocity);
322 }
323 
324 //----------------------------------------------------------------------------
326 {
327  float aValue;
328  this->GetValue<float>(KEY_SOUNDVELOCITY, aValue);
329  return aValue;
330 }
331 
332 //----------------------------------------------------------------------------
334 {
335  return this->SetValue<float>(KEY_VOLTAGE, aVoltage);
336 }
337 
338 //----------------------------------------------------------------------------
340 {
341  return this->GetValue<float>(KEY_VOLTAGE, aVoltage);
342 }
343 
344 //----------------------------------------------------------------------------
346 {
347  float aValue;
348  this->GetValue<float>(KEY_VOLTAGE, aValue);
349  return aValue;
350 }
351 
352 //----------------------------------------------------------------------------
354 {
355  std::stringstream result;
356  std::copy(imageSize.begin(), imageSize.end(), std::ostream_iterator<double>(result, " "));
357 
358  if (this->Parameters[KEY_IMAGESIZE].Value != result.str())
359  {
360  // If the value changed, then mark it pending
361  this->Parameters[KEY_IMAGESIZE].Pending = true;
362  }
363  this->Parameters[KEY_IMAGESIZE].Value = result.str();
364  this->Parameters[KEY_IMAGESIZE].Set = true;
365 
366  return PLUS_SUCCESS;
367 }
368 
369 //----------------------------------------------------------------------------
370 PlusStatus vtkPlusUsImagingParameters::SetImageSize(unsigned int x, unsigned int y, unsigned int z)
371 {
372  FrameSizeType imageSize = { x, y, z };
373  return this->SetImageSize(imageSize);
374 }
375 
376 //----------------------------------------------------------------------------
378 {
380  if (keyIt != this->Parameters.end() && keyIt->second.Set == false)
381  {
382  return PLUS_FAIL;
383  }
384  else if (keyIt == this->Parameters.end())
385  {
386  return PLUS_FAIL;
387  }
388 
389  std::stringstream ss;
391  ss.str(it->second.Value);
392  std::vector<unsigned int> numbers((std::istream_iterator<unsigned int>(ss)), std::istream_iterator<unsigned int>());
393 
394  imageSize[0] = numbers[0];
395  if (numbers.size() > 1)
396  {
397  imageSize[1] = numbers[1];
398  }
399  if (numbers.size() > 2)
400  {
401  imageSize[2] = numbers[2];
402  }
403  else
404  {
405  imageSize[2] = 1;
406  }
407  return PLUS_SUCCESS;
408 }
409 
410 //----------------------------------------------------------------------------
412 {
413  FrameSizeType imageSize;
414  this->GetImageSize(imageSize);
415  return imageSize;
416 }
This class is used to store a configuration of the imaging parameters of an ultrasound video device....
This class is used as the basis to store a configuration of generic parameters for any device....
igsioStatus PlusStatus
Definition: PlusCommon.h:40
PlusStatus SetContrast(double aContrast)
#define PLUS_FAIL
Definition: PlusCommon.h:43
PlusStatus SetTimeGainCompensation(const std::vector< double > &tgc)
vtkStandardNewMacro(vtkPlusUsImagingParameters)
PlusStatus SetPowerDb(double aPower)
#define PLUS_SUCCESS
Definition: PlusCommon.h:44
PlusStatus SetProbeVoltage(float aVoltage)
ParameterMap::const_iterator ParameterMapConstIterator
PlusStatus SetGainPercent(double aGainPercent)
PlusStatus SetImageSize(const FrameSizeType &imageSize)
PlusStatus SetDynRangeDb(double aDynRangeDb)
PlusStatus SetSectorPercent(double aSectorPercent)
int x
Definition: phidget22.h:4265
std::vector< double > GetTimeGainCompensation() const
PlusStatus SetIntensity(double aIntensity)
PlusStatus SetFrequencyMhz(double aFrequencyMhz)
PlusStatus SetFocusDepthPercent(double aFocusDepthPercent)
Direction vectors of rods y
Definition: algo3.m:15
PlusStatus SetZoomFactor(double aZoomFactor)
PlusStatus SetDepthMm(double aDepthMm)
PlusStatus SetSoundVelocity(float aSoundVelocity)