Fix xvr principal-point sign and DeepFluoro voxel origin #1
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1"
general
weight: 0.35
cdinea
Fixes the two geometry offsets behind the paired comparison: the Ljubljana horizontal offset that PR #73's offset-sign diagnostic exposed, and a smaller half-voxel offset in DeepFluoro. With both, Ljubljana's renders move onto their angiograms and DeepFluoro's structural agreement rises above the published numbers.
Results
All 382 views, rerun locally with the PR #73 protocol (
render_and_compare.py, same data revision and settings). Medians of per-subject medians:| | DeepFluoro gradient NCC | DeepFluoro NCC | Ljubljana gradient NCC | Ljubljana NCC | Ljubljana matched beats misposed |
|---|---:|---:|---:|---:|---:|
| PR #73 as published | 0.623 | 0.936 | 0.219 | 0.253 | 15/20 |
| Principal point only | 0.598 | 0.935 | 0.737 | 0.840 | 20/20 |
| This PR | 0.681 | 0.939 | 0.737 | 0.840 | 20/20 |
DeepFluoro still has 362/362 matched views beating their misposed controls. Residual misalignment (edge-based phase correlation, binned pixels) falls from 0.94 to 0.19 px RMS on DeepFluoro and from up to 92 px to 0.26 px RMS on Ljubljana, with no systematic shift left in either.
1. Detector geometry is set by its principal point
CarmGeometry.detector_offset_xy_mmdescribed how far the detector is displaced, which is the opposite of what calibrations store (where the perpendicular ray lands), so every adapter had to negate it. It is replaced byprincipal_point_px: the(column, row)pixel hit by the ray perpendicular to the detector, in the coordinatesproject_point_to_detectorreturns.Nonemeans the image centre. The renderer's mm offset is derived from it in one place; the shader is unchanged.detector_offset_xy_mmwas added in this PR stack and is not onmain.The xvr adapter passed
(x0, -y0), which mirrors the principal point horizontally. The storedx0/y0are principal-point offsets from the image centre along columns and rows. xvr itself negatesx0(only) before building DiffDRR's detector (xvr 4c68e0c, "Fix x0 principle point sign"). In DiffDRR 0.6.0 the detector grid reverses the row axis but not the column axis before adding the constructor offsets, so the raw stored values come out right in Y and mirrored in X. DiffDRR's ownintrinsicmatrix also disagrees with its renderer in Y. The adapter's DiffDRR agreement check passed because it fed DiffDRR the storedx0without xvr's negation.Measured on the 20 Ljubljana views before the fix, the horizontal render shift equals
2·x0/pitch(slope 0.998, r = 1.000, offsets −28 to +15 mm), and no vertical shift appears even where ay0sign error would give 11–13 px. DeepFluoro's offsets are half a native pixel (−0.097 mm), so they cannot distinguish the signs.2. DeepFluoro voxels sit where the xvr poses expect them
After fix 1, every DeepFluoro subject still sat about one binned pixel off its references, in the same direction for all six subjects. Fitting a constant 3D volume shift to the per-view residuals explains them better than a constant detector shift (0.22 vs 0.30 px RMS, from 0.94), giving +0.53/+0.46/+0.50 voxels along i/j/k (1 mm voxels). The DeepFluoro poses in this release therefore treat NIfTI indices as voxel corners, as DiffDRR does with
voxel_shift=0, which xvr's registration uses. Ljubljana's poses expect voxel centres: the same half-voxel shift worsens all 20 Ljubljana views.POSE_VOXEL_ORIGIN = {"deepfluoro": "corner", "ljubljana": "center"}records this.XvrView.cameraapplies it by offsetting the camera, because the renderer positions the C-arm relative to the volume centre, so moving the volume origin alone has no effect.XvrCamera.projectapplies the same offset, keeping fiducial projections consistent with renders. This is a property of the data release, not of the simulator: #72's voxel-centre fix concernsfrom_dicom/from_niftiand does not change this path (I checked a #72 + #73 merge: renders identical to 1e-5).Tests
cx = (W-1)/2 + x0/dx.principal_point_pxfor centred and off-centre principal points.gpu/slow, skipped unlessXVR_DATA_ROOTpoints to an xvr-data download): all 20 Ljubljana views must align within one binned pixel, and the median offset of eight views per DeepFluoro subject must stay below half a binned pixel. Against the previous adapter, all 10 Ljubljana and all 6 DeepFluoro subjects fail; with this PR all pass.Report
docs/reports/deepfluoro-ljubljana/is regenerated from a clean run at 9ebb85e (the numbers in the table above). Its README adds a "Changes since the previous report" section with the before/after table and both conventions. The offset-sign diagnostic is removed fromrender_and_compare.pyandbuild_local_report.py, since it would now render the old mirrored geometry. Patient and generated images remain local, as before.Upstream follow-ups
intrinsic/renderer mismatch.🤖 Generated with Claude Code