Skip to content

CUDA Zeng forward and back projectors in RTK - #977

Open
CoConstan wants to merge 5 commits into
RTKConsortium:mainfrom
CoConstan:CudaZeng
Open

CUDA Zeng forward and back projectors in RTK#977
CoConstan wants to merge 5 commits into
RTKConsortium:mainfrom
CoConstan:CudaZeng

Conversation

@CoConstan

Copy link
Copy Markdown

Add CUDA Zeng forward and back projectors

Summary

This PR adds CUDA implementations of RTK's rotation-based Zeng forward and
back projectors for SPECT reconstruction. The implementation reproduces the
CPU Zeng slice recurrence, including the depth-dependent Gaussian point spread
function (PSF) and optional attenuation correction.

The new projectors operate on itk::CudaImage<float, 3> and keep their main
inputs and outputs on the GPU. They are available from C++, the command-line
applications, iterative reconstruction filters, and Python wrapping.

Main changes

  • Add rtk::CudaZengForwardProjectionImageFilter.
  • Add rtk::CudaZengBackProjectionImageFilter.
  • Add CUDA kernels for:
    • volume rotation and trilinear interpolation;
    • the Zeng forward and adjoint slice recurrences;
    • separable discrete Gaussian PSF convolution;
    • optional exponential attenuation.
  • Match the Gaussian coefficients generated by ITK's discrete Gaussian
    implementation, including Bessel-based coefficients, normalization, and
    constant-zero boundary behavior.
  • Keep volumes, projection stacks, attenuation maps, intermediate images, and
    outputs GPU-resident between CUDA filters.
  • Reuse persistent CUDA workspaces and cache geometry/PSF metadata for repeated
    iterative reconstruction subsets.
  • Use shared-memory tiles for the separable Gaussian convolution kernels.
  • Add CudaZeng to the forward/back projector selectors used by:
    • rtkforwardprojections;
    • rtkbackprojections;
    • iterative reconstruction filters;
    • Python applications.
  • Add Python wrapping for both CUDA filters.

Automated tests

The existing CUDA Zeng tests now cover:

  • functional forward projection;
  • output GPU residency;
  • forward/back adjointness with an active PSF;
  • adjointness with attenuation;
  • GPU residency with and without attenuation.

This PR also adds rtkZengProjectionComparisonCudaTest, which performs direct
CPU/CUDA comparisons using separate itk::Image and itk::CudaImage inputs.
It checks:

  • forward projection with SigmaZero=1.5 and Alpha=0.016;
  • backprojection with the same PSF;
  • attenuated forward projection with a uniform attenuation coefficient of
    0.01;
  • attenuated backprojection;
  • finite output values;
  • GPU residency before CPU comparison.

The comparison tolerances are:

Comparison Relative L2 tolerance
Forward projection 5e-5
Backprojection 5e-5
Attenuated forward projection 5e-4
Attenuated backprojection 2e-3

Measured values on the development system were:

Comparison Relative L2 error
Forward projection 1.31e-5
Backprojection 1.30e-5
Attenuated forward projection 2.31e-4
Attenuated backprojection 1.23e-3

Compute Sanitizer was also run on the forward projector, backprojector, and a
short OSEM reconstruction. It reported zero memory errors and zero leaked
bytes.

Performance

Application-level measurements were made on an NVIDIA RTX 3500 Ada Laptop GPU
using a 64 x 64 x 64 volume, 60 projections of 64 x 64 pixels, 4 mm
spacing, SigmaZero=1.5, and Alpha=0.016.

Operator CPU median CUDA median Speedup
Zeng forward projection 2.25 s 0.38 s 5.92x
Zeng backprojection 2.01 s 0.62 s 3.24x

An OSEM benchmark with five iterations and ten projections per subset produced
a median runtime of approximately 5.23 seconds. Persistent workspaces and
shared-memory convolution preserve bit-for-bit identical OSEM output compared
with the previous CUDA implementation.

Validation limitation of the local environment

The complete RTKCudaTestDriver cannot currently be linked in the development
environment because the installed older CudaCommon version fails while
compiling the unrelated 4D ROOSTER CUDA test. The new Zeng comparison and
adjointness test translation units compile successfully. A standalone driver
was used to execute the new comparison test, and all four comparisons passed.

This limitation is unrelated to the CUDA Zeng implementation and should not be
present with a current compatible ITK/CudaCommon build.

Comment thread src/rtkCudaZengBackProjectionImageFilter.cxx Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants