libparallelproj_c

  1/**
  2 * @file parallelproj_c.h
  3 */
  4
  5#ifndef __PARALLELPROJ_C_H__
  6#define __PARALLELPROJ_C_H__
  7
  8#ifdef  __cplusplus
  9extern "C" {
 10#endif
 11
 12/** @brief 3D non-tof joseph back projector
 13 *
 14 *  All threads back project in one image using openmp's atomic add.
 15 *
 16 *  @param xstart array of shape [3*nlors] with the coordinates of the start points of the LORs.
 17 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2.
 18 *                Units are the ones of voxsize.
 19 *  @param xend   array of shape [3*nlors] with the coordinates of the end   points of the LORs.
 20 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2.
 21 *                Units are the ones of voxsize.
 22 *  @param img    array of shape [n0*n1*n2] containing the 3D image used for back projection (output).
 23 *                The pixel [i,j,k] ist stored at [n1*n2*i + n2*j + k].
 24 *                !! values are added to existing array !!
 25 *  @param img_origin  array [x0_0,x0_1,x0_2] of coordinates of the center of the [0,0,0] voxel
 26 *  @param voxsize     array [vs0, vs1, vs2] of the voxel sizes
 27 *  @param p           array of length nlors with the values to be back projected
 28 *  @param nlors       number of geometrical LORs
 29 *  @param img_dim     array with dimensions of image [n0,n1,n2]
 30 */
 31void joseph3d_back(const float *xstart, 
 32                   const float *xend, 
 33                   float *img,
 34                   const float *img_origin, 
 35                   const float *voxsize,
 36                   const float *p, 
 37                   long long nlors, 
 38                   const int *img_dim);
 39
 40
 41
 42/** @brief 3D listmode tof joseph back projector
 43 *
 44 *  All threads back project in one image using openmp's atomic add.
 45 *
 46 *  @param xstart array of shape [3*nlors] with the coordinates of the start points of the LORs.
 47 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
 48 *                Units are the ones of voxsize.
 49 *  @param xend   array of shape [3*nlors] with the coordinates of the end   points of the LORs.
 50 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
 51 *                Units are the ones of voxsize.
 52 *  @param img    array of shape [n0*n1*n2] containing the 3D image used for back projection (output).
 53 *                The pixel [i,j,k] ist stored at [n1*n2*i + n2*j + k].
 54 *                !! values are added to existing array !!
 55 *  @param img_origin  array [x0_0,x0_1,x0_2] of coordinates of the center of the [0,0,0] voxel
 56 *  @param voxsize     array [vs0, vs1, vs2] of the voxel sizes
 57 *  @param p           array of length nlors with the values to be back projected
 58 *  @param nlors       number of geometrical LORs
 59 *  @param img_dim     array with dimensions of image [n0,n1,n2]
 60 *  @param tofbin_width     width of the TOF bins in spatial units (units of xstart and xend)
 61 *  @param sigma_tof        array of length 1 or nlors (depending on lor_dependent_sigma_tof)
 62 *                          with the TOF resolution (sigma) for each LOR in
 63 *                          spatial units (units of xstart and xend) 
 64 *  @param tofcenter_offset array of length 1 or nlors (depending on lor_dependent_tofcenter_offset)
 65 *                          with the offset of the central TOF bin from the 
 66 *                          midpoint of each LOR in spatial units (units of xstart and xend). 
 67 *                          A positive value means a shift towards the end point of the LOR.
 68 *  @param n_sigmas         number of sigmas to consider for calculation of TOF kernel
 69 *  @param tof_bin          signed integer array with the tofbin of the events
 70 *                          the center of TOF bin 0 is assumed to be at the center of the LOR
 71 *                          (shifted by the tofcenter_offset)
 72 *  @param lor_dependent_sigma_tof unsigned char 0 or 1
 73 *                                 1 means that the TOF sigmas are LOR dependent
 74 *                                 any other value means that the first value in the sigma_tof
 75 *                                 array is used for all LORs
 76 *  @param lor_dependent_tofcenter_offset unsigned char 0 or 1
 77 *                                        1 means that the TOF center offsets are LOR dependent
 78 *                                        any other value means that the first value in the 
 79 *                                        tofcenter_offset array is used for all LORs
 80 */
 81void joseph3d_back_tof_lm(const float *xstart, 
 82                          const float *xend, 
 83                          float *img,
 84                          const float *img_origin, 
 85                          const float *voxsize,
 86                          const float *p, 
 87                          long long nlors, 
 88                          const int *img_dim,
 89                          float tofbin_width,
 90                          const float *sigma_tof,
 91                          const float *tofcenter_offset,
 92                          float n_sigmas,
 93                          const short *tof_bin,
 94                          unsigned char lor_dependent_sigma_tof,
 95                          unsigned char lor_dependent_tofcenter_offset);
 96
 97
 98
 99/** @brief 3D sinogram tof joseph back projector
100 *
101 *  All threads back project in one image using openmp's atomic add.
102 *
103 *  @param xstart array of shape [3*nlors] with the coordinates of the start points of the LORs.
104 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
105 *                Units are the ones of voxsize.
106 *  @param xend   array of shape [3*nlors] with the coordinates of the end   points of the LORs.
107 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
108 *                Units are the ones of voxsize.
109 *  @param img    array of shape [n0*n1*n2] containing the 3D image used for back projection (output).
110 *                The pixel [i,j,k] ist stored at [n1*n2*i + n2*j + k].
111 *                !! values are added to existing array !!
112 *  @param img_origin  array [x0_0,x0_1,x0_2] of coordinates of the center of the [0,0,0] voxel
113 *  @param voxsize     array [vs0, vs1, vs2] of the voxel sizes
114 *  @param p           array of length nlors*n_tofbins with the values to be back projected
115 *                     the order of the array is 
116 *                     [LOR0-TOFBIN-0, LOR0-TOFBIN-1, ... LOR0_TOFBIN-(n-1), 
117 *                      LOR1-TOFBIN-0, LOR1-TOFBIN-1, ... LOR1_TOFBIN-(n-1), 
118 *                      ...
119 *                      LOR(N-1)-TOFBIN-0, LOR(N-1)-TOFBIN-1, ... LOR(N-1)_TOFBIN-(n-1)] 
120 *  @param nlors       number of geometrical LORs
121 *  @param img_dim     array with dimensions of image [n0,n1,n2]
122 *  @param tofbin_width     width of the TOF bins in spatial units (units of xstart and xend)
123 *  @param sigma_tof        array of length 1 or nlors (depending on lor_dependent_sigma_tof)
124 *                          with the TOF resolution (sigma) for each LOR in
125 *                          spatial units (units of xstart and xend) 
126 *  @param tofcenter_offset array of length 1 or nlors (depending on lor_dependent_tofcenter_offset)
127 *                          with the offset of the central TOF bin from the 
128 *                          midpoint of each LOR in spatial units (units of xstart and xend). 
129 *                          A positive value means a shift towards the end point of the LOR.
130 *  @param n_sigmas         number of sigmas to consider for calculation of TOF kernel
131 *  @param n_tofbins        number of TOF bins
132 *  @param lor_dependent_sigma_tof unsigned char 0 or 1
133 *                                 1 means that the TOF sigmas are LOR dependent
134 *                                 any other value means that the first value in the sigma_tof
135 *                                 array is used for all LORs
136 *  @param lor_dependent_tofcenter_offset unsigned char 0 or 1
137 *                                        1 means that the TOF center offsets are LOR dependent
138 *                                        any other value means that the first value in the 
139 *                                        tofcenter_offset array is used for all LORs
140 */
141void joseph3d_back_tof_sino(const float *xstart, 
142                            const float *xend, 
143                            float *img,
144                            const float *img_origin, 
145                            const float *voxsize,
146                            const float *p, 
147                            long long nlors, 
148                            const int *img_dim,
149                            float tofbin_width,
150                            const float *sigma_tof,
151                            const float *tofcenter_offset,
152                            float n_sigmas,
153                            short n_tofbins,
154                            unsigned char lor_dependent_sigma_tof,
155                            unsigned char lor_dependent_tofcenter_offset);
156
157
158
159
160/** @brief 3D non-tof joseph forward projector
161 *
162 *  @param xstart array of shape [3*nlors] with the coordinates of the start points of the LORs.
163 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
164 *                Units are the ones of voxsize.
165 *  @param xend   array of shape [3*nlors] with the coordinates of the end   points of the LORs.
166 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
167 *                Units are the ones of voxsize.
168 *  @param img    array of shape [n0*n1*n2] containing the 3D image to be projected.
169 *                The pixel [i,j,k] ist stored at [n1*n2*i + n2*j + k].
170 *  @param img_origin  array [x0_0,x0_1,x0_2] of coordinates of the center of the [0,0,0] voxel
171 *  @param voxsize     array [vs0, vs1, vs2] of the voxel sizes
172 *  @param p           array of length nlors (output) used to store the projections
173 *  @param nlors       number of geomtrical LORs
174 *  @param img_dim     array with dimensions of image [n0,n1,n2]
175 */
176void joseph3d_fwd(const float *xstart, 
177                  const float *xend, 
178                  const float *img,
179                  const float *img_origin, 
180                  const float *voxsize, 
181                  float *p,
182                  long long nlors, 
183                  const int *img_dim);
184
185/** @brief 3D listmode tof joseph forward projector
186 *
187 *  @param xstart array of shape [3*nlors] with the coordinates of the start points of the LORs.
188 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
189 *                Units are the ones of voxsize.
190 *  @param xend   array of shape [3*nlors] with the coordinates of the end   points of the LORs.
191 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
192 *                Units are the ones of voxsize.
193 *  @param img    array of shape [n0*n1*n2] containing the 3D image to be projected.
194 *                The pixel [i,j,k] ist stored at [n1*n2*i + n2*j + k].
195 *  @param img_origin  array [x0_0,x0_1,x0_2] of coordinates of the center of the [0,0,0] voxel
196 *  @param voxsize     array [vs0, vs1, vs2] of the voxel sizes
197 *  @param p           array of length nlors (output) used to store the projections
198 *  @param nlors       number of geomtrical LORs
199 *  @param img_dim     array with dimensions of image [n0,n1,n2]
200 *  @param tofbin_width     width of the TOF bins in spatial units (units of xstart and xend)
201 *  @param sigma_tof        array of length 1 or nlors (depending on lor_dependent_sigma_tof)
202 *                          with the TOF resolution (sigma) for each LOR in
203 *                          spatial units (units of xstart and xend) 
204 *  @param tofcenter_offset array of length 1 or nlors (depending on lor_dependent_tofcenter_offset)
205 *                          with the offset of the central TOF bin from the 
206 *                          midpoint of each LOR in spatial units (units of xstart and xend). 
207 *                          A positive value means a shift towards the end point of the LOR.
208 *  @param n_sigmas         number of sigmas to consider for calculation of TOF kernel
209 *  @param tof_bin          signed integer array with the tofbin of the events
210 *                          the center of TOF bin 0 is assumed to be at the center of the LOR
211 *                          (shifted by the tofcenter_offset)
212 *  @param lor_dependent_sigma_tof unsigned char 0 or 1
213 *                                 1 means that the TOF sigmas are LOR dependent
214 *                                 any other value means that the first value in the sigma_tof
215 *                                 array is used for all LORs
216 *  @param lor_dependent_tofcenter_offset unsigned char 0 or 1
217 *                                        1 means that the TOF center offsets are LOR dependent
218 *                                        any other value means that the first value in the 
219 *                                        tofcenter_offset array is used for all LORs
220 */
221void joseph3d_fwd_tof_lm(const float *xstart, 
222                        const float *xend, 
223                        const float *img,
224                        const float *img_origin, 
225                        const float *voxsize, 
226                        float *p,
227                        long long nlors, 
228                        const int *img_dim,
229                        float tofbin_width,
230                        const float *sigma_tof,
231                        const float *tofcenter_offset,
232                        float n_sigmas,
233                        const short *tof_bin,
234                        unsigned char lor_dependent_sigma_tof,
235                        unsigned char lor_dependent_tofcenter_offset);
236
237/** @brief 3D sinogram tof joseph forward projector
238 *
239 *  @param xstart array of shape [3*nlors] with the coordinates of the start points of the LORs.
240 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
241 *                Units are the ones of voxsize.
242 *  @param xend   array of shape [3*nlors] with the coordinates of the end   points of the LORs.
243 *                The start coordinates of the n-th LOR are at xstart[n*3 + i] with i = 0,1,2. 
244 *                Units are the ones of voxsize.
245 *  @param img    array of shape [n0*n1*n2] containing the 3D image to be projected.
246 *                The pixel [i,j,k] ist stored at [n1*n2*i + n2*j + k].
247 *  @param img_origin  array [x0_0,x0_1,x0_2] of coordinates of the center of the [0,0,0] voxel
248 *  @param voxsize     array [vs0, vs1, vs2] of the voxel sizes
249 *  @param p           array of length nlors*n_tofbins (output) used to store the projections
250 *                     the order of the array is
251 *                     [LOR0-TOFBIN-0, LOR0-TOFBIN-1, ... LOR0_TOFBIN-(n-1), 
252 *                      LOR1-TOFBIN-0, LOR1-TOFBIN-1, ... LOR1_TOFBIN-(n-1), 
253 *                      ...
254 *                      LOR(N-1)-TOFBIN-0, LOR(N-1)-TOFBIN-1, ... LOR(N-1)_TOFBIN-(n-1)] 
255 *  @param nlors       number of geomtrical LORs
256 *  @param img_dim     array with dimensions of image [n0,n1,n2]
257 *  @param tofbin_width     width of the TOF bins in spatial units (units of xstart and xend)
258 *  @param sigma_tof        array of length 1 or nlors (depending on lor_dependent_sigma_tof)
259 *                          with the TOF resolution (sigma) for each LOR in
260 *                          spatial units (units of xstart and xend) 
261 *  @param tofcenter_offset array of length 1 or nlors (depending on lor_dependent_tofcenter_offset)
262 *                          with the offset of the central TOF bin from the 
263 *                          midpoint of each LOR in spatial units (units of xstart and xend). 
264 *                          A positive value means a shift towards the end point of the LOR.
265 *  @param n_sigmas         number of sigmas to consider for calculation of TOF kernel
266 *  @param n_tofbins        number of TOF bins
267 *  @param lor_dependent_sigma_tof unsigned char 0 or 1
268 *                                 1 means that the TOF sigmas are LOR dependent
269 *                                 any other value means that the first value in the sigma_tof
270 *                                 array is used for all LORs
271 *  @param lor_dependent_tofcenter_offset unsigned char 0 or 1
272 *                                        1 means that the TOF center offsets are LOR dependent
273 *                                        any other value means that the first value in the 
274 *                                        tofcenter_offset array is used for all LORs
275 */
276void joseph3d_fwd_tof_sino(const float *xstart, 
277                           const float *xend, 
278                           const float *img,
279                           const float *img_origin, 
280                           const float *voxsize, 
281                           float *p,
282                           long long nlors, 
283                           const int *img_dim,
284                           float tofbin_width,
285                           const float *sigma_tof,
286                           const float *tofcenter_offset,
287                           float n_sigmas,
288                           short n_tofbins,
289                           unsigned char lor_dependent_sigma_tof,
290                           unsigned char lor_dependent_tofcenter_offset);
291
292#ifdef __cplusplus
293}  /* extern "C" */
294#endif
295
296#endif