Skip to content

Focal spot, detector sampling and the intensity model - #20

Open
nHackel wants to merge 5 commits into
mainfrom
nh/focalspot
Open

nHackel wants to merge 5 commits into
mainfrom
nh/focalspot

Conversation

@nHackel

@nHackel nHackel commented Nov 15, 2026

Copy link
Copy Markdown
Member

Summary

  • sampled(op; source, detector) averages a projector over samples of the focal spot (FocalSpot) and of the detector cells (DetectorSampling). The result has the data size of op and its exact adjoint.
  • IntensityModel averages the intensities exp(-p) over the samples before the log, as a detector does. It comes with its Jacobian, the gradient of the least-squares objective, and IntensityGradient for first-order solvers of RegularizedLeastSquares.jl.
  • Breaking: MultiRay is no longer exported. SiddonProjector(image, MultiRay(geometry, points; weights)) becomes sampled(SiddonProjector(image, geometry); detector=DetectorSampling(points; weights)). The kernels are the same.
  • Docs: a how-to "Model the Focal Spot", the explanation page "Sampling the Beam" (renamed from "Several Rays per Cell"), and a consistency pass over all pages.

Sampling

  • FocalSpot(fu, fv=fu; points, weights=UniformWeights()): a spot of size fu × fv in the plane perpendicular to the central ray. The point strategy is required. The existing strategies work here too, and DiskPoints(rings, angles=6) adds circular spots.
  • DetectorSampling(points; weights=UniformWeights()): several rays per detector cell, with the strategies MultiRay took before.
  • How the samples are run (execution=:auto, :fused or :sequential):
    • Fused: Siddon's and Joseph's methods sample the detector cells in their kernels, as MultiRay did. The fused normal operator of LinearOperatorCollection.jl still applies.
    • Sequential: every other combination, and the focal spot for all projectors. sampled builds one projector per sample on a shifted geometry and sums them in a SampleSum, which holds a data and an image buffer.
    • The distance-driven projector refuses detector sampling, because its footprint already covers the cell.
    • Sequential detector sampling needs points that are the same in every cell (varies_per_cell).
  • Shifted geometries: ConeBeam and ParallelBeam stay plain geometries of their type. An ArcConeBeam becomes a Shifted geometry, whose detector does not move with the source. It has its own project_point for the voxel-driven projector.
  • stacked(op; source, detector) returns the projections of all samples side by side (SampleStack, with sample_weights).
  • Dispatch hooks (public, not exported): supports_sampling, fuses_sampling and varies_per_cell let projectors of other packages declare what they support.

Intensity model

  • IntensityModel(op; source, detector) evaluates p(x) = -log sum_k w_k exp(-(A_k x)) per data element, with a stable log-sum-exp.
  • CTOperators.jacobian(m, x) returns a SampleSum with weights per data element. SampleSum now accepts weights per data element as well as per view.
  • CTOperators.gradient!(g, m, x, y) computes the gradient of |p(x) - y|^2 / 2. IntensityGradient(m, y) wraps it as an operator, e.g. for FISTA(; AHA=G, rho).
  • The objective is in general not convex.

Docs

  • How-to "Model the Focal Spot" (fan beam, 2D):
    • the blur of a spot measured against the prediction from adding variances;
    • spot shapes;
    • reconstructions with and without the spot in the model;
    • intensity data reconstructed with the linear and with the intensity model.
  • Explanation "Sampling the Beam", now under Projection Methods: how points and weights are placed, the intensity model, and the focal spot. Its figures are computed with the package:
    • a disk in a cone beam;
    • detector images;
    • the shadows of single spot samples;
    • profiles.
  • "Use Several Rays per Cell" and "Write a Sampling Strategy" use the new API. The custom projector declares fuses_sampling.
  • Consistency pass over all pages:
    • outdated statements corrected;
    • citations checked against the papers;
    • numbers the pages quoted are now computed on the page;
    • stray output removed;
    • figures described.
    • FDK and detector sampling are now on the start page and in the README.
    • "Ordered Subsets and Normalization" is renamed to "Use Ordered Subsets and Normalizations".
    • References use full journal names.
    • Docstring examples for the new types.

Tests

  • Offsets and frames of the strategies, and shifted geometries.
  • Fused against sequential, with an error model for the end points.
  • Adjoints, subsets, masks, devices.
  • The blur of a box spot against its exact form, with a midpoint-rule error bound.
  • Intensity model:
    • Jensen's inequality;
    • the second-order term against the variance of the samples;
    • the Jacobian at 0 and against central differences;
    • the gradient.
  • The tests of several rays per cell moved to the new API, with the same invariants.

nHackel and others added 5 commits November 15, 2026 13:36
FocalSpot(fu, fv; points, weights) and DetectorSampling(points; weights) describe the samples of the
source and of the detector cells; DiskPoints places points in a disk for circular spots. sampled(op;
source, detector, execution) averages a projector over them: detector sampling in the kernels of
Siddon and Joseph (through MultiRay), otherwise one projector per sample on a shifted geometry,
summed in a SampleSum; stacked returns the samples side by side (SampleStack, sample_weights). shift
moves source and detector of ConeBeam and ParallelBeam; an ArcConeBeam becomes a Shifted geometry
whose detector stays fixed, with its own project_point for the voxel-driven projector.
supports_sampling, fuses_sampling and varies_per_cell decide by dispatch which projector does what.
Tests: offsets and frames, shifted geometries, fused against sequential with an error model,
adjoints, subsets, masks, the blur of a box spot against its exact form, devices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IntensityModel(op; source, detector) averages intensities over the samples before the log,
p(x) = -log sum_k w_k exp(-(A_k x)) per data element, on a SampleStack with a stable log-sum-exp from
broadcasts and reductions. jacobian gives its derivative as a SampleSum with weights per data element
(SampleSum now takes those as well as weights per view), gradient! the gradient J(x)' (p(x) - y), and
IntensityGradient that gradient as an operator for the solvers of RegularizedLeastSquares.jl that
take only a normal operator. Tests: Jensen's inequality, the second-order term against the variance
of the samples, the Jacobian at 0 and against central differences, the gradient, devices; each with
its error model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MultiRay is no longer exported: it is the internal geometry CellSampled, which sampled builds for
projectors that sample the cells in their kernel (Siddon, Joseph). Users write sampled(op;
detector=DetectorSampling(points; weights)); the point and weighting strategies serve detector
sampling and focal spots. The tests of several rays per cell use the new API with unchanged
invariants; the docs pages, the custom projector of "Write a Sampling Strategy" (which now declares
fuses_sampling) and the benchmark README follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Model the Focal Spot" shows the blur of a focal spot in a fan beam against the prediction by
variance addition, the shapes of a spot, and reconstructions with the linear and the intensity
model. "Sampling the Beam" (formerly "Several Rays per Cell", now after "Comparing Projectors")
adds the intensity model and the focal spot, with figures computed by the package: the scene, the
detector image, the shadows of the spot samples and profiles. Docstrings of the sampling types
and of IntensityModel cite De Man et al. (1999).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes from a review of all pages: outdated statements (FBP and Parker weights, the buffer of the
normal operator, distance-driven claims, Liu et al. 2017), citations (Miao for more rays, Parker for
redundancy weights), numbers that the pages now compute, stray output, figure descriptions, terms
and line lengths. References use full journal names and uniform headings. The start page and the
README list FDK and detector sampling; the ordered-subsets how-to is renamed to "Use Ordered
Subsets and Normalizations". Docstring examples for SampleSum, SampleStack, stacked,
IntensityModel and IntensityGradient.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant