corrct.projectors

Tomographic projectors.

@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France

Module Contents

Classes

ProjectorMatrix

Projector that uses an explicit projection matrix.

ProjectorUncorrected

Base projection class.

ProjectorAttenuationXRF

Attenuation corrected projection class for XRF, with multi-detector support.

Data

num_threads

astra_available

API

corrct.projectors.num_threads

‘round(…)’

corrct.projectors.astra_available

None

class corrct.projectors.ProjectorMatrix(A: numpy.typing.NDArray | scipy.sparse.spmatrix, vol_shape: numpy.typing.ArrayLike, prj_shape: numpy.typing.ArrayLike)[source]

Bases: corrct.operators.ProjectorOperator

Projector that uses an explicit projection matrix.

Initialization

Initialize the matrix projector.

Parameters

A : NDArray | spmatrix The projection matrix. vol_shape : ArrayLike Volume shape. prj_shape : ArrayLike Projection shape.

A: numpy.typing.NDArray | scipy.sparse.spmatrix

None

_transpose() corrct.operators.ProjectorOperator[source]

Create the transpose operator.

Returns

operators.ProjectorOperator The transpose operator.

absolute() corrct.operators.ProjectorOperator[source]

Return the projection operator using the absolute value of the projection coefficients.

Returns

operators.ProjectorOperator The absolute value operator.

fp(x: numpy.typing.NDArray) numpy.typing.NDArray[source]

Define the interface for the forward-projection.

Parameters

x : NDArray Input volume.

Returns

NDArray The projection data.

bp(x: numpy.typing.NDArray) numpy.typing.NDArray[source]

Define the interface for the back-projection.

Parameters

x : NDArray Input projection data.

Returns

NDArray The back-projected volume.

class corrct.projectors.ProjectorUncorrected(vol_geom: collections.abc.Sequence[int] | numpy.typing.NDArray[numpy.integer] | corrct.models.VolumeGeometry, angles_rot_rad: collections.abc.Sequence[float] | numpy.typing.NDArray, rot_axis_shift_pix: float | numpy.typing.ArrayLike | numpy.typing.NDArray | None = None, *, prj_geom: corrct.models.ProjectionGeometry | None = None, prj_intensities: numpy.typing.ArrayLike | None = None, psf: numpy.typing.ArrayLike | None = None, backend: str | corrct._projector_backends.ProjectorBackend = 'astra' if astra_available else 'skimage', create_single_projs: bool = False)[source]

Bases: corrct.operators.ProjectorOperator

Base projection class.

Initialization

Initialize the base projection class.

It implements the forward and back projection of the single lines of a sinogram. It takes care of initializing and disposing the ASTRA projectors when used in a with statement. It supports both 2D and 3D geometries.

Parameters

vol_geom : Sequence[int] | NDArray[np.integer] | models.VolumeGeometry The volume shape in Y X and optionally Z. angles_rot_rad : Sequence[float] | NDArray The rotation angles. rot_axis_shift_pix : float | ArrayLike | NDArray, optional The rotation axis shift(s) in pixels, by default None. prj_geom : models.ProjectionGeometry | None, optional The fully specified projection geometry. When active, the rotation axis shift is ignored, by default None. prj_intensities : ArrayLike | NDArray | None, optional Projection scaling factor, by default None. psf : ArrayLike | NDArray | None, optional The “point spread function” of the detector, by default None. backend : bool, optional Whether to use ASTRA or fall back to scikit-image. The default is True if CUDA and ASTRA are available, otherwise False. create_single_projs : bool, optional Whether to create projectors for single projections. Used for corrections and SART, by default False.

Raises

ValueError When the geometry is not correct.

vol_geom: corrct.models.VolumeGeometry

None

projector_backend: corrct._projector_backends.ProjectorBackend

None

prj_intensities: numpy.typing.NDArray[numpy.floating] | None

None

psf: numpy.typing.NDArray[numpy.floating] | float | None

None

property angles_rot_rad: numpy.typing.NDArray

Simplify access to the rotation angles (in radians).

Returns

NDArray The rotation angles (in radians).

__enter__()[source]

Initialize the with statement block.

__exit__(*args)[source]

De-initialize the with statement block.

_set_psf(psf: numpy.typing.ArrayLike | None, is_conv_symm: bool = False) None[source]
get_pre_weights() numpy.typing.NDArray | None[source]

Compute the pre-weights of the projector geometry (notably for cone-beam geometries).

Returns

NDArray | None The computed detector weights

fp_angle(vol: numpy.typing.NDArray, angle_ind: int) numpy.typing.NDArray[source]

Forward-project a volume to a single sinogram line.

Parameters

vol : NDArray The volume to forward-project. angle_ind : int The angle index to forward project.

Returns

x : NDArray The forward-projected sinogram line.

bp_angle(prj_vu: numpy.typing.NDArray, angle_ind: int) numpy.typing.NDArray[source]

Back-project a single sinogram line to the volume.

Parameters

prj_vu : NDArray The sinogram to back-project or a single line. angle_ind : int The angle index to forward project.

Returns

NDArray The back-projected volume.

fp(vol: numpy.typing.NDArray) numpy.typing.NDArray[source]

Forward-projection of the volume to the projection data.

