vamtoolbox.projector.pyTorchAlgebraicPropagation#

Module Contents#

Classes#

PyTorchAlgebraicPropagator

CPU/GPU implementation with pyTorch.

class vamtoolbox.projector.pyTorchAlgebraicPropagation.PyTorchAlgebraicPropagator(target_geo, proj_geo, output_torch_tensor=False, dtype=torch.float32)#

CPU/GPU implementation with pyTorch. The operator automatically identify the z-size mismatch (if there is any, and apply to all the layers.)

This operator is the A in Ax = b, or the P in Pf = g, where x or f is the real space object (flattened into 1D array) and b or g is the sinogram (flattened into 1D array).

Notes: Due to the demanding memory requirement in this algebraic propagation approach, it is often to only create projection matrix in 2D and apply it to both 2D and 3D problems. In this simplified case of decoupling a 3D problem into many 2D problems, the imported sparse matrix is only required to encode projection process of one z-layer.

Therefore, the number of real space voxels only has to be equal to the integer multiples of the number of columns in imported sparse matrix (.py or .npz). This requirement reads as (x.size % A.shape[1]) == 0. For example, x.size = 256 * A.shape[1] when there are 256 z-layers but A only encode projection of one layer.

As in other projectors, the size of the sinogram is determined by the projection process itself. Forward propagation using this method produce sinogram that has the size of (number of rows of sparse propagation matrix * number of z-layer tiling) Continuing from above example, it reads b.size = A.shape[0]*256

Vice versa, Backpropagation process will check for (b.size % A.shape[0]) == 0

Current implementation store sparse matrix in CSR format for fast matrix-vector multiplication. #TODO: Enable performance mode to optionally allow explicit storage of adjoint of the matrix also in CSR (instead of CSC).

forward(x)#
backward(b)#