STIR 6.4.0
ProjDataInfo.inl
Go to the documentation of this file.
1//
2//
3/*
4 Copyright (C) 2000 PARAPET partners
5 Copyright (C) 2000 - 2011-10-14, Hammersmith Imanet Ltd
6 Copyright (C) 2011-07-01 - 2011, Kris Thielemans
7 Copyright (C) 2016, University of Hull
8 Copyright (C) 2016, 2017, 2020, University College London
9 This file is part of STIR.
10
11 SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
12 See STIR/LICENSE.txt for details
13*/
27
28#include "stir/warning.h"
29START_NAMESPACE_STIR
30
31shared_ptr<ProjDataInfo>
33{
34 shared_ptr<ProjDataInfo> sptr(this->clone());
35 return sptr;
36}
37
38shared_ptr<ProjDataInfo>
40{
41 shared_ptr<ProjDataInfo> sptr(this->clone());
42 sptr->set_tof_mash_factor(0); // tof mashing factor = 0 is a trigger for non-tof data
43 return sptr;
44}
45
46int
48{
49 return (max_axial_pos_per_seg.get_length());
50}
51
52int
53ProjDataInfo::get_num_axial_poss(const int segment_num) const
54{
55 return max_axial_pos_per_seg[segment_num] - min_axial_pos_per_seg[segment_num] + 1;
56}
57
58int
60{
61 return max_view_num - min_view_num + 1;
62}
63
64int
66{
67 return max_tangential_pos_num - min_tangential_pos_num + 1;
68}
69
70int
72{
73 return num_tof_bins;
74}
75
76int
77ProjDataInfo::get_tof_bin(const double delta) const
78{
79 if (!is_tof_data())
80 return 0;
81
82 for (int i = min_tof_pos_num; i <= max_tof_pos_num; ++i)
83 {
84 if (delta >= tof_bin_boundaries_ps[i].low_lim && delta < tof_bin_boundaries_ps[i].high_lim)
85 return i;
86 }
87 // TODO handle differently
88 warning("TOF delta time " + std::to_string(delta) + " out of range");
89 return min_tof_pos_num;
90}
91
92#if 0
93// KT: code disabled as buggy but currently not needed
94int
95ProjDataInfo::get_unmashed_tof_bin(const double delta) const
96{
97 if (!is_tof_data())
98 return 0;
99
100 for (int i = min_unmashed_tof_pos_num; i <= max_unmashed_tof_pos_num; ++i)
101 {
102 if (delta >= tof_bin_boundaries_ps[i].low_lim &&
103 delta < tof_bin_boundaries_ps[i].high_lim)
104 return i;
105 }
106 // TODO handle differently
107 warning(format("TOF delta time {} out of range", delta));
108 return min_tof_pos_num;
109
110}
111#endif
112
113int
115{
116 return tof_mash_factor;
117}
118
119int
121{
122 return (max_axial_pos_per_seg.get_min_index());
123}
124
125int
127{
128 return (max_axial_pos_per_seg.get_max_index());
129}
130
131int
132ProjDataInfo::get_min_axial_pos_num(const int segment_num) const
133{
134 return min_axial_pos_per_seg[segment_num];
135}
136
137int
138ProjDataInfo::get_max_axial_pos_num(const int segment_num) const
139{
140 return max_axial_pos_per_seg[segment_num];
141}
142
143int
145{
146 return min_view_num;
147}
148
149int
151{
152 return max_view_num;
153}
154
155int
157{
158 return min_tangential_pos_num;
159}
160
161int
163{
164 return max_tangential_pos_num;
165}
166
167int
169{
170 return min_tof_pos_num;
171}
172
173int
175{
176 return max_tof_pos_num;
177}
178
179bool
181{
182 // First case: if tof_mash_factor == 0, scanner is not tof ready and no tof data
183 if (tof_mash_factor == 0)
184 {
185 if (num_tof_bins != 1)
186 {
187 error("Non-TOF data with inconsistent Time-of-Flight bin number - Aborted operation.");
188 }
189 return false;
190 }
191 // Second case: when tof_mash_factor is strictly positive, it means we have TOF data
192 else if (tof_mash_factor > 0)
193 {
194 return true;
195 }
196 return false;
197}
198
199float
201{
202 return 1 / sqrt(1 + square(get_tantheta(bin)));
203}
204
205float
206ProjDataInfo::get_m(const Bin& bin) const
207{
208 return get_t(bin) / get_costheta(bin);
209}
210
211const Scanner*
213{
214 return scanner_ptr.get();
215}
216
217shared_ptr<Scanner>
219{
220 return scanner_ptr;
221}
222
223int
225{
226 int num_sinos = 0;
227 for (int s = this->get_min_segment_num(); s <= this->get_max_segment_num(); ++s)
228 num_sinos += this->get_num_axial_poss(s);
229
230 return num_sinos;
231}
232
233int
235{
236 return this->get_num_non_tof_sinograms() * this->get_num_tof_poss();
237}
238
239std::size_t
241{
242 return static_cast<std::size_t>(this->get_num_sinograms())
243 * static_cast<std::size_t>(this->get_num_views() * this->get_num_tangential_poss());
244}
245
246END_NAMESPACE_STIR
A class for storing coordinates and value of a single projection bin.
Definition Bin.h:49
int get_min_tof_pos_num() const
Get the index of the first TOF position.
Definition ProjDataInfo.inl:168
shared_ptr< ProjDataInfo > create_non_tof_clone() const
Similar to create_shared_clone() but returns a non-tof version of ProjDataInfo setting tof mashing fa...
Definition ProjDataInfo.inl:39
int get_num_sinograms() const
Get the total number of sinograms.
Definition ProjDataInfo.inl:234
shared_ptr< ProjDataInfo > create_shared_clone() const
Like clone() but return a shared_ptr.
Definition ProjDataInfo.inl:32
int get_num_axial_poss(const int segment_num) const
Get number of axial positions per segment.
Definition ProjDataInfo.inl:53
int get_min_axial_pos_num(const int segment_num) const
Get minimum axial position per segmnet.
Definition ProjDataInfo.inl:132
int get_min_tangential_pos_num() const
Get minimum tangential position number.
Definition ProjDataInfo.inl:156
int get_num_views() const
Get number of views.
Definition ProjDataInfo.inl:59
int get_tof_bin(const double delta) const
Get number of tof bin for a given time difference.
Definition ProjDataInfo.inl:77
int get_num_segments() const
Get number of segments.
Definition ProjDataInfo.inl:47
shared_ptr< Scanner > get_scanner_sptr() const
Get scanner shared pointer.
Definition ProjDataInfo.inl:218
int get_max_tangential_pos_num() const
Get maximum tangential position number.
Definition ProjDataInfo.inl:162
int get_max_axial_pos_num(const int segment_num) const
Get maximum axial position per segment.
Definition ProjDataInfo.inl:138
int get_min_segment_num() const
Get minimum segment number.
Definition ProjDataInfo.inl:120
int get_max_tof_pos_num() const
Get the index of the last timgin position.
Definition ProjDataInfo.inl:174
float get_costheta(const Bin &) const
Get cosine of the co-polar angle of the normal to the projection plane.
Definition ProjDataInfo.inl:200
int get_min_view_num() const
Get minimum view number.
Definition ProjDataInfo.inl:144
virtual float get_t(const Bin &) const =0
Get value of the (roughly) axial coordinate in the projection plane (in mm)
int get_max_view_num() const
Get maximum view number.
Definition ProjDataInfo.inl:150
virtual float get_m(const Bin &) const
Return z-coordinate of the middle of the LOR (in mm)
Definition ProjDataInfo.inl:206
VectorWithOffset< Float1Float2 > tof_bin_boundaries_ps
Vector which holds the lower and higher boundary for each TOF position in ps`, for faster access.
Definition ProjDataInfo.h:461
virtual ProjDataInfo * clone() const =0
Standard trick for a 'virtual copy-constructor'.
virtual float get_tantheta(const Bin &) const =0
Get tangent of the co-polar angle of the normal to the projection plane.
const Scanner * get_scanner_ptr() const
Get scanner pointer.
Definition ProjDataInfo.inl:212
std::size_t size_all() const
Get the total size of the data.
Definition ProjDataInfo.inl:240
int get_num_tof_poss() const
Get number of TOF bins.
Definition ProjDataInfo.inl:71
bool is_tof_data() const
Determine if TOF data from tof_mash_factor and num_tof_bins.
Definition ProjDataInfo.inl:180
int get_tof_mash_factor() const
Get TOF mash factor.
Definition ProjDataInfo.inl:114
int get_num_non_tof_sinograms() const
Get the number of non-tof sinograms.
Definition ProjDataInfo.inl:224
int get_num_tangential_poss() const
Get number of tangential positions.
Definition ProjDataInfo.inl:65
int get_max_segment_num() const
Get maximum segment number.
Definition ProjDataInfo.inl:126
A class for storing some info on the scanner.
Definition Scanner.h:108
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition error.cxx:42
void warning(const char *const s,...)
Print warning with format string a la printf.
Definition warning.cxx:41
NUMBER square(const NUMBER &x)
returns the square of a number, templated.
Definition common.h:154
Declaration of stir::warning()