Parameters

vol : NDArray The volume to forward-project.

Returns

NDArray The forward-projected projection data.

bp(prj_vwu: numpy.typing.NDArray) numpy.typing.NDArray[source]

Back-projection of the projection data to the volume.

Parameters

prj_vwu : NDArray The projection data to back-project.

Returns

NDArray The back-projected volume.

class corrct.projectors.ProjectorAttenuationXRF(vol_geom: collections.abc.Sequence[int] | numpy.typing.NDArray[numpy.integer] | corrct.models.VolumeGeometry, angles_rot_rad: collections.abc.Sequence[float] | numpy.typing.NDArray, rot_axis_shift_pix: float | numpy.typing.ArrayLike | numpy.typing.NDArray | None = None, *, prj_geom: corrct.models.ProjectionGeometry | None = None, prj_intensities: numpy.typing.ArrayLike | None = None, backend: str | corrct._projector_backends.ProjectorBackend = 'astra' if astra_available else 'skimage', att_maps: numpy.typing.NDArray[numpy.floating] | None = None, att_in: numpy.typing.NDArray[numpy.floating] | None = None, att_out: numpy.typing.NDArray[numpy.floating] | None = None, angles_detectors_rad: float | numpy.typing.ArrayLike = np.pi / 2, weights_detectors: numpy.typing.ArrayLike | None = None, psf: numpy.typing.ArrayLike | None = None, is_symmetric: bool = False, weights_angles: numpy.typing.ArrayLike | None = None, use_multithreading: bool = True, data_type: numpy.typing.DTypeLike = np.float32, verbose: bool = True)[source]

Bases: corrct.projectors.ProjectorUncorrected

Attenuation corrected projection class for XRF, with multi-detector support.

It includes the computation of the attenuation volumes.

Initialization

Initialize the (attenuation corrected) XRF dedicated projector.

Parameters

vol_geom : Sequence[int] | NDArray[np.integer] | models.VolumeGeometry The volume shape in X Y and optionally Z. angles_rot_rad : Sequence[float] | NDArray The rotation angles. rot_axis_shift_pix : float | ArrayLike | NDArray | None, optional The rotation axis shift(s) in pixels. The default is None. prj_geom : models.ProjectionGeometry | None, optional The fully specified projection geometry. When active, the rotation axis shift is ignored. The default is None. prj_intensities : ArrayLike | None, optional Projection scaling factor. The default is None. backend : str | prj_backends.ProjectorBackend, optional Projector backend to use, by default “astra” if astra is available, otherwise “skimage”. att_maps : NDArray[np.floating] | None, optional Precomputed attenuation maps for each angle, by default None att_in : NDArray[np.floating] | None, optional Attenuation volume of the incoming beam. The default is None. att_out : NDArray[np.floating] | None, optional Attenuation volume of the outgoing beam. The default is None. angles_detectors_rad : float | ArrayLike, optional Angles of the detector elements with respect to incident beam. The default is (np.pi / 2). weights_detectors : ArrayLike | None, optional Weights (e.g. solid angle, efficiency, etc) of the detector elements. The default is None. psf : ArrayLike | None, optional Optical system’s point spread function (PSF). The default is None. is_symmetric : bool, optional Whether the projector is symmetric or not. The default is False. weights_angles : ArrayLike | None, optional Projection weight for a given element at a given angle. The default is None. use_multithreading : bool, optional Whether to use multiple threads or not. The default is True. data_type : DTypeLike, optional Output data type. The default is np.float32. verbose : bool, optional Whether to produce verbose output. The default is True.

Raises

ValueError When given inconsistent numbers of detector weights and detector angles.

att_vol_angles: numpy.typing.NDArray[numpy.floating]

None

executor: concurrent.futures.ThreadPoolExecutor | None

None

__enter__()[source]

Initialize the with statement block.

__exit__(*args)[source]

De-initialize the with statement block.

collapse_detectors() None[source]

Convert multi-detector configurations into single-detector.

fp_angle(vol: numpy.typing.NDArray, angle_ind: int) numpy.typing.NDArray[source]

Forward-project the volume to a single sinogram line.

It applies the attenuation corrections.

Parameters

vol : NDArray The volume to forward-project. angle_ind : int The angle index to forward project.

Returns

sino_line : NDArray The forward-projected sinogram line.

bp_angle(sino: numpy.typing.NDArray, angle_ind: int, single_line: bool = False) numpy.typing.NDArray[source]

Back-project a single sinogram line to the volume.

It only applies the attenuation corrections if the projector is symmetric.

Parameters

sino : NDArray The sinogram to back-project or a single line. angle_ind : int The angle index to forward project. single_line : bool, optional Whether the input is a single sinogram line. The default is False.

Returns

NDArray The back-projected volume.

fp(vol: numpy.typing.NDArray) numpy.typing.NDArray[source]

Forward-project the volume to the sinogram.

It applies the attenuation corrections.

Parameters

vol : NDArray The volume to forward-project.

Returns

NDArray The forward-projected sinogram.

bp(sino: numpy.typing.NDArray) numpy.typing.NDArray[source]

Back-projection of the sinogram to the volume.

Parameters

sino : NDArray The sinogram to back-project.

Returns

NDArray The back-projected volume.