API
- parallelproj.backend.calc_chunks(nLORs: int, num_chunks: int) list[int][source]
calculate indices to split an array of length nLORs into num_chunks chunks
example: splitting an array of length 10 into 3 chunks returns [0,4,7,10]
- parallelproj.backend.get_array_module(array) module[source]
return module of a cupy or numpy array
- Parameters:
array (cupy or numpy array) –
- Return type:
cupy or numpy module
- parallelproj.backend.joseph3d_back(xstart: ndarray[Any, dtype[float32]], xend: ndarray[Any, dtype[float32]], back_img: ndarray[Any, dtype[float32]], img_origin: ndarray[Any, dtype[float32]], voxsize: ndarray[Any, dtype[float32]], sino: ndarray[Any, dtype[float32]], threadsperblock: int = 32, num_chunks: int = 1) None[source]
Non-TOF Joseph 3D forward projector
- Parameters:
xstart (XPFloat32Array (float32 numpy or cupy array)) – start world coordinates of the LORs, shape (nLORs, 3)
xend (XPFloat32Array (float32 numpy or cupy array)) – end world coordinates of the LORs, shape (nLORs, 3)
back_img (XPFloat32Array (float32 numpy or cupy array)) – output array for the back projection
img_origin (XPFloat32Array (float32 numpy or cupy array)) – containing the world coordinates of the image origin (voxel [0,0,0])
voxsize (XPFloat32Array (float32 numpy or cupy array)) – array containing the voxel size
sino (XPFloat32Array (float32 numpy or cupy array)) – array of length nLORs containing the values to be back projected
threadsperblock (int, optional) – by default 32
num_chunks (int, optional) – break down the back projection in hybrid mode into chunks to save memory on the GPU, by default 1
- parallelproj.backend.joseph3d_back_tof_lm(xstart: ndarray[Any, dtype[float32]], xend: ndarray[Any, dtype[float32]], back_img: ndarray[Any, dtype[float32]], img_origin: ndarray[Any, dtype[float32]], voxsize: ndarray[Any, dtype[float32]], lst: ndarray[Any, dtype[float32]], tofbin_width: float, sigma_tof: ndarray[Any, dtype[float32]], tofcenter_offset: ndarray[Any, dtype[float32]], nsigmas: float, tofbin: ndarray[Any, dtype[int16]], threadsperblock: int = 32, num_chunks: int = 1) None[source]
TOF Joseph 3D listmode back projector
- Parameters:
xstart (XPFloat32Array (float32 numpy or cupy array)) – start world coordinates of the LORs, shape (nLORs, 3)
xend (XPFloat32Array (float32 numpy or cupy array)) – end world coordinates of the LORs, shape (nLORs, 3)
back_img (XPFloat32Array (float32 numpy or cupy array)) – output array to be back projected
img_origin (XPFloat32Array (float32 numpy or cupy array)) – containing the world coordinates of the image origin (voxel [0,0,0])
voxsize (XPFloat32Array (float32 numpy or cupy array)) – array containing the voxel size
lst (XPFloat32Array (float32 numpy or cupy array)) – “list” of values to be projected
threadsperblock (int, optional) – by default 32
sigma_tof (XPFloat32Array (float32 numpy or cupy array)) – sigma of Gaussian TOF kernel in spatial units (same units as xstart) can be an array of length 1 -> same sigma for all LORs or an array of length nLORs -> LOR dependent sigma
tofcenter_offset (XPFloat32Array (float32 numpy or cupy array)) – center offset of the central TOF bin in spatial units (same units as xstart) can be an array of length 1 -> same offset for all LORs or an array of length nLORs -> LOR dependent offset
nsigmas (float) – number of sigmas to consider when Gaussian kernel is evaluated (truncated)
tofbin (XPShortArray) – array containing the tof bin of the events
num_chunks (int, optional) – break down the projection in hybrid mode into chunks to save memory on the GPU, by default 1
tofbin_width (float) – width of the TOF bin in spatial units (same units as xstart)
- parallelproj.backend.joseph3d_back_tof_sino(xstart: ndarray[Any, dtype[float32]], xend: ndarray[Any, dtype[float32]], back_img: ndarray[Any, dtype[float32]], img_origin: ndarray[Any, dtype[float32]], voxsize: ndarray[Any, dtype[float32]], sino: ndarray[Any, dtype[float32]], tofbin_width: float, sigma_tof: ndarray[Any, dtype[float32]], tofcenter_offset: ndarray[Any, dtype[float32]], nsigmas: float, ntofbins: int, threadsperblock: int = 32, num_chunks: int = 1) None[source]
TOF Joseph 3D sinogram forward projector
- Parameters:
xstart (XPFloat32Array (float32 numpy or cupy array)) – start world coordinates of the LORs, shape (nLORs, 3)
xend (XPFloat32Array (float32 numpy or cupy array)) – end world coordinates of the LORs, shape (nLORs, 3)
back_img (XPFloat32Array (float32 numpy or cupy array)) – output array to be back projected
img_origin (XPFloat32Array (float32 numpy or cupy array)) – containing the world coordinates of the image origin (voxel [0,0,0])
voxsize (XPFloat32Array (float32 numpy or cupy array)) – array containing the voxel size
sino (XPFloat32Array (float32 numpy or cupy array)) – TOF sinogram of size (nLORs*ntofbins) to be back projected
threadsperblock (int, optional) – by default 32
sigma_tof (XPFloat32Array (float32 numpy or cupy array)) – sigma of Gaussian TOF kernel in spatial units (same units as xstart) can be an array of length 1 -> same sigma for all LORs or an array of length nLORs -> LOR dependent sigma
tofcenter_offset (XPFloat32Array (float32 numpy or cupy array)) – center offset of the central TOF bin in spatial units (same units as xstart) can be an array of length 1 -> same offset for all LORs or an array of length nLORs -> LOR dependent offset
nsigmas (float) – number of sigmas to consider when Gaussian kernel is evaluated (truncated)
ntofbins (int) – total number of TOF bins
num_chunks (int, optional) – break down the projection in hybrid mode into chunks to save memory on the GPU, by default 1
tofbin_width (float) – width of the TOF bin in spatial units (same units as xstart)
- parallelproj.backend.joseph3d_fwd(xstart: ndarray[Any, dtype[float32]], xend: ndarray[Any, dtype[float32]], img: ndarray[Any, dtype[float32]], img_origin: ndarray[Any, dtype[float32]], voxsize: ndarray[Any, dtype[float32]], img_fwd: ndarray[Any, dtype[float32]], threadsperblock: int = 32, num_chunks: int = 1) None[source]
Non-TOF Joseph 3D forward projector
- Parameters:
xstart (XPFloat32Array (float32 numpy or cupy array)) – start world coordinates of the LORs, shape (nLORs, 3)
xend (XPFloat32Array (float32 numpy or cupy array)) – end world coordinates of the LORs, shape (nLORs, 3)
img (XPFloat32Array (float32 numpy or cupy array)) – containing the 3D image to be projected
img_origin (XPFloat32Array (float32 numpy or cupy array)) – containing the world coordinates of the image origin (voxel [0,0,0])
voxsize (XPFloat32Array (float32 numpy or cupy array)) – array containing the voxel size
img_fwd (XPFloat32Array (float32 numpy or cupy array)) – output array of length nLORs for storing the forward projection
threadsperblock (int, optional) – by default 32
num_chunks (int, optional) – break down the projection in hybrid mode into chunks to save memory on the GPU, by default 1
- parallelproj.backend.joseph3d_fwd_tof_lm(xstart: ndarray[Any, dtype[float32]], xend: ndarray[Any, dtype[float32]], img: ndarray[Any, dtype[float32]], img_origin: ndarray[Any, dtype[float32]], voxsize: ndarray[Any, dtype[float32]], img_fwd: ndarray[Any, dtype[float32]], tofbin_width: float, sigma_tof: ndarray[Any, dtype[float32]], tofcenter_offset: ndarray[Any, dtype[float32]], nsigmas: float, tofbin: ndarray[Any, dtype[int16]], threadsperblock: int = 32, num_chunks: int = 1) None[source]
TOF Joseph 3D listmode forward projector
- Parameters:
xstart (XPFloat32Array (float32 numpy or cupy array)) – start world coordinates of the LORs, shape (nLORs, 3)
xend (XPFloat32Array (float32 numpy or cupy array)) – end world coordinates of the LORs, shape (nLORs, 3)
img (XPFloat32Array (float32 numpy or cupy array)) – containing the 3D image to be projected
img_origin (XPFloat32Array (float32 numpy or cupy array)) – containing the world coordinates of the image origin (voxel [0,0,0])
voxsize (XPFloat32Array (float32 numpy or cupy array)) – array containing the voxel size
img_fwd (XPFloat32Array (float32 numpy or cupy array)) – output array of size (xstart.shape[0] / nevents) for storing the forward projection
tofbin_width (float) – width of the TOF bin in spatial units (same units as xstart)
sigma_tof (XPFloat32Array (float32 numpy or cupy array)) – sigma of Gaussian TOF kernel in spatial units (same units as xstart) can be an array of length 1 -> same sigma for all LORs or an array of length nLORs -> LOR dependent sigma
tofcenter_offset (XPFloat32Array (float32 numpy or cupy array)) – center offset of the central TOF bin in spatial units (same units as xstart) can be an array of length 1 -> same offset for all LORs or an array of length nLORs -> LOR dependent offset
nsigmas (float) – number of sigmas to consider when Gaussian kernel is evaluated (truncated)
tofbin (XPShortArray) – array containing the tof bin of the events
threadsperblock (int, optional) – by default 32
num_chunks (int, optional) – break down the projection in hybrid mode into chunks to save memory on the GPU, by default 1
- parallelproj.backend.joseph3d_fwd_tof_sino(xstart: ndarray[Any, dtype[float32]], xend: ndarray[Any, dtype[float32]], img: ndarray[Any, dtype[float32]], img_origin: ndarray[Any, dtype[float32]], voxsize: ndarray[Any, dtype[float32]], img_fwd: ndarray[Any, dtype[float32]], tofbin_width: float, sigma_tof: ndarray[Any, dtype[float32]], tofcenter_offset: ndarray[Any, dtype[float32]], nsigmas: float, ntofbins: int, threadsperblock: int = 32, num_chunks: int = 1) None[source]
TOF Joseph 3D sinogram forward projector
- Parameters:
xstart (XPFloat32Array (float32 numpy or cupy array)) – start world coordinates of the LORs, shape (nLORs, 3)
xend (XPFloat32Array (float32 numpy or cupy array)) – end world coordinates of the LORs, shape (nLORs, 3)
img (XPFloat32Array (float32 numpy or cupy array)) – containing the 3D image to be projected
img_origin (XPFloat32Array (float32 numpy or cupy array)) – containing the world coordinates of the image origin (voxel [0,0,0])
voxsize (XPFloat32Array (float32 numpy or cupy array)) – array containing the voxel size
img_fwd (XPFloat32Array (float32 numpy or cupy array)) – output array of size (nLORs*ntofbins) for storing the forward projection
tofbin_width (float) – width of the TOF bin in spatial units (same units as xstart)
sigma_tof (XPFloat32Array (float32 numpy or cupy array)) – sigma of Gaussian TOF kernel in spatial units (same units as xstart) can be an array of length 1 -> same sigma for all LORs or an array of length nLORs -> LOR dependent sigma
tofcenter_offset (XPFloat32Array (float32 numpy or cupy array)) – center offset of the central TOF bin in spatial units (same units as xstart) can be an array of length 1 -> same offset for all LORs or an array of length nLORs -> LOR dependent offset
nsigmas (float) – number of sigmas to consider when Gaussian kernel is evaluated (truncated)
ntofbins (int) – total number of TOF bins
threadsperblock (int, optional) – by default 32
num_chunks (int, optional) – break down the projection in hybrid mode into chunks to save memory on the GPU, by default 1