Repository navigation
TIGRE as a CT backend, chosen library-wide and recorded in the geometry - #397
Open
AnderBiguri wants to merge 2 commits into
Open
AnderBiguri wants to merge 2 commits into
AnderBiguri wants to merge 2 commits into
Conversation
CTProjectionOp(backend="tigre"): projection, matched backprojection,
autograd and FDK/FBP (TIGRE's, in torch) with TIGRE 3.3.0, on the tensors'
GPU. set_ct_backend() chooses the backend library-wide (tomosipo by
default); a geometry's backend ("default" unless set) is replaced by the
one used when the operator is made or the geometry saved, so records say
which backend made a result and loading uses it again. Operator.backend
says which library computes an operator.
SIRT and TV-min need tomosipo (require_ct_backend). DeepFusionBP asks its
single-angle operators for autograd() instead of calling tomosipo.
scripts/tigre_vs_tomosipo.py (to remove before merging) finds TIGRE's
angle/detector convention against tomosipo and compares agreement, speed
and memory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6n1VL9muzzcts6DAv9Vzm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6n1VL9muzzcts6DAv9Vzm
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First step of TIGRE as LION's CT backend (design: the project note
lion-tigre-backend-design.md). TIGRE 3.3.0 keeps PyTorch CUDA tensors on their GPU, so this is now possible; thetigreextra installs 3.3.1 (faster, same API).What it does
CTProjectionOp(backend="tigre"): projection (tigre.Ax, Siddon), backprojection (tigre.Atb,"matched", so it is the adjoint),autograd()(two smalltorch.autograd.Functions, batched), in LION's layout: images(1, H, W), sinograms(1, angles, detectors), the same as tomosipo. CUDA tensors stay on their GPU; CPU tensors go through NumPy. The TIGRE code is inLION/operators/ct/_tigre.py.tigre.utilities.filtering), then TIGRE's backprojection (FDK weights for fan beam), on the GPU, and differentiable withdifferentiable=True. It istigre.algorithms.fdk/fbpwithout Parker weights: LION's tomosipo FDK has none either.LION.operators.ct.set_ct_backend("tigre"); tomosipo stays the default until the comparison below.OperatorParameters.backend(generic) andGeometry.backend:"default"unless set, replaced by the backend used when the operator is made or the geometry saved (theinitial_reconstruction = "default"pattern). Every record that has the geometry (models, solvers, reconstructors, experiments, data records) says which backend was used, and loading makes the operator with it again, whatever the current setting.Operator.backend: which library computes an operator (None for torch-only ones).sirtandtv_minraise a clearNotImplementedErrorwith another backend (require_ct_backend). The 2DeteCT loader still uses ts_algorithms itself. Porting them is the next PR.autograd()instead of calling tomosipo'sto_autograditself. For tomosipo it is the same call, and it now works with TIGRE.import_tigre(LION/utils/tigre_import.py); atigreextra inpyproject.toml(TIGRE isn't on PyPI);tigrein the environment record's packages; atigrepytest marker; README, CHANGELOG, contributor guide.What changes for existing results
Nothing is computed differently: tomosipo is still the default. Saved geometries now have
"backend": "tomosipo".CTProjectionOp'sbackendargument now defaults to None (the geometry's), and its shapes come from the geometry rather than tomosipo (they are the same).Not verified yet: conventions and numbers (needs holly)
TIGRE can't be built here (no CUDA), so the LION-side code was tested with a stand-in TIGRE (a matrix): layout, adjointness, batching, autograd, FDK, records. The angle and detector conventions that make TIGRE's sinogram equal tomosipo's are my reading of the two libraries: TIGRE angle = LION angle − π/2, detector not flipped (
ANGLE_SIGN,ANGLE_OFFSET,FLIP_Uin_tigre.py). The script finds the right ones.On holly:
The script (internal: to remove before merging) prints:
_tigre.py, I'll change it.tigre.algorithms.fdk/fbp, and each backend's adjointness. It also savesfdk.png.--batch-sizes). torch's peak memory doesn't include TIGRE's own CUDA allocations, so it also reports the change in free GPU memory.Please send me the output and
results.json.Open (for after the numbers)
"interpolated"projection, and Parker weights for short scans in FDK.Generated by Claude Code