Skip to main content

Diff-FVR: Differentiable Fourier Volume Rendering

Research software for parallel-beam digitally reconstructed radiographs (DRRs) and biplanar 3D–2D registration. It precomputes a padded 3D Fourier transform, extracts a 2D frequency slice for each pose, and compares candidate projections using a spectral similarity objective. Optional modules explore gradients, articulated spine models, metal masking, and PyTorch acceleration.

Research prototype. Clinical accuracy and suitability for surgical navigation have not been established by the experiments in this repository.

Author: Pareel Amre · TU Dresden · pareel.amre@gmail.com License: MIT

What the experiments establish

The experiments/ directory contains 31 numbered simulation, real C-arm fluoroscopy, and NVIDIA A100 GPU benchmark studies (plus the 9b magnification approximation). These explore rendering speed and fidelity, registration convergence, noise, occlusion, truncation, articulation, motion, PyTorch/Triton/CUDAGraph acceleration, and multi-subject clinical cohort registration.

Experiments 7, 12, and 13 each use one source CT volume and multiple randomized poses. Their target images are generated by the same Fourier renderer used by the optimizer, with optional synthetic noise. They are same-renderer simulation tests, not registration against acquired fluoroscopy and not a multi-patient clinical validation. Other stress tests simulate selected image effects; their results do not demonstrate real-world robustness. mTRE uses eight synthetic volume landmarks, not annotated anatomical landmarks.

Historical CSVs and figures in outputs/paper_figures/ predate the physical-unit correction. CT-derived error values were computed in voxels while labeled mm; derived success rates and accuracy claims must be regenerated. The previous README's numerical accuracy and speed claims are withdrawn pending verified reruns with documented units, hardware, and an independent projection reference. See result limitations.

Real Paired C-Arm & DiffDRR Benchmark (Experiments 25–26)

Experiments 25 and 26 evaluate Diff-FVR against DiffDRR 0.6.1 (Siddon cone-beam raycasting) on real paired pelvic CT + physical C-arm fluoroscopy (DeepFluoro, subject01–subject06) with ground-truth SE(3) poses and 3D anatomical fiducials (128×128 interior crop, CPU):

  • Forward Speed & Perspective Fidelity (exp25, subject01, 10 views): 10.9 ms mean single-DRR latency (~92 FPS) vs. 1153.8 ms (~0.87 FPS) for DiffDRR 0.6.1 (106x mean speedup), with NCC(Diff-FVR, DiffDRR) = 0.9213–0.9863 (mean 0.9676).
  • Bi-Planar Real C-Arm Registration (exp25, subject01, 4 pairs, init 9.69 mm): Diff-FVR (35 steps) runs in 1.9 s (7.04 mm mean mTRE); a coarse-to-fine Hybrid (30 Diff-FVR + 15 DiffDRR) reaches 5.93 mm in 62.1 s, matching pure DiffDRR (5.95 mm in 103.3 s) with 40% lower runtime.
  • Multi-Subject Cohort (exp26, subject01–subject06, N=6): 88.3x mean forward speedup (14.7 ms vs. 1248.1 ms), mean NCC(Diff-FVR, DiffDRR) = 0.9550, 2.24 s mean Diff-FVR registration (6.04 mm), and 3.41 mm Hybrid (123.27 s) vs. 3.73 mm DiffDRR (157.97 s).

NVIDIA A100 GPU Benchmark, PoU-FVR Pareto Ablation (exp29), & Multi-Start Registration (exp30)

