Residual calculators

class mumott.methods.residual_calculators.GradientResidualCalculator(data_container, basis_set, projector, integration_samples=11, use_scalar_projections=False, scalar_projections=None)[source]

Class that implements the GradientResidualCalculator method. This residual calculator is an appropriate choice for SAXS tensor tomography, as it relies on the small-angle approximation. It relies on inverting the John transform (also known as the X-ray transform) of a tensor field (where each tensor is a representation of a spherical function) by comparing it to scattering data which has been corrected for transmission.

  • data_container (DataContainer) – Container for the data which is to be reconstructed.

  • basis_set (BasisSet) – The basis set used for representing spherical functions.

  • projector (Projector) – The type of projector used together with this method.

  • integration_samples (Optional, int) – Number of samples to use when calculating the mapping from the detector to the sphere. Defaults to 11, which is sufficiently dense without being computationally onerous. If a different method than binning detector pixels is used, e.g., fitting a function and selecting points from this function, a different nuimber, such as 1, may be a more appropriate choice.

  • use_scalar_projections (bool) – Whether to use a set of scalar projections, rather than the data in data_container.

  • scalar_projections (NDArray[float]) – If use_scalar_projections is true, the set of scalar projections to use. Should have the same shape as, except with only one channel in the last index.

property coefficients: ndarray[Any, dtype[_ScalarType_co]]

Optimization coefficients for this method.


Projects a residual gradient into coefficient and volume space. Used to get gradients from more complicated residuals, e.g., the Huber loss. Assumes that any weighting to the residual gradient has already been applied.


residual_gradient (ndarray[Any, dtype[float]]) – The residual gradient, from which to calculate the gradient.

Return type



An NDArray containing the gradient.

get_residuals(get_gradient=False, get_weights=False)[source]

Calculates a residuals and possibly a gradient between coefficients projected using the BasisSet and Projector attached to this instance.

  • get_gradient (bool) – Whether to return the gradient. Default is False.

  • get_weights (bool) – Whether to return weights. Default is False. If True along with get_gradient, the gradient will be computed with weights.

Return type



A dictionary containing the residuals, and possibly the gradient and/or weights. If gradient and/or weights are not returned, their value will be None.

property is_dirty: bool

True if stored hashes of geometry or basis set objects do not match their current hashes. Used to trigger updates

property probed_coordinates: ndarray[Any, dtype[_ScalarType_co]]

An array of 3-vectors with the (x, y, z)-coordinates on the reciprocal space map probed by the method. Structured as (N, K, I, 3), where N is the number of projections, K is the number of detector segments, I is the number of points to be integrated over, and the last axis contains the (x, y, z)-coordinates.


The region of the reciprocal space map spanned by each detector segment is represented as a parametric curve between each segment. This is intended to simulate the effect of summing up pixels on a detector screen. For other methods of generating data (e.g., by fitting measurements to a curve), it may be more appropriate to only include a single point, which will then have the same coordinates as the center of a detector segments. This can be achieved by setting the property integration_samples.