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