For AI agents: see the complete TomoJAX documentation index at llms.txt. This page is also available as Markdown at https://tomojax.dev/api/corrections-api.md or by sending Accept: text/markdown.

tomojax.corrections.api

Expert correction helpers for streaming row-slab pipelines.

NameSummary
CorrectedRowsOwned device projections and their records, completed only when requested.
check_rowsCheck a half-open row interval in the binned output.
check_scan_stepsCheck that a line-integral scan still has the domains required by each step.
corrected_row_sourceRead corrected detector-row intervals without a materialized projection stack.
positive_finiteCheck a positive finite correction parameter.
preview_windowPropagate complete native output blocks backwards across the ordered corrections.
raw_cache_bytesEstimate the bytes held in the raw reader's two cached blocks and its prefetch.
slab_stepsCheck which corrections can run independently on complete detector rows.
validated_views_per_batchCheck the requested correction batch size.

CorrectedRows

class CorrectedRows(
    projections: jax.Array,
    flat: Correction,
    steps: tuple[Step, ...],
    epsilon: float,
    counts: tuple[jax.Array, jax.Array],
    raw: np.ndarray,
)
Defined in src/tomojax/corrections/_rows.py:106

Owned device projections and their records, completed only when requested.

Parameters

  • projections (jax.Array): Corrected line integrals of the requested rows, in (view, row, column) order.
  • flat (Correction): Record of the flat and dark normalization.
  • steps (tuple of Step): Corrections applied after normalization, in order.
  • epsilon (float): Floor applied to transmission before the logarithm.
  • counts (tuple of jax.Array): Device counts of nonpositive transmissions and of nonfinite results.
  • raw (numpy.ndarray): Raw detector counts read for these rows.

CorrectedRows.records

@property
records: tuple[Correction, ...]

Correction records for these measured rows, including any sampling halo.

Returns

  • tuple of Correction: Flat normalization, transmission steps, logarithm and line-integral steps.

Raises

  • ValueError: If any corrected value is not finite.

check_rows

check_rows(rows: tuple[int, int], native_rows: int, binning: int) -> None
Defined in src/tomojax/corrections/_validation.py:86

Check a half-open row interval in the binned output.

Parameters

  • rows (tuple of int): Requested start and exclusive stop.
  • native_rows (int): Native detector height.
  • binning (int): Number of native rows in an output row.

Raises

  • InvalidParameter: If the interval lies outside complete detector blocks.

check_scan_steps

check_scan_steps(steps: Sequence[Step]) -> None
Defined in src/tomojax/corrections/_validation.py:17

Check that a line-integral scan still has the domains required by each step.

Parameters

  • steps (sequence of Step): Corrections in user-supplied order.

Raises

  • InvalidParameter: If a step requires the original counts or transmission.

corrected_row_source

corrected_row_source(
    counts: Any,
    *,
    flats: Any,
    flat_positions: np.ndarray | None,
    darks: Any,
    white_level: float | None,
    steps: Sequence[Step],
    epsilon: float = 1e-06,
    view_positions: np.ndarray | None = None,
    exposure_times: np.ndarray | float | None = None,
    flat_exposure_times: np.ndarray | float | None = None,
    host: bool = False,
    dark_source: str | None = None,
    linear_limit: tuple[float, str] | None = None,
    flat_weights: FlatWeighting = FLAT_WEIGHTS,
) -> Iterator[Callable[[int, int], CorrectedRows | Corrected]]
Defined in src/tomojax/corrections/_rows.py:283

Read corrected detector-row intervals without a materialized projection stack.

Each request returns owned projections, independent of later reads and context closure. Only whole-row transmission and line-integral steps without view selection are supported; operations requiring neighboring rows must run on full frames. Raw inputs must be NumPy arrays or support lazy detector windows. The source and calibration arrays must remain unchanged until this context closes.