experiments/exp29_gpu_triton_and_ablation.py (verified on NVIDIA A100-SXM4-40GB, commit 53158de, Triton=True, zero OOM entries across all 135 (H, B, method) cells) benchmarks SE(3)-invariant ray-cached, fused-Triton (pou_pinhole_warp_sum), and CUDAGraph-captured PoU-FVR across H ∈ {128, 200, 256, 512} and B ∈ {1, 16, 64} against DiffDRR and nanodrr (n=500 and n=200 PyTorch and Triton/torch.compile kernels), with sequential micro-batching ([mb=16]) automatically engaged only where nanodrr torch at 512×512, B=64 would otherwise exceed 40 GB VRAM (93.75 GiB unchunked):

  • Cone-Beam Forward Latency & Memory (PoU-FVR Triton+CUDAGraph / PoU-FVR Triton, 2×2×2 bf16, 0.394 s 3D FFT prep):
    • 256×256, B=1: 0.108 ms CUDAGraph (9,254 FPS) / 1.241 ms eager (5.0 MB) — 152x faster than DiffDRR f32 (16.425 ms, 2,581.5 MB), 6.5x faster than nanodrr triton+compile (n=500) (0.707 ms), and 5.3x faster than n=200 (0.570 ms).
    • 256×256, B=64: 1.969 ms CUDAGraph (32,501 FPS) / 2.703 ms eager (320.0 MB) — 58.7x faster than nanodrr torch (115.53 ms, 32,144 MB), 7.25x faster than nanodrr triton+compile (n=500) (14.28 ms), and 3.06x faster than n=200 (6.03 ms).
    • 512×512, B=1: 0.114 ms CUDAGraph (8,738 FPS) — 11.8x faster than nanodrr triton+compile (n=500) (1.352 ms) and 7.3x faster than n=200 (0.835 ms).
    • 512×512, B=16: 0.576 ms CUDAGraph (27,773 FPS) / 1.386 ms eager (80.0 MB) — 195x faster than nanodrr torch (112.42 ms, 32,145 MB) and 24.7x faster than nanodrr triton+compile (n=500) (14.24 ms).
    • 512×512, B=64: 2.415 ms CUDAGraph (26,506 FPS) / 3.163 ms eager (320.0 MB) — 185x faster than nanodrr torch [mb=16] (446.13 ms, 32,193 MB), 23.0x faster than nanodrr triton+compile (n=500) (55.43 ms), and 9.4x faster than n=200 (22.65 ms).
  • Full End-to-End Differentiable fwd+bwd Training Throughput (PoU-FVR Triton vs. nanodrr triton n=500):
    • 256×256, B=16: 4.270 ms (80.0 MB) vs. 10.318 ms (2.42x).
    • 256×256, B=64: 7.074 ms (320.0 MB) vs. 38.836 ms (5.49x).
    • 512×512, B=16: 6.137 ms (80.0 MB) vs. 38.628 ms (6.29x).
    • 512×512, B=64: 21.843 ms (320.0 MB) vs. 150.999 ms (6.91x).
  • Parallel-Beam Dual-Domain Loss (TorchDiffFVR Zero-IFFT NCC, zero-IFFT in loop): Sustains 0.666–1.294 ms up to 256×256, B=64 (49,454 FPS, 96.0 MB) and 3.470 ms at 512×512, B=64 (18,445 FPS, 384.0 MB).
  • PoU-FVR Block / Resolution Pareto Ablation (H=256×256, sdd=1020 mm, B=1): Across 1×1×1 (0.63–0.98 MB, 1.20 ms, NCC=0.921–0.934), 2×2×2 (2.82–7.82 MB, 1.22–1.23 ms, NCC=0.926–0.942), 2×4×2 @ 48–96 (5.63–22.50 MB, 1.23–1.26 ms, NCC=0.932–0.955, EdgeNCC=0.508–0.746), and 4×4×2 @ 80 (31.25 MB, 1.26 ms, NCC=0.9633, EdgeNCC=0.7319), fused-Triton forward latency stays nearly flat at 1.20–1.26 ms vs. synthetic ray-marching ground truth.
  • Bi-Planar B=64 Multi-Start GPU Registration (exp30, 10 DeepFluoro trials, mean init 15.79 mm, 50 steps): With warmup_pinhole and dynamic Triton loops eliminating Trial-1 cold-start recompilation (2.129 s on Trial 1):
    • PoU-FVR Triton (2×4×2@80 bf16): 0.950 mm mean mTRE (0.848 mm median), 100% < 2 mm, 2.161 s mean (2.11–2.20 s across all 10 trials), 1,348 MB peak VRAM (2.79x faster than nanodrr triton+compile).
    • Hybrid PoU-Triton + nanodrr polish: 1.495 mm mean mTRE (1.475 mm median), 100% < 2 mm, 1.341 s mean (1.15–1.24 s steady-state), 464 MB peak VRAM (4.50x faster than nanodrr triton+compile).
    • nanodrr triton+compile (bf16 n=500): 1.503 mm mean mTRE, 100% < 2 mm, 6.035 s mean, 355 MB peak VRAM.
    • nanodrr torch (f32 n=500): OOM at B=64 during autograd on all trials.
  • 6-Subject Real Clinical DeepFluoro GPU Cohort (exp31, subject01–subject06, 18 trials, mean init 12.00 mm, H=256, B=64): True-pose cone-beam forward parity spans NCC = 0.9782–0.9986 across all 6 patients.

