TomoJAX

tomojax.recon.api

Expert reconstruction helpers: method configuration, array and slab solvers.

The solvers and their configuration classes are exported by tomojax.recon; tomojax.reconstruct is the workflow entry point.

NameSummary
MethodConfig
clear_filter_cachesClear cached host filter coefficients.
default_fbp_scaleReturn the uniform half-turn angular weight pi / n_views.
method_configBuild a method configuration from defaults or named replacements.
reconstruct_arraysReconstruct projection arrays and return their solver record.
reconstruct_slabsReconstruct owned axial slabs from bounded corrected detector-row reads.
run_parallel_fbp_direct_cudaRun unscaled z-parallel FBP, retaining filtered tails through the volume.

MethodConfig

Defined in src/tomojax/recon/api.py:33

clear_filter_caches

clear_filter_caches() -> None
Defined in src/tomojax/recon/filters.py:135

Clear cached host filter coefficients.

default_fbp_scale

default_fbp_scale(n_views: int) -> float
Defined in src/tomojax/recon/fbp.py:83

Return the uniform half-turn angular weight pi / n_views.

fbp derives exact per-view weights by default; this constant is the uniform weight for an untilted half turn and the fallback for scans with too few views to define a rotation.

Parameters

  • n_views (int): Positive number of views in a uniform half turn.

Returns

  • float: Angular weight pi / n_views.

Raises

  • ValueError: If n_views is not positive.

method_config

method_config(
    method: str,
    *,
    config: MethodConfig | None = None,
    warm_start: bool | None = None,
    **settings: object,
) -> MethodConfig
Defined in src/tomojax/recon/api.py:73

Build a method configuration from defaults or named replacements.

fbp (FDK for cone beams) takes an FBPConfig, cgls a CGLSConfig, fista a FistaConfig and spdhg an SPDHGConfig; sirt takes SIRTConfig, mlem MLEMConfig and fourier FourierConfig. Each setting replaces the field of its name, as dataclasses.replace does. A config of another class, or a setting its class has no field for, raises ValueError naming the valid ones; so does warm_start for the direct methods (fbp, fourier), which start from nothing.

Parameters

  • method (str): Reconstruction method: "fbp", "fourier", "cgls", "fista", "spdhg", "sirt" or "mlem".
  • config (MethodConfig or None, optional): Existing configuration of the method's type. None uses its defaults.
  • warm_start (bool or None, optional): Whether the caller asked for a warm start; only the iterative methods take one.
  • **settings (object): Named fields replacing the corresponding configuration values.

Returns

  • MethodConfig: Configuration for the requested method with replacements applied.

Raises

  • ValueError: If method is unknown, config has the wrong type or a setting is unknown.

Examples

from tomojax.recon.api import method_config
method_config("cgls", iterations=20).iterations
# 20

reconstruct_arrays

reconstruct_arrays(
    method: str,
    geometry: Geometry,
    grid: Grid,
    detector: Detector,
    projections: jnp.ndarray | np.ndarray,
    *,
    config: MethodConfig | None = None,
    warm_start: bool = False,
    out: np.ndarray | None = None,
) -> tuple[jnp.ndarray | np.ndarray, dict[str, object]]
Defined in src/tomojax/recon/api.py:224

Reconstruct projection arrays and return their solver record.

config is the method's configuration (see method_config). warm_start starts the iterative methods from the FBP reconstruction, with calibrated per-view cone arrangements retained. The whole cone scan must cover an FDK-compatible arc. Returns the volume and its record: the config used, warm_start for the iterative methods and the solver's own record. FDK and FBP volumes too large for the device come back as host NumPy arrays, made in slabs (host_slabs). Independent axial SIRT/MLEM planes and their warm starts also use host slabs when needed. Coupled cone MLEM uses host-owned volume slabs when its device workspace does not fit. Fourier always returns host arrays in slabs. out supplies writable float32 host storage for FBP/FDK, Fourier, and cone-beam CGLS, SIRT and MLEM, and forces host slabs; it is returned without allocating another full volume.

Parameters

  • method (str): Reconstruction method accepted by method_config.
  • geometry (Geometry): Scan geometry, including angles and per-view poses.
  • grid (Grid): Reconstruction grid, with physical spacing in (x, y, z) order.
  • detector (Detector): Detector shape and placement in the same length unit as the grid.
  • projections (array-like): Line integrals of shape (views, nv, nu). For MLEM these represent nonnegative linear Poisson measurements, not raw transmission counts.
  • config (MethodConfig or None, optional): Method-specific configuration. None uses that method's defaults.
  • warm_start (bool, optional): Start iterative reconstruction from FBP or FDK. Default is False.
  • out (numpy.ndarray or None, optional): Writable float32 (nx, ny, nz) host storage for FBP/FDK, Fourier, or cone-beam CGLS, SIRT and MLEM. None lets the method select storage; other methods do not accept out.

Returns

  • volume (jax.Array or numpy.ndarray): Reconstruction of shape (nx, ny, nz); uses out itself if supplied.
  • record (dict): Configuration used, solver diagnostics and any host-slab or warm-start flags.

Raises

  • ValueError: If method, configuration, shapes or geometry are incompatible, warm_start is requested for a noniterative method, or out is unsupported.

reconstruct_slabs

reconstruct_slabs(
    method: str,
    geometry: Geometry,
    grid: Grid,
    detector: Detector,
    read: Callable[[int, int], tuple[jnp.ndarray | np.ndarray, T]],
    *,
    config: MethodConfig,
    warm_start: bool = False,
) -> Generator[ReconstructionSlab[T], None, None]
Defined in src/tomojax/recon/api.py:140

Reconstruct owned axial slabs from bounded corrected detector-row reads.

Parameters

  • method ({'fbp', 'fourier', 'sirt', 'mlem'}): Reconstruction method.
  • geometry (Geometry): Cone-beam FDK or unposed axial parallel-beam geometry.
  • grid (Grid): Output grid.
  • detector (Detector): Detector of the corrected rows.
  • read (callable): read(first_row, stop_row) returning corrected rows and the producer's context for that interval.
  • config (MethodConfig): Method configuration, as for tomojax.reconstruct.
  • warm_start (bool, optional): Start SIRT/OSEM from FBP. Default is False.

Returns

  • generator of ReconstructionSlab: Owned slabs in z order, each with its source interval and context.

Raises

  • ValueError: If the method or a setting does not support slabs.

run_parallel_fbp_direct_cuda

run_parallel_fbp_direct_cuda(
    T_all: jnp.ndarray,
    proj: jnp.ndarray,
    *,
    grid: Grid,
    detector: Detector,
    filter: str,
) -> jnp.ndarray
Defined in src/tomojax/recon/fbp.py:545

Run unscaled z-parallel FBP, retaining filtered tails through the volume.

Parameters

  • T_all (array-like): Object-to-world rigid poses of shape (views, 4, 4) for rotations about z.
  • proj (array-like): Line integrals of shape (views, nv, nu).
  • grid (Grid): Reconstruction grid with z slices aligned to detector rows.
  • detector (Detector): Canonical detector grid with rows aligned to voxel z slices.
  • filter (str): Frequency filter: "ramp", "shepp-logan" or "hann".

Returns

  • jax.Array: Unscaled float32 backprojection of shape (nx, ny, nz). Angular quadrature weights have not been applied.

Raises

  • ValueError: If shapes, poses or detector-row alignment are incompatible.

On this page