C API Reference¶
Functions declared in parallelproj.h.
Functions
-
int parallelproj_cuda_enabled(void)¶
Query whether this libparallelproj library was compiled with CUDA support.
- Returns:
1 if compiled with CUDA support, 0 otherwise.
-
const char *parallelproj_version(void)¶
Query the version string of this libparallelproj library. Potentially includes extra suffix for “dirty” versions.
- Returns:
Null-terminated version string.
-
int parallelproj_version_major(void)¶
Query the major version number of this libparallelproj library.
- Returns:
Major version number.
-
int parallelproj_version_minor(void)¶
Query the minor version number of this libparallelproj library.
- Returns:
Minor version number.
-
int parallelproj_version_patch(void)¶
Query the patch version number of this libparallelproj library.
- Returns:
Patch version number.
-
void joseph3d_fwd(const float *lor_start, const float *lor_end, const float *image, const float *image_origin, const float *voxel_size, float *projection_values, std::size_t num_lors, const int *image_dim, int device_id = 0, int threads_per_block = 64)¶
Forward projection using the Joseph 3D algorithm.
Note
All pointers can be host pointers, CUDA device pointers, or CUDA managed pointers.
Note
Image memory layout for
imageis C-contiguous with index n1*n2*i + n2*j + k for voxel/pixel [i,j,k].- Parameters:
lor_start – Pointer to array of shape [3 *
num_lors] with the coordinates of the start points of the LORs/events. The start coordinates of the n-th LOR/event are atlor_start[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.lor_end – Pointer to array of shape [3 *
num_lors] with the coordinates of the end points of the LORs/events. The end coordinates of the n-th LOR/event are atlor_end[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.image – Pointer to array of shape [n0*n1*n2] containing the 3D image used for forward projection.
image_origin – Pointer to array [x0_0, x0_1, x0_2] of coordinates of the center of the [0,0,0] voxel.
voxel_size – Pointer to array [vs0, vs1, vs2] of voxel sizes.
projection_values – Pointer to array of length
num_lorswhere the forward projection results will be stored.num_lors – Number of geometric LORs.
image_dim – Pointer to array with image dimensions [n0, n1, n2].
device_id – ID of the device to use for computation (default: 0).
threads_per_block – Number of threads per block for GPU computation (default: 64).
-
void joseph3d_back(const float *lor_start, const float *lor_end, float *image, const float *image_origin, const float *voxel_size, const float *projection_values, std::size_t num_lors, const int *image_dim, int device_id = 0, int threads_per_block = 64)¶
Backprojection using the Joseph 3D algorithm.
Note
All pointers can be host pointers, CUDA device pointers, or CUDA managed pointers.
Note
Image memory layout for
imageis C-contiguous with index n1*n2*i + n2*j + k for voxel/pixel [i,j,k].- Parameters:
lor_start – Pointer to array of shape [3 *
num_lors] with the coordinates of the start points of the LORs/events. The start coordinates of the n-th LOR/event are atlor_start[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.lor_end – Pointer to array of shape [3 *
num_lors] with the coordinates of the end points of the LORs/events. The end coordinates of the n-th LOR/event are atlor_end[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.image – Pointer to array of shape [n0*n1*n2] containing the 3D image used for backprojection. Values are added to the existing contents of this array.
image_origin – Pointer to array [x0_0, x0_1, x0_2] of coordinates of the center of the [0,0,0] voxel.
voxel_size – Pointer to array [vs0, vs1, vs2] of voxel sizes.
projection_values – Pointer to array of length
num_lorswith the values to be backprojected.num_lors – Number of geometric LORs.
image_dim – Pointer to array with image dimensions [n0, n1, n2].
device_id – ID of the device to use for computation (default: 0).
threads_per_block – Number of threads per block for GPU computation (default: 64).
-
void joseph3d_tof_sino_fwd(const float *lor_start, const float *lor_end, const float *image, const float *image_origin, const float *voxel_size, float *projection_values, std::size_t num_lors, const int *image_dim, float tof_bin_width, const float *tof_sigma, const float *tof_center_offset, float num_sigmas, short num_tof_bins, unsigned char is_lor_dependent_tof_sigma, unsigned char is_lor_dependent_tof_center_offset, int device_id = 0, int threads_per_block = 64)¶
3D sinogram TOF Joseph forward projector
Note
All pointers can be host pointers, CUDA device pointers, or CUDA managed pointers.
Note
Image memory layout for
imageis C-contiguous with index n1*n2*i + n2*j + k for voxel/pixel [i,j,k].Note
TOF sinogram memory layout for
projection_valuesis row-major per LOR: [LOR0-TOFBIN-0, LOR0-TOFBIN-1, …, LOR0-TOFBIN-(num_tof_bins-1), LOR1-TOFBIN-0, LOR1-TOFBIN-1, …, LOR1-TOFBIN-(num_tof_bins-1), …].- Parameters:
lor_start – Pointer to array of shape [3 *
num_lors] with the coordinates of the start points of the LORs/events. The start coordinates of the n-th LOR/event are atlor_start[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.lor_end – Pointer to array of shape [3 *
num_lors] with the coordinates of the end points of the LORs/events. The end coordinates of the n-th LOR/event are atlor_end[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.image – Pointer to array of shape [n0*n1*n2] containing the 3D image used for forward projection.
image_origin – Pointer to array [x0_0, x0_1, x0_2] of coordinates of the center of the [0,0,0] voxel.
voxel_size – Pointer to array [vs0, vs1, vs2] of voxel sizes.
projection_values – Pointer to array of length
num_lors*num_tof_bins(output) used to store the projections.num_lors – Number of geometric LORs.
image_dim – Pointer to array with image dimensions [n0, n1, n2].
tof_bin_width – Width of the TOF bins in spatial units (units of
lor_startandlor_end).tof_sigma – Pointer to array of length 1 or
num_lors(depending onis_lor_dependent_tof_sigma). Contains TOF resolution (sigma) values in spatial units (units oflor_startandlor_end).tof_center_offset – Pointer to array of length 1 or
num_lors(depending onis_lor_dependent_tof_center_offset). Contains offsets of the central TOF bin from the LOR midpoint in spatial units. A positive value means a shift towards the end point of the LOR.num_sigmas – Number of sigmas to consider for calculation of the TOF kernel.
num_tof_bins – Number of TOF bins.
is_lor_dependent_tof_sigma – Unsigned char 0 or 1. 0 means that the first value in
tof_sigmais used for all LORs. 1 (non-zero) means that the TOF resolutions are LOR dependent.is_lor_dependent_tof_center_offset – Unsigned char 0 or 1. 0 means that the first value in
tof_center_offsetis used for all LORs. 1 (non-zero) means that the TOF center offsets are LOR dependent.device_id – ID of the device to use for computation (default: 0).
threads_per_block – Number of threads per block for GPU computation (default: 64).
-
void joseph3d_tof_sino_back(const float *lor_start, const float *lor_end, float *image, const float *image_origin, const float *voxel_size, const float *projection_values, std::size_t num_lors, const int *image_dim, float tof_bin_width, const float *tof_sigma, const float *tof_center_offset, float num_sigmas, short num_tof_bins, unsigned char is_lor_dependent_tof_sigma, unsigned char is_lor_dependent_tof_center_offset, int device_id = 0, int threads_per_block = 64)¶
TOF sinogram backprojection using the Joseph 3D algorithm.
The function backprojects a TOF sinogram into a 3D image volume using the Joseph ray-driven algorithm. Values from
projection_valuesare distributed intoimage(accumulated, not overwritten).Note
All pointers can be host pointers, CUDA device pointers, or CUDA managed pointers.
Note
Image memory layout for
imageis C-contiguous with index n1*n2*i + n2*j + k for voxel/pixel [i,j,k].Note
TOF sinogram memory layout for
projection_valuesis row-major per LOR: [LOR0-TOFBIN-0, LOR0-TOFBIN-1, …, LOR0-TOFBIN-(num_tof_bins-1), LOR1-TOFBIN-0, LOR1-TOFBIN-1, …, LOR1-TOFBIN-(num_tof_bins-1), …].- Parameters:
lor_start – Pointer to array of shape [3 *
num_lors] with the coordinates of the start points of the LORs/events. The start coordinates of the n-th LOR/event are atlor_start[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.lor_end – Pointer to array of shape [3 *
num_lors] with the coordinates of the end points of the LORs/events. The end coordinates of the n-th LOR/event are atlor_end[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.image – Pointer to array of shape [n0*n1*n2] containing the 3D image used for backprojection. Values are added to the existing contents of this array.
image_origin – Pointer to array [x0_0, x0_1, x0_2] of coordinates of the center of the [0,0,0] voxel.
voxel_size – Pointer to array [vs0, vs1, vs2] of voxel sizes.
projection_values – Pointer to TOF sinogram data of length
num_lors*num_tof_bins(see details).num_lors – Number of geometric LORs.
image_dim – Pointer to array with image dimensions [n0, n1, n2].
tof_bin_width – Width of the TOF bins in spatial units (units of
lor_startandlor_end).tof_sigma – Pointer to array of length 1 or
num_lors(depending onis_lor_dependent_tof_sigma). Contains TOF resolution (sigma) values in spatial units (units oflor_startandlor_end).tof_center_offset – Pointer to array of length 1 or
num_lors(depending onis_lor_dependent_tof_center_offset). Contains offsets of the central TOF bin from the LOR midpoint in spatial units. A positive value means a shift towards the end point of the LOR.num_sigmas – Number of sigmas to consider for calculation of the TOF kernel.
num_tof_bins – Number of TOF bins.
is_lor_dependent_tof_sigma – Unsigned char 0 or 1. 0 means that the first value in
tof_sigmais used for all LORs. 1 (non-zero) means that the TOF resolutions are LOR dependent.is_lor_dependent_tof_center_offset – Unsigned char 0 or 1. 0 means that the first value in
tof_center_offsetis used for all LORs. 1 (non-zero) means that the TOF center offsets are LOR dependent.device_id – ID of the device to use for computation (default: 0).
threads_per_block – Number of threads per block for GPU computation (default: 64).
-
void joseph3d_tof_lm_fwd(const float *lor_start, const float *lor_end, const float *image, const float *image_origin, const float *voxel_size, float *projection_values, std::size_t num_events, const int *image_dim, float tof_bin_width, const float *tof_sigma, const float *tof_center_offset, float num_sigmas, const short *tof_bin_index, short num_tof_bins, unsigned char is_lor_dependent_tof_sigma, unsigned char is_lor_dependent_tof_center_offset, int device_id = 0, int threads_per_block = 64)¶
3D listmode TOF Joseph forward projector
Note
All pointers can be host pointers, CUDA device pointers, or CUDA managed pointers.
Note
Image memory layout for
imageis C-contiguous with index n1*n2*i + n2*j + k for voxel/pixel [i,j,k].- Parameters:
lor_start – Pointer to array of shape [3 *
num_events] with the coordinates of the start points of the LORs/events. The start coordinates of the n-th LOR/event are atlor_start[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.lor_end – Pointer to array of shape [3 *
num_events] with the coordinates of the end points of the LORs/events. The end coordinates of the n-th LOR/event are atlor_end[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.image – Pointer to array of shape [n0*n1*n2] containing the 3D image used for forward projection.
image_origin – Pointer to array [x0_0, x0_1, x0_2] of coordinates of the center of the [0,0,0] voxel.
voxel_size – Pointer to array [vs0, vs1, vs2] of voxel sizes.
projection_values – Pointer to array of length
num_events(output) used to store the projections.num_events – Number of events.
image_dim – Pointer to array with image dimensions [n0, n1, n2].
tof_bin_width – Width of the TOF bins in spatial units (units of
lor_startandlor_end).tof_sigma – Pointer to array of length 1 or
num_events(depending onis_lor_dependent_tof_sigma). Contains TOF resolution (sigma) values in spatial units (units oflor_startandlor_end).tof_center_offset – Pointer to array of length 1 or
num_events(depending onis_lor_dependent_tof_center_offset). Contains offsets of the central TOF bin from the LOR midpoint in spatial units. A positive value means a shift towards the end point of the LOR.num_sigmas – Number of sigmas to consider for calculation of the TOF kernel.
tof_bin_index – Pointer to array of length
num_eventswith the TOF bin numbers.num_tof_bins – Number of TOF bins.
is_lor_dependent_tof_sigma – Unsigned char 0 or 1. 0 means that the first value in
tof_sigmais used for all events. 1 (non-zero) means that the TOF resolutions are LOR dependent.is_lor_dependent_tof_center_offset – Unsigned char 0 or 1. 0 means that the first value in
tof_center_offsetis used for all events. 1 (non-zero) means that the TOF center offsets are LOR dependent.device_id – ID of the device to use for computation (default: 0).
threads_per_block – Number of threads per block for GPU computation (default: 64).
-
void joseph3d_tof_lm_back(const float *lor_start, const float *lor_end, float *image, const float *image_origin, const float *voxel_size, const float *projection_values, std::size_t num_events, const int *image_dim, float tof_bin_width, const float *tof_sigma, const float *tof_center_offset, float num_sigmas, const short *tof_bin_index, short num_tof_bins, unsigned char is_lor_dependent_tof_sigma, unsigned char is_lor_dependent_tof_center_offset, int device_id = 0, int threads_per_block = 64)¶
3D listmode TOF Joseph back projector
Note
All pointers can be host pointers, CUDA device pointers, or CUDA managed pointers.
Note
Image memory layout for
imageis C-contiguous with index n1*n2*i + n2*j + k for voxel/pixel [i,j,k].- Parameters:
lor_start – Pointer to array of shape [3 *
num_events] with the coordinates of the start points of the LORs/events. The start coordinates of the n-th LOR/event are atlor_start[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.lor_end – Pointer to array of shape [3 *
num_events] with the coordinates of the end points of the LORs/events. The end coordinates of the n-th LOR/event are atlor_end[n*3 + i] with i = 0,1,2. Units are those ofvoxel_size.image – Pointer to array of shape [n0*n1*n2] containing the 3D image used for backprojection. Values are added to the existing contents of this array.
image_origin – Pointer to array [x0_0, x0_1, x0_2] of coordinates of the center of the [0,0,0] voxel.
voxel_size – Pointer to array [vs0, vs1, vs2] of voxel sizes.
projection_values – Pointer to array of values to be backprojected (length
num_events).num_events – Number of events.
image_dim – Pointer to array with image dimensions [n0, n1, n2].
tof_bin_width – Width of the TOF bins in spatial units (units of
lor_startandlor_end).tof_sigma – Pointer to array of length 1 or
num_events(depending onis_lor_dependent_tof_sigma). Contains TOF resolution (sigma) values in spatial units (units oflor_startandlor_end).tof_center_offset – Pointer to array of length 1 or
num_events(depending onis_lor_dependent_tof_center_offset). Contains offsets of the central TOF bin from the LOR midpoint in spatial units. A positive value means a shift towards the end point of the LOR.num_sigmas – Number of sigmas to consider for calculation of the TOF kernel.
tof_bin_index – Pointer to array of length
num_eventswith the TOF bin numbers.num_tof_bins – Number of TOF bins.
is_lor_dependent_tof_sigma – Unsigned char 0 or 1. 0 means that the first value in
tof_sigmais used for all events. 1 (non-zero) means that the TOF resolutions are LOR dependent.is_lor_dependent_tof_center_offset – Unsigned char 0 or 1. 0 means that the first value in
tof_center_offsetis used for all events. 1 (non-zero) means that the TOF center offsets are LOR dependent.device_id – ID of the device to use for computation (default: 0).
threads_per_block – Number of threads per block for GPU computation (default: 64).