-
Notifications
You must be signed in to change notification settings - Fork 89
/
Scanner.inl
583 lines (490 loc) · 11.7 KB
/
Scanner.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
//
//
/*
Copyright (C) 2000 PARAPET partners
Copyright (C) 2000- 2007, Hammersmith Imanet Ltd
Copyright (C) 2016, 2021 University College London
Copyright 2017 ETH Zurich, Institute of Particle Physics and Astrophysics
This file is part of STIR.
SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
See STIR/LICENSE.txt for details
*/
/*!
\file
\ingroup buildblock
\brief implementation of inline functions of class Scanner
\author Nikos Efthimiou
\author Sanida Mustafovic
\author Kris Thielemans
\author Long Zhang (set*() functions)
\author PARAPET project
\author Parisa Khateri
*/
#include "stir/error.h"
#include "stir/Succeeded.h"
START_NAMESPACE_STIR
bool
Scanner::operator!=(const Scanner& scanner) const
{
return !(*this == scanner);
}
Scanner::Type
Scanner::get_type() const
{
return type;
}
int
Scanner::get_num_rings() const
{
return num_rings;
}
int
Scanner::get_num_detectors_per_ring() const
{
return num_detectors_per_ring;
}
int
Scanner::get_max_num_non_arccorrected_bins() const
{
return max_num_non_arccorrected_bins;
}
int
Scanner::get_max_num_views() const
{
return get_num_detectors_per_ring() / 2;
}
int
Scanner::get_default_num_arccorrected_bins() const
{
return default_num_arccorrected_bins;
}
float
Scanner::get_inner_ring_radius() const
{
return inner_ring_radius;
}
float
Scanner::get_max_FOV_radius() const
{
return max_FOV_radius;
}
float
Scanner::get_average_depth_of_interaction() const
{
return average_depth_of_interaction;
}
float
Scanner::get_effective_ring_radius() const
{
return inner_ring_radius + average_depth_of_interaction;
}
float
Scanner::get_ring_spacing() const
{
return ring_spacing;
}
float
Scanner::get_default_bin_size() const
{
return bin_size;
}
float
Scanner::get_intrinsic_azimuthal_tilt() const
{
#ifdef STIR_LEGACY_IGNORE_VIEW_OFFSET
return 0.F;
#else
return intrinsic_tilt;
#endif
}
int
Scanner::get_num_transaxial_blocks_per_bucket() const
{
return num_transaxial_blocks_per_bucket;
}
int
Scanner::get_num_axial_blocks_per_bucket() const
{
return num_axial_blocks_per_bucket;
}
int
Scanner::get_num_axial_crystals_per_block() const
{
return num_axial_crystals_per_block;
}
int
Scanner::get_num_transaxial_crystals_per_block() const
{
return num_transaxial_crystals_per_block;
}
int
Scanner::get_num_axial_crystals_per_bucket() const
{
return get_num_axial_blocks_per_bucket() * get_num_axial_crystals_per_block();
}
int
Scanner::get_num_transaxial_crystals_per_bucket() const
{
return get_num_transaxial_blocks_per_bucket() * get_num_transaxial_crystals_per_block();
}
int
Scanner::get_num_detector_layers() const
{
return num_detector_layers;
}
int
Scanner::get_num_axial_blocks() const
{
// when using virtual crystals between blocks, there won't be one at the end, so we
// need to take this into account.
return (num_rings + get_num_virtual_axial_crystals_per_block()) / num_axial_crystals_per_block;
}
int
Scanner::get_num_transaxial_blocks() const
{
return num_detectors_per_ring / num_transaxial_crystals_per_block;
}
int
Scanner::get_num_axial_buckets() const
{
return get_num_axial_blocks() / num_axial_blocks_per_bucket;
}
int
Scanner::get_num_transaxial_buckets() const
{
return get_num_transaxial_blocks() / num_transaxial_blocks_per_bucket;
}
int
Scanner::get_num_axial_crystals_per_singles_unit() const
{
return num_axial_crystals_per_singles_unit;
}
int
Scanner::get_num_transaxial_crystals_per_singles_unit() const
{
return num_transaxial_crystals_per_singles_unit;
}
int
Scanner::get_num_axial_singles_units() const
{
if (num_axial_crystals_per_singles_unit == 0)
{
return 0;
}
else
{
return (num_rings + get_num_virtual_axial_crystals_per_block()) / num_axial_crystals_per_singles_unit;
}
}
int
Scanner::get_num_transaxial_singles_units() const
{
if (num_transaxial_crystals_per_singles_unit == 0)
{
return 0;
}
else
{
return num_detectors_per_ring / num_transaxial_crystals_per_singles_unit;
}
}
int
Scanner::get_num_singles_units() const
{
// TODO Accomodate more complex (multi-layer) geometries.
return get_num_axial_singles_units() * get_num_transaxial_singles_units();
}
float
Scanner::get_energy_resolution() const
{
return energy_resolution;
}
float
Scanner::get_reference_energy() const
{
return reference_energy;
}
int
Scanner::get_max_num_timing_poss() const
{
return max_num_of_timing_poss;
}
float
Scanner::get_size_of_timing_pos() const
{
return size_timing_pos;
}
float
Scanner::get_timing_resolution() const
{
return timing_resolution;
}
bool
Scanner::is_tof_ready() const
{
return (max_num_of_timing_poss > 0 && size_timing_pos > 0.0f && timing_resolution > 0.0f);
}
std::string
Scanner::get_scanner_geometry() const
{
return scanner_geometry;
}
float
Scanner::get_axial_crystal_spacing() const
{
return axial_crystal_spacing;
}
float
Scanner::get_transaxial_crystal_spacing() const
{
return transaxial_crystal_spacing;
}
float
Scanner::get_transaxial_block_spacing() const
{
return transaxial_block_spacing;
}
float
Scanner::get_axial_block_spacing() const
{
return axial_block_spacing;
}
std::string
Scanner::get_crystal_map_file_name() const
{
return crystal_map_file_name;
}
//************************ set ******************************8
void
Scanner::set_type(const Type& new_type)
{
type = new_type;
_already_setup = false;
}
void
Scanner::set_num_rings(const int& new_num)
{
num_rings = new_num;
_already_setup = false;
}
void
Scanner::set_num_detectors_per_ring(const int& new_num)
{
num_detectors_per_ring = new_num;
_already_setup = false;
}
void
Scanner::set_max_num_non_arccorrected_bins(const int& new_num)
{
max_num_non_arccorrected_bins = new_num;
_already_setup = false;
}
void
Scanner::set_default_num_arccorrected_bins(const int& new_num)
{
default_num_arccorrected_bins = new_num;
_already_setup = false;
}
void
Scanner::set_inner_ring_radius(const float& new_radius)
{
inner_ring_radius = new_radius;
_already_setup = false;
}
void
Scanner::set_average_depth_of_interaction(const float& new_depth_of_interaction)
{
average_depth_of_interaction = new_depth_of_interaction;
_already_setup = false;
}
bool
Scanner::has_energy_information() const
{
return (energy_resolution <= 0.0 || reference_energy <= 0.0) ? false : true;
}
void
Scanner::set_ring_spacing(const float& new_spacing)
{
ring_spacing = new_spacing;
}
void
Scanner::set_default_bin_size(const float& new_size)
{
bin_size = new_size;
_already_setup = false;
}
void
Scanner::set_intrinsic_azimuthal_tilt(const float new_tilt)
{
intrinsic_tilt = new_tilt;
_already_setup = false;
}
void
Scanner::set_num_transaxial_blocks_per_bucket(const int& new_num)
{
num_transaxial_blocks_per_bucket = new_num;
_already_setup = false;
}
void
Scanner::set_num_axial_blocks_per_bucket(const int& new_num)
{
num_axial_blocks_per_bucket = new_num;
_already_setup = false;
}
void
Scanner::set_num_detector_layers(const int& new_num)
{
num_detector_layers = new_num;
_already_setup = false;
}
void
Scanner::set_num_axial_crystals_per_block(const int& new_num)
{
num_axial_crystals_per_block = new_num;
_already_setup = false;
}
void
Scanner::set_num_transaxial_crystals_per_block(const int& new_num)
{
num_transaxial_crystals_per_block = new_num;
_already_setup = false;
}
void
Scanner::set_num_axial_crystals_per_singles_unit(const int& new_num)
{
num_axial_crystals_per_singles_unit = new_num;
_already_setup = false;
}
void
Scanner::set_num_transaxial_crystals_per_singles_unit(const int& new_num)
{
num_transaxial_crystals_per_singles_unit = new_num;
_already_setup = false;
}
void
Scanner::set_energy_resolution(const float new_num)
{
energy_resolution = new_num;
_already_setup = false;
}
void
Scanner::set_reference_energy(const float new_num)
{
reference_energy = new_num;
_already_setup = false;
}
void
Scanner::set_axial_crystal_spacing(const float& new_spacing)
{
axial_crystal_spacing = new_spacing;
_already_setup = false;
}
void
Scanner::set_transaxial_crystal_spacing(const float& new_spacing)
{
transaxial_crystal_spacing = new_spacing;
_already_setup = false;
}
void
Scanner::set_transaxial_block_spacing(const float& new_spacing)
{
transaxial_block_spacing = new_spacing;
_already_setup = false;
}
void
Scanner::set_axial_block_spacing(const float& new_spacing)
{
axial_block_spacing = new_spacing;
_already_setup = false;
}
void
Scanner::set_crystal_map_file_name(const std::string& new_crystal_map_file_name)
{
crystal_map_file_name = new_crystal_map_file_name;
_already_setup = false;
}
void
Scanner::set_max_num_timing_poss(const int new_num)
{
max_num_of_timing_poss = new_num;
_already_setup = false;
}
void
Scanner::set_size_of_timing_poss(const float new_num)
{
size_timing_pos = new_num;
_already_setup = false;
}
void
Scanner::set_timing_resolution(const float new_num_in_ps)
{
timing_resolution = new_num_in_ps;
_already_setup = false;
}
/******** Calculate singles bin index from detection position *********/
int
Scanner::get_singles_bin_index(int axial_index, int transaxial_index) const
{
// TODO: Accomodate more complex geometry.
return (transaxial_index + (axial_index * get_num_transaxial_singles_units()));
}
int
Scanner::get_singles_bin_index(const DetectionPosition<>& det_pos) const
{
// TODO: Accomodate more complex geometry.
int axial_index = det_pos.axial_coord() / get_num_axial_crystals_per_singles_unit();
int transaxial_index = det_pos.tangential_coord() / get_num_transaxial_crystals_per_singles_unit();
// return(transaxial_index + (axial_index * get_num_transaxial_singles_units()));
return (get_singles_bin_index(axial_index, transaxial_index));
}
// Get the axial singles bin coordinate from a singles bin.
int
Scanner::get_axial_singles_unit(int singles_bin_index) const
{
// TODO: Accomodate more complex geometry.
return (singles_bin_index / get_num_transaxial_singles_units());
}
// Get the transaxial singles bin coordinate from a singles bin.
int
Scanner::get_transaxial_singles_unit(int singles_bin_index) const
{
// TODO: Accomodate more complex geometry.
return (singles_bin_index % get_num_transaxial_singles_units());
}
// For retrieving the coordinates / detector, ring id from the scanner
stir::DetectionPosition<>
Scanner::get_det_pos_for_index(const stir::DetectionPosition<>& det_pos) const
{
if (!detector_map_sptr)
stir::error("Scanner: detector_map not defined. Did you run set_up()?");
return detector_map_sptr->get_det_pos_for_index(det_pos);
}
stir::CartesianCoordinate3D<float>
Scanner::get_coordinate_for_det_pos(const stir::DetectionPosition<>& det_pos) const
{
if (!_already_setup)
stir::error("Scanner: you forgot to call set_up().");
if (!detector_map_sptr)
stir::error("Scanner: detector_map not defined. Did you run set_up()?");
return detector_map_sptr->get_coordinate_for_det_pos(det_pos);
}
stir::CartesianCoordinate3D<float>
Scanner::get_coordinate_for_index(const stir::DetectionPosition<>& index) const
{
if (!_already_setup)
stir::error("Scanner: you forgot to call set_up().");
if (!detector_map_sptr)
stir::error("Scanner: detector_map not defined. Did you run set_up()?");
return detector_map_sptr->get_coordinate_for_index(index);
}
Succeeded
Scanner::find_detection_position_given_cartesian_coordinate(DetectionPosition<>& det_pos,
const CartesianCoordinate3D<float>& cart_coord) const
{
if (!_already_setup)
stir::error("Scanner: you forgot to call set_up().");
if (!detector_map_sptr)
stir::error("Scanner: detector_map not defined. Did you run set_up()?");
return detector_map_sptr->find_detection_position_given_cartesian_coordinate(det_pos, cart_coord);
}
END_NAMESPACE_STIR