corrct._projector_backends
Tomographic projector backends.
@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France
Module Contents
Classes
Base abstract projector backend class. All backends should inherit from this class. |
|
Projector backend based on scikit-image. |
|
Projector backend based on astra-toolbox. |
|
Experimental astra-toolbox functions projector. |
Functions
Compute the attenuation volume for the given local attenuation, and angle. |
API
- corrct._projector_backends.compute_attenuation(vol: numpy.typing.NDArray, angle_rad: float, invert: bool = False) numpy.typing.NDArray [source]
Compute the attenuation volume for the given local attenuation, and angle.
Parameters
vol : NDArray The local attenuation volume. angle_rad : float The angle along which to compute the attenuation. invert : bool, optional Whether to invert propagation direction. The default is False.
Returns
NDArray The attenuation volume.
- class corrct._projector_backends.ProjectorBackend[source]
Bases:
abc.ABC
Base abstract projector backend class. All backends should inherit from this class.
Initialization
Initialize base abstract projector backend class.
- vol_geom: corrct.models.VolumeGeometry
None
- vol_shape_zxy: numpy.typing.NDArray[numpy.integer]
None
- angles_w_rad: numpy.typing.NDArray[numpy.floating]
None
- prj_shape_vwu: numpy.typing.NDArray[numpy.integer]
None
- prj_shape_vu: numpy.typing.NDArray[numpy.integer]
None
- is_initialized: bool
None
- is_ready: bool
None
- initialize_geometry(vol_geom: corrct.models.VolumeGeometry, angles_rot_rad: Union[numpy.typing.ArrayLike, numpy.typing.NDArray], rot_axis_shift_pix: Union[numpy.typing.ArrayLike, numpy.typing.NDArray, None] = None, prj_geom: Optional[corrct.models.ProjectionGeometry] = None, create_single_projs: bool = False)[source]
Initialize the projector geometry.
Parameters
vol_geom : VolumeGeometry The volume geometry. angles_rot_rad : ArrayLike | NDArray The projection angles. rot_axis_shift_pix : float | NDArray | None, optional Relative position of the rotation center with respect to the volume center. The default is None. prj_geom : ProjectionGeometry, optional The fully specified projection geometry. When active, the rotation axis shift is ignored. The default is None. create_single_projs : bool, optional Whether to create projectors for single projections. Used for corrections and SART. The default is False.
- get_vol_shape() numpy.typing.NDArray [source]
Return the expected and produced volume shape (in ZXY coordinates).
Returns
NDArray The volume shape.
- get_prj_shape() numpy.typing.NDArray [source]
Return the expected and produced projection shape (in VWU coordinates).
Returns
NDArray The projection shape.
- make_ready() None [source]
Initialize the projector.
It should make sure that all the resources have been allocated.
- dispose() None [source]
De-initialize the projector.
It should make sure that all the resources have been de-allocated.
- __repr__() str [source]
Build a string representation of the projector backend.
Returns
str The representation of the projector.
- abstract fp(vol: numpy.typing.NDArray, angle_ind: Optional[int] = None) numpy.typing.NDArray [source]
Forward-project volume.
Forward-projection interface. Derived backends need to implement this method.
Parameters
vol : NDArray The volume to forward-project. angle_ind : int, optional The angle index to foward project. The default is None.
- abstract bp(prj: numpy.typing.NDArray, angle_ind: Optional[int] = None) numpy.typing.NDArray [source]
Back-project data.
Back-projection interface. Derived backends need to implement this method.
Parameters
prj : NDArray The sinogram to back-project or a single line. angle_ind : int, optional The angle index to foward project. The default is None.
- class corrct._projector_backends.ProjectorBackendSKimage[source]
Bases:
corrct._projector_backends.ProjectorBackend
Projector backend based on scikit-image.
Initialization
Initialize scikit-image projector backend class.
- initialize_geometry(vol_geom: corrct.models.VolumeGeometry, angles_rot_rad: Union[numpy.typing.ArrayLike, numpy.typing.NDArray], rot_axis_shift_pix: Union[numpy.typing.ArrayLike, numpy.typing.NDArray, None] = None, prj_geom: Optional[corrct.models.ProjectionGeometry] = None, create_single_projs: bool = False)[source]
Initialize projector backend based on scikit-image.
Parameters
vol_geom : VolumeGeometry The volume shape. angles_rot_rad : ArrayLike The projection angles. rot_axis_shift_pix : float | NDArray | None, optional Relative position of the rotation center with respect to the volume center. The default is None. NOT SUPPORTED: if anything else than None is passed, it will throw an error! prj_geom : ProjectionGeometry, optional The fully specified projection geometry. When active, the rotation axis shift is ignored. The default is None. NOT SUPPORTED: if anything else than None is passed, it will throw an error! create_single_projs : bool, optional Whether to create projectors for single projections. Used for corrections and SART. The default is False.
Raises
ValueError In case the volume dimensionality is larger than 2D, and if a rotation axis shift is passed.
- fp(vol: numpy.typing.NDArray, angle_ind: Optional[int] = None) numpy.typing.NDArray [source]
Forward-projection of the volume to the sinogram or a single sinogram line.
Parameters
vol : NDArray The volume to forward-project. angle_ind : int, optional The angle index to foward project. The default is None.
Returns
NDArray The forward-projected sinogram or sinogram line.
- bp(prj: numpy.typing.NDArray, angle_ind: Optional[int] = None) numpy.typing.NDArray [source]
Back-projection of a single sinogram line to the volume.
Parameters
prj : NDArray The sinogram to back-project or a single line. angle_ind : int, optional The angle index to foward project. The default is None.
Returns
NDArray The back-projected volume.
- class corrct._projector_backends.ProjectorBackendASTRA(super_sampling: int = 1)[source]
Bases:
corrct._projector_backends.ProjectorBackend
Projector backend based on astra-toolbox.
Initialization
Initialize the ASTRA projector backend.
Parameters
super_sampling : int, optional Super sampling factor for the pixels and voxels, by default 1.
- proj_id: List
None
- astra_vol_geom: Mapping
None
- proj_geom_ind: Sequence[Mapping]
None
- proj_geom_all: Mapping
None
- initialize_geometry(vol_geom: corrct.models.VolumeGeometry, angles_rot_rad: Union[numpy.typing.ArrayLike, numpy.typing.NDArray], rot_axis_shift_pix: Union[numpy.typing.ArrayLike, numpy.typing.NDArray, None] = None, prj_geom: Optional[corrct.models.ProjectionGeometry] = None, create_single_projs: bool = False)[source]
Initialize geometry of projector backend based on astra-toolbox.
Parameters
vol_geom : VolumeGeometry The volume shape. angles_rot_rad : ArrayLike The projection angles. rot_axis_shift_pix : float | NDArray | None, optional Relative position of the rotation center with respect to the volume center. The default is None. prj_geom : ProjectionGeometry, optional The fully specified projection geometry. When active, the rotation axis shift is ignored. The default is None. create_single_projs : bool, optional Whether to create projectors for single projections. Used for corrections and SART. The default is False.
Raises
ValueError In case the volume dimensionality is larger than 2D and CUDA is not available.
- _check_data(x: numpy.typing.NDArray, expected_shape: Union[Sequence[int], numpy.typing.NDArray[numpy.integer]]) numpy.typing.NDArray [source]
- fp(vol: numpy.typing.NDArray, angle_ind: Optional[int] = None) numpy.typing.NDArray [source]
Apply forward-projection of the volume to the sinogram or a single sinogram line.
Parameters
vol : NDArray The volume to forward-project. angle_ind : int | None, optional The angle index to forward project. The default is None.
Returns
NDArray The forward-projected sinogram or sinogram line.
- bp(prj: numpy.typing.NDArray, angle_ind: Optional[int] = None) numpy.typing.NDArray [source]
Apply back-projection of a single sinogram line to the volume.
Parameters
prj : NDArray The sinogram to back-project or a single line. angle_ind : int | None, optional The angle index to forward project. The default is None.
Returns
NDArray The back-projected volume.
- class corrct._projector_backends.ProjectorBackendDirectASTRA(super_sampling: int = 1)[source]
Bases:
corrct._projector_backends.ProjectorBackendASTRA
Experimental astra-toolbox functions projector.
Initialization
Initialize the ASTRA projector backend.
Parameters
super_sampling : int, optional Super sampling factor for the pixels and voxels, by default 1.
- astra_vol_shape: Sequence
None
- astra_prj_shape: Sequence
None
- astra_angle_prj_shape: Sequence
None
- angle_prj_shape: Sequence
None
- initialize_geometry(vol_geom: corrct.models.VolumeGeometry, angles_rot_rad: Union[numpy.typing.ArrayLike, numpy.typing.NDArray], rot_axis_shift_pix: Union[numpy.typing.ArrayLike, numpy.typing.NDArray, None] = None, prj_geom: Optional[corrct.models.ProjectionGeometry] = None, create_single_projs: bool = False)[source]
Initialize projector backend based on experimental astra-toolbox functions.
Parameters
vol_geom : VolumeGeometry The volume shape. angles_rot_rad : ArrayLike The projection angles. rot_axis_shift_pix : float, optional Relative position of the rotation center with respect to the volume center. The default is 0.0. geom : ProjectionGeometry, optional The fully specified projection geometry. When active, the rotation axis shift is ignored. The default is None. create_single_projs : bool, optional Whether to create projectors for single projections. Used for corrections and SART. The default is False.
Raises
ValueError In case CUDA is not available.
- fp(vol: numpy.typing.NDArray, angle_ind: Optional[int] = None)[source]
Apply forward-projection of the volume to the sinogram or a single sinogram line.
Parameters
vol : NDArray The volume to forward-project. angle_ind : int | None, optional The angle index to forward project. The default is None.
Returns
NDArray The forward-projected sinogram or sinogram line.
- bp(prj: numpy.typing.NDArray, angle_ind: Optional[int] = None)[source]
Apply back-projection of a single sinogram line to the volume.
Parameters
prj : NDArray The sinogram to back-project or a single line. angle_ind : int | None, optional The angle index to forward project. The default is None.
Returns
NDArray The back-projected volume.