English · 简体中文
Differentiable CT operators for measured scanner geometry.
Project volumes, backproject measurements, reconstruct images and calibrate scanner geometry in PyTorch, from CPU experiments to multi-node CUDA execution.
The video shows trajectories, autograd, geometry gradients, multi-GPU execution and reconstruction from measured walnut data · MP4.
Walnut data: Meaney 2022, Zenodo 6986012, CC BY 4.0; see examples/data/NOTICE.
Operators · Reconstruction · Clinical CT · Scaling · Installation · Documentation
Version 2.x uses per-view trajectories. Code written for 1.x needs migration. This README tracks the source checkout. Features under Unreleased require installation from source.
diffct gives PyTorch a matched pair of CT projection operators. The trajectory tensors specify a ray direction or source position for each view, together with the detector centre and axes. Circular, helical, saddle, calibrated and measured clinical trajectories use the same tensor format.
To our knowledge, diffct is the only open-source GPU CT library with arbitrary per-view trajectories, autograd through the volume, first-order geometry gradients, and multi-node execution. We checked LEAP, TIGRE, ASTRA/tomosipo, DiffDRR and other libraries in October 2026.
- Matched adjoint.
project()andbackproject()implement the cell-constant Siddon model as an exact adjoint pair.project()supports gradients with respect to the input volume, andbackproject()with respect to the input measurements. Both support Hessian-vector products. - Measured geometry. Per-view source positions can include flying focal spot offsets.
ParameterizedSurfacedescribes cylindrical and other curved detectors without rebinning. - Reconstruction.
cgls,sirt,tv_reconstruction, differentiable FBP/FDK and gradient-based optimization share the same operators. Differentiable FBP/FDK can learn filters and weights. The projection operators can supply volume gradients for optimization. - Scale. Automatic chunking, disk-backed state and distributed execution let diffct reconstruct scans that exceed one GPU's memory.
Technical report: diffct: Differentiable CT Operators from Circular Orbits to Arbitrary Trajectories.
The figure compares analytical and iterative reconstruction. The input is a noiseless 120-view fan-beam scan simulated from a clinical abdominal slice of Mayo liver case L213. The reference panel is the vendor image. The other panels show FBP and three iterative methods. SIRT uses 200 iterations, CGLS 30 iterations and TV-regularized reconstruction 300 iterations with weight 0.3.
Patient image source: Mayo Clinic LDCT-and-Projection-data, liver case L213, CC BY 4.0.
diffct reconstructs the measured helical scan of liver case L213. The GE scan has 7,140 full-dose projection views on an 888 × 64 cylindrical detector. The rows show axial, coronal and sagittal sections. The columns compare the vendor image, Adam least-squares reconstruction, SIRT, CGLS and TV-regularized reconstruction. Adam and TV use 150 iterations, SIRT 100 iterations and CGLS 15 iterations. TV uses weight 3. The reconstruction grid uses 0.652 mm voxels in plane and 3 mm voxels along the scan axis.
Patient data: McCollough et al., Low Dose CT Image and Projection Data (LDCT-and-Projection-data), Version 7, The Cancer Imaging Archive, 2020, 10.7937/9npb-2637. Dataset paper: Moen et al., Medical Physics, 2020, 10.1002/mp.14594. Chest and Liver subsets: CC BY 4.0; see docs/assets/gallery/NOTICE.
The benchmark uses a 512³ FP32 volume, A100 64 GB GPUs, a circular cone beam, 360 views, a 1024 × 768 detector and pitch 1.25.
| 512³ volume | 1 GPU | 4 GPUs, 1 node | 8 GPUs, 2 nodes |
|---|---|---|---|
| Forward projection | 566.79 ms | 150.76 ms (3.8×) | 81.58 ms (6.9×) |
| Adjoint (backprojection) | 1060.77 ms | 279.37 ms (3.8×) | 224.04 ms (4.7×) |
| CGLS iteration | 1753.73 ms | 468.09 ms (3.7×) | 337.39 ms (5.2×) |
The performance guide gives the methodology, chart and raw samples. For more reconstructions, see the examples.
diffct needs Python 3.10 or newer. Install PyTorch for your device.
For native NVIDIA CUDA execution, check the CUDA version of the PyTorch build:
python -c "import torch; print(torch.version.cuda)"When torch.version.cuda is 12.x, run:
pip install "diffct[cu12]"When torch.version.cuda is 13.x, run:
pip install "diffct[cu13]"For CPU, PyTorch ROCm or Apple Silicon, install diffct without an extra:
pip install diffct
Select backend="torch" for the portable backend. Apple Silicon uses the built-in MPS support. A community MLX port by Linda-Sophie Schneider also exists. CUDA compatibility notes and source installation: installation guide.
Create one projector. Project the image and backproject the measurements. Then compute the loss gradient with respect to the image estimate:
import torch from diffct import Projector, circular_trajectory_2d_parallel trajectory = circular_trajectory_2d_parallel(180, device="cpu") A = Projector(trajectory, (64, 64), 96, beam="parallel", detector_spacing=1.0, voxel_spacing=1.0) image = torch.zeros(A.volume_shape, device="cuda", dtype=torch.float32) image[20:44, 20:44] = 1.0 measurements = A.project(image) # (180, 96) adjoint = A.backproject(measurements) # (64, 64), not an inverse estimate = torch.zeros_like(image, requires_grad=True) loss = 0.5 * (A.project(estimate) - measurements).square().sum() loss.backward() print(measurements.shape, estimate.grad.shape)
Expected output: torch.Size([180, 96]) torch.Size([64, 64]). CPU and Apple Silicon variants are in the quickstart guide.
Quickstart · Trajectories and geometry · Clinical helical CT · Mayo public datasets · Multi-GPU · API reference · Examples
If you use diffct in your research, cite both the software and the technical report. Machine-readable metadata is in CITATION.cff.
BibTeX
@software{diffct2025, author = {Yipeng Sun}, title = {diffct: Differentiable Computed Tomography Reconstruction with CUDA}, year = 2025, publisher = {Zenodo}, doi = {10.5281/zenodo.14999333}, url = {https://doi.org/10.5281/zenodo.14999333} } @article{202605.1446, doi = {10.20944/preprints202605.1446.v2}, url = {https://doi.org/10.20944/preprints202605.1446.v2}, year = 2026, month = {Oct}, publisher = {Preprints}, author = {Yipeng Sun and Linda-Sophie Schneider and Chengze Ye and Andreas Maier}, title = {diffct: Differentiable CT Operators from Circular Orbits to Arbitrary Trajectories}, journal = {Preprints} }
Apache 2.0, see LICENSE. The project draws on PYRO-NN and geometry_gradients_CT. Issues and pull requests are welcome.
