corrct.physics.attenuation
Incident beam and emidded radiation attenuation support.
@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France
Module Contents
Classes
Attenuation volume computation class. |
Functions
Compute the linear attenuation coefficient for given compound, energy, and pixel size. |
|
Plot spectral attenuation of a given line. |
|
Plot transmittance decay curve(s) for the given compound(s) at a given energy and thickness range. |
Data
API
- corrct.physics.attenuation.num_threads
‘round(…)’
- corrct.physics.attenuation.NDArrayFloat
None
- corrct.physics.attenuation.NDArrayInt
None
- corrct.physics.attenuation.CONVERT_UM_TO_CM
0.0001
- class corrct.physics.attenuation.AttenuationVolume(incident_local: Union[corrct.physics.attenuation.NDArrayFloat, None], emitted_local: Union[corrct.physics.attenuation.NDArrayFloat, None], angles_rot_rad: numpy.typing.ArrayLike, angles_det_rad: Union[corrct.physics.attenuation.NDArrayFloat, numpy.typing.ArrayLike, float] = np.pi / 2, dtype: numpy.typing.DTypeLike = np.float32)[source]
Attenuation volume computation class.
Initialization
Initialize the AttenuationVolume class.
Raises
ValueError In case no volumes were passed, or if they differed in shape.
- incident_local: Union[corrct.physics.attenuation.NDArrayFloat, None]
None
- emitted_local: Union[corrct.physics.attenuation.NDArrayFloat, None]
None
- angles_rot_rad: corrct.physics.attenuation.NDArrayFloat
None
- angles_det_rad: corrct.physics.attenuation.NDArrayFloat
None
- dtype: numpy.typing.DTypeLike
None
- vol_shape_zyx: numpy.typing.NDArray
None
- maps: numpy.typing.NDArray
None
- _compute_attenuation_angle_in(local_att: corrct.physics.attenuation.NDArrayFloat, angle_rad: float) numpy.typing.NDArray [source]
- _compute_attenuation_angle_out(local_att: corrct.physics.attenuation.NDArrayFloat, angle_rad: float) numpy.typing.NDArray [source]
- compute_maps(use_multithreading: bool = True, verbose: bool = True) None [source]
Compute the correction maps for each angle.
Parameters
use_multithreading : bool, optional Use multi-threading for computing the attenuation maps. The default is True. verbose : bool, optional Show verbose output. The default is True.
- plot_map(ax: matplotlib.axes._axes.Axes, rot_ind: int, det_ind: int = 0, slice_ind: Optional[int] = None, axes: Union[collections.abc.Sequence[int], corrct.physics.attenuation.NDArrayInt] = (-2, -1)) collections.abc.Sequence[float] [source]
Plot the requested attenuation map.
Parameters
ax : matplotlib axes The axes where to plot. rot_ind : int Rotation angle index. det_ind : int, optional Detector angle index. The default is 0. slice_ind : Optional[int], optional Volume slice index (for 3D volumes). The default is None. axes : Sequence[int] | NDArray, optional Axes of the slice. The default is (-2, -1).
Returns
Sequence[float] The extent of the axes plot (min-max coords).
Raises
ValueError In case a slice index is not passed for a 3D volume.
- get_maps(roi: Optional[numpy.typing.ArrayLike] = None, rot_ind: Union[int, slice, collections.abc.Sequence[int], corrct.physics.attenuation.NDArrayInt, None] = None, det_ind: Union[int, slice, collections.abc.Sequence[int], corrct.physics.attenuation.NDArrayInt, None] = None) numpy.typing.NDArray [source]
Return the attenuation maps.
Parameters
roi : ArrayLike, optional The region-of-interest to select. The default is None. rot_ind : int, optional A specific rotation index, if only one is to be desired. The default is None. det_ind : int, optional A specific detector index, if only one is to be desired. The default is None.
Returns
NDArray The attenuation maps.
- get_projector_args(roi: Optional[numpy.typing.ArrayLike] = None, rot_ind: Union[int, slice, collections.abc.Sequence[int], corrct.physics.attenuation.NDArrayInt, None] = None, det_ind: Union[int, slice, collections.abc.Sequence[int], corrct.physics.attenuation.NDArrayInt, None] = None) dict[str, numpy.typing.NDArray] [source]
Return the projector arguments.
Parameters
roi : ArrayLike, optional The region-of-interest to select. The default is None. rot_ind : int, optional A specific rotation index, if only one is to be desired. The default is None. det_ind : int, optional A specific detector index, if only one is to be desired. The default is None.
Returns
dict[str, NDArray] A dictionary containing the attenuation maps and the detector angle.
- corrct.physics.attenuation.get_linear_attenuation_coefficient(compound: Union[str, dict], energy_keV: float, pixel_size_um: float, density: Union[float, None] = None) float [source]
Compute the linear attenuation coefficient for given compound, energy, and pixel size.
Parameters
compound : Union[str, dict] The compound for which we compute the linear attenuation coefficient energy_keV : float The energy of the photons pixel_size_um : float The pixel size in microns density : Union[float, None], optional The density of the compound (if different from the default value), by default None
Returns
float The linear attenuation coefficient
- corrct.physics.attenuation.plot_emission_line_attenuation(compound: Union[str, dict], thickness_um: float, mean_energy_keV: float, fwhm_keV: float, line_shape: str = 'lorentzian', num_points: int = 201, plot_lines_mean: bool = True) None [source]
Plot spectral attenuation of a given line.
Parameters
compound : Union[str, dict] Compound to consider thickness_um : float Thickness of the compound (in microns) mean_energy_keV : float Average energy of the line fwhm_keV : float Full-width half-maximum of the line line_shape : str, optional Shape of the line, by default “lorentzian”. Options are: “gaussian” | “lorentzian” | “sech**2”. num_points : int, optional number of discretization points, by default 201 plot_lines_mean : bool, optional Whether to plot the line mean and the effective line mean, by default True
Raises
ValueError When an unsupported line is chosen.
- corrct.physics.attenuation.plot_transmittance_decay(compounds: Union[str, dict, collections.abc.Sequence[Union[str, dict]]], mean_energy_keV: float, thickness_range_um: tuple[float, float, int] = (0.0, 10.0, 101)) None [source]
Plot transmittance decay curve(s) for the given compound(s) at a given energy and thickness range.
Parameters
compounds : str | dict | Sequence[str | dict] The compound(s) description mean_energy_keV : float The mean photon energy thickness_range_um : tuple[float, float, int], optional The thickness range as (start, end, num_points), by default (0.0, 10.0, 101)