Parameters

  • counts (array-like): Detector counts with shape (views, rows, columns). May be a lazy source.
  • flats (array-like or None): Open-beam frames with shape (frames, rows, columns), or None when white_level supplies the open-beam count.
  • flat_positions (numpy.ndarray or None): Number of views recorded before each flat frame. Frames at the same position form one set; None puts all frames in one set.
  • darks (array-like or None): Dark frames with shape (frames, rows, columns); None uses zero dark.
  • white_level (float or None): Positive open-beam count used when flats is None.
  • steps (sequence of Step): Corrections, run by domain and in the supplied order within each domain.
  • epsilon (float, optional): Positive transmission floor before the logarithm. Default is 1e-6.
  • view_positions (numpy.ndarray or None, optional): Position of each view among the flats. Defaults to i + 0.5 for view i.
  • exposure_times (numpy.ndarray or float or None, optional): Sample exposure durations in seconds, one per view or a common duration.
  • flat_exposure_times (numpy.ndarray or float or None, optional): Flat exposure durations in seconds, one per flat or a common duration.
  • host (bool, optional): Return NumPy bands using bounded device view batches, instead of keeping the whole corrected band on the device. Default is False.
  • dark_source (str or None, optional): What removed the dark before the counts were recorded (a camera that subtracts it, say), kept in the record as dark_removed_by in place of a count of dark frames. Default None.
  • linear_limit (tuple of (float, str) or None, optional): The detector's stated linear range in counts and where it is stated. The record keeps the fraction of counts above it and the line integral where it ends, and a warning names both when any count lies above. Default None.
  • flat_weights ({'views', 'position'}, optional): How a view between two flat sets blends them, as for tomojax.corrections.correct_frames.

Yields

  • callable: Reader accepting a half-open row interval (first, stop) and returning corrected rows with their correction records. Use within a with block.

Raises

  • ValueError: If steps require full frames or select views, or calibration or positions are invalid.
  • TypeError: If counts lack detector-window access or a correction is not a Step.

positive_finite

positive_finite(value: float, name: str) -> float
Defined in src/tomojax/corrections/_validation.py:65

Check a positive finite correction parameter.

Parameters

  • value (float): Proposed value.
  • name (str): Field to identify in an error.

Returns

  • float: Validated value.

preview_window

preview_window(
    steps: Sequence[Step],
    shape: tuple[int, int],
    lower: int,
    upper: int,
    factor: int,
) -> tuple[slice, tuple[Step, ...]]
Defined in src/tomojax/corrections/_rows.py:54

Propagate complete native output blocks backwards across the ordered corrections.

Parameters

  • steps (sequence of Step): Corrections in their supplied order.
  • shape (tuple of int): Native detector rows and columns.
  • lower, upper (int): Half-open row bounds in the binned output.
  • factor (int): Native block size.

Returns

  • tuple: Native input interval and its locally registered correction steps.

raw_cache_bytes

raw_cache_bytes(counts: np.ndarray | FrameStack) -> int
Defined in src/tomojax/corrections/_rows.py:178

Estimate the bytes held in the raw reader's two cached blocks and its prefetch.

Parameters

  • counts (numpy.ndarray or FrameStack): Raw acquisition in (view, row, column) order. A lazy stack supplies its shape and dtype without reading detector pixels.

Returns

  • int: Bytes of resident counts for an array, or bytes of raw blocks cached for a file. In-flight transfers can retain older blocks.

slab_steps

slab_steps(steps: Sequence[Step]) -> list[tuple[str, Step]]
Defined in src/tomojax/corrections/_rows.py:258

Check which corrections can run independently on complete detector rows.

Parameters

  • steps (sequence of Step): Proposed raw corrections.

Returns

  • list of tuple: Domain and step pairs in pipeline order.

validated_views_per_batch

validated_views_per_batch(value: int | None) -> int | None
Defined in src/tomojax/corrections/_validation.py:43

Check the requested correction batch size.

Parameters

  • value (int or None): Positive view count or automatic selection.

Returns

  • int or None: Validated batch size.

On this page

TomoJAX