Projection geometry and physical units

  • RobustDiffFVREngine accepts a cubic, isotropic volume and spacing (Z, Y, X) in mm. Its poses use (yaw, pitch, roll, tx, ty, tz), with rotations in degrees and translations/bounds in mm.
  • The CLI preserves CT spacing while resampling to an isotropic cube that fits the longest physical dimension. NPY input contains HU values and defaults to one mm per voxel; use --spacing-mm Z Y X when this differs. DICOM spacing comes from its metadata.
  • AP projects along Y, with X horizontal and Z vertical. Lateral projects along X, with Y horizontal and Z vertical. Targets must already match the rendered image shape, orientation, pixel spacing, and field of view. Arbitrary acquired X-rays are not automatically calibrated, rescaled, or registered in patient DICOM coordinates.
  • This is a parallel-beam engine. SDD/SAD settings now raise an error rather than being silently ignored. render_calibrated_drr retains its legacy name for compatibility; it performs no cone-beam or perspective correction. Experiment 9b's isocenter scaling is an approximation, not a general calibration model. Full cone-beam geometry requires a separate implementation and validation.
  • Low-level NumPy renderers, the original experimental registration engines, and gradients retain their existing voxel-coordinate conventions. They do not share the robust core's mm API. compute_mtre_6dof returns mm when passed measured spacing; use translation_units='mm' for robust-core poses, or the default 'voxels' for low-level poses. Omitted spacing assumes 1 mm. The optional Torch backend is a separate experimental implementation; physical coordinate parity with the robust core has not been established.

Compatibility changes: the robust core interprets translations as mm even when spacing differs from 1 mm; explicit SDD/SAD configuration is rejected. fvr.cli.load_volume now returns (attenuation_volume, spacing_zyx_mm). Failed CLI optimization writes success: false and exits with status 1; optimizer convergence alone does not establish registration accuracy.

Install and try a simulation

pip install -e .

# Generate two synthetic targets on the same grid (parallel-beam model).
fvr-render --ct data/dicom --res 96 --view ap --tx 4 --ty 2 --tz 3 --out outputs/example_ap.png
fvr-render --ct data/dicom --res 96 --view lateral --tx 4 --ty 2 --tz 3 --out outputs/example_lat.png

# Recover the pose from those simulated targets.
fvr-register --ct data/dicom --res 96 --ap outputs/example_ap.png --lat outputs/example_lat.png --out outputs/example_pose.json

# Focused synthetic regressions and CT-based integration smoke test.
python tests/test_physical_units.py
python tests/test_core_engine.py

Optional Torch support: pip install -e '.[torch]'. Run its tests with python tests/test_torch_engine.py; CUDA availability is environment dependent.

The browser demonstration is a scripted illustration with synthetic images and an interpolated convergence animation. It does not execute the Python registration engine or measure clinical accuracy.

Repository

src/fvr/ contains renderers, registration, metrics, DICOM loading and CLI code; tests/ contains synthetic regressions and integration scripts; experiments/ contains simulation studies; docs/ contains the illustrative browser demo; outputs/exp29_*.csv, outputs/exp30_*.csv, and outputs/exp31_*.csv store the verified NVIDIA A100 GPU benchmark, PoU-FVR Pareto, multi-start registration, and 6-subject DeepFluoro cohort tables; outputs/paper_figures/ contains historical generated results.

Metadata

Release files for diff-fvr 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diff-fvr 1.1.1
File Size Uploaded Provenance Actions
diff_fvr-1.1.1.tar.gz 57.2 kB With provenance Details for diff_fvr-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for diff-fvr 1.1.1
File Interpreter ABI Platform Actions
diff_fvr-1.1.1-py3-none-any.whl Python 3 none any Details for diff_fvr-1.1.1-py3-none-any.whl

Total release size: 112.3 kB

Release files / diff_fvr-1.1.1.tar.gz

Download URL diff_fvr-1.1.1.tar.gz
Size 57.2 kB
Tags Source
SHA-256 checksum
How to use checksums
433d2469d8934907acf30222fa4f33a40f8660a462057591e40a74469721a98d
BLAKE2b-256 checksum
How to use checksums
619b986f51bb720d380a46588f6cfe2382835ac8d4ef3d88b3b0f2afbb4ec6d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / diff_fvr-1.1.1-py3-none-any.whl

Download URL diff_fvr-1.1.1-py3-none-any.whl
Size 55.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb91a8593730a6cc667876756d2d120d97a8e89fd00da99037d7c820e3543ae7
BLAKE2b-256 checksum
How to use checksums
4abf6bf1d3666e6eda46d2daa889d2c457182dbdef1ea86841f8f6cffa934ded
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for diff-fvr 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for diff_fvr-1.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page