A simple projector using PyCUDA: the SimplePyCUDAProjector module

class nnfbp.SimplePyCUDAProjector.SimplePyCUDAProjector(recSize, angles)[source]

Bases: object

Implementation of the projector interface using PyCUDA and pyfft.

A projector needs to implement:

  • Forward projecting
  • Back projecting
  • Creating a FBP reconstruction with a custom filter

You can use this class as an abstracted weight matrix \(W\): multiplying an instance proj of this class by an image results in a forward projection of the image, and multiplying proj.T by a sinogram results in a backprojection of the sinogram:

proj = SimplePyCUDAProjector(...)
fp = proj*image
bp = proj.T*sinogram
Parameters:
  • recSize (int) – Width/height of the reconstruction volume. (only 2D squares are supported)
  • angles (numpy.ndarray) – Array with angles in radians.
backProject(sinogram=None, returnResult=True, clipCircle=False, singleAngle=None)[source]

Backproject a sinogram.

Parameters:
  • sinogram (numpy.ndarray) – The sinogram data. If None, use existing data on the GPU.
  • returnResult (bool) – Whether to return the result as a numpy.ndarray, or simply keep in on the GPU.
  • clipCircle (bool) – Whether to only reconstruct the unit disk.
  • singleAngle (int) – Only reconstruct using this angle. None if you want to reconstruct normally, using all angles.
Returns:

numpy.ndarray – The backprojection.

calcNextPowerOfTwo(val)[source]

Calculated the power of two larger than val. Used internally.

filterSinogram(filt, sinogram)[source]

Filter a sinogram sino with filter filt. Used internally.

forwProject(image=None, returnResult=True)[source]

Forward project an image.

Parameters:
  • image (numpy.ndarray) – The image data. If None, use existing data on the GPU.
  • returnResult (bool) – Whether to return the result as a numpy.ndarray, or simply keep in on the GPU.
Returns:

numpy.ndarray – The forward projection.

reconstructWithFilter(sinogram, filt, clipCircle=False, returnResult=True)[source]

Create a FBP reconstruction of the sinogram with a custom filter

Parameters:
  • sinogram (numpy.ndarray) – The sinogram data
  • filt (numpy.ndarray) – 1D custom filter
Returns:

numpy.ndarray – The reconstruction.

class nnfbp.SimplePyCUDAProjector.SimplePyCUDAProjectorTranspose(parentProj)[source]

Implements the proj.T functionality.

Do not use directly, since it can be accessed as member .T of an SimplePyCUDAProjector object.

Previous topic

A simple projector using the CPU: the SimpleCPUProjector module

Next topic

Reducing the data size: the Reductors module

This Page