corrct.models
Define all the models used through-out the code.
@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France
Module Contents
Classes
Base geometry class. |
|
Store the projection geometry. |
|
Store the volume geometry. |
Functions
Combine vertical and horizontal shifts. |
|
Process the requested rotation axis direction and return a meaningful value. |
|
Generate the default geometry for parallel beam. |
|
Generate the default geometry for parallel beam. |
|
Generate a default volume geometry from the data shape. |
|
Generate a default volume geometry from the given volume. |
Data
API
- corrct.models.ROT_DIRS_VALID
(‘clockwise’, ‘counter-clockwise’)
- class corrct.models.ProjectionGeometry[source]
Bases:
corrct.models.Geometry
Store the projection geometry.
- geom_type: str
None
- src_pos_xyz: numpy.typing.NDArray
None
- det_pos_xyz: numpy.typing.NDArray
None
- det_u_xyz: numpy.typing.NDArray
None
- det_v_xyz: numpy.typing.NDArray
None
- rot_dir_xyz: numpy.typing.NDArray
None
- pix2vox_ratio: float
1
- det_shape_vu: Optional[numpy.typing.NDArray]
None
- __getitem__(indx: Any)[source]
Slice projection geometry along the angular direction.
Parameters
indx : Any Indices of the slicing.
- copy() corrct.models.ProjectionGeometry [source]
Deepcopy an existing geometry.
Returns
ProjectionGeometry The new instance of ProjectionGeometry
- static get_default_parallel(*, geom_type: str = '3d', rot_axis_shift_pix: Optional[numpy.typing.ArrayLike] = None, rot_axis_dir: Union[str, numpy.typing.ArrayLike] = 'clockwise') corrct.models.ProjectionGeometry [source]
Generate the default geometry for parallel beam.
Parameters
geom_type : str, optional The geometry type. The default is “parallel3d”. rot_axis_shift_pix : Optional[ArrayLike], optional Rotation axis shift in pixels. The default is None. rot_axis_dir : Union[str, ArrayLike], optional Rotation axis direction. It can be either a string or a direction. The default is “clockwise”.
Returns
ProjectionGeometry The default parallel-beam geometry.
- property ndim: int
Return the number of dimensions of the geometry.
Returns
int The number of dimensions.
- get_3d() corrct.models.ProjectionGeometry [source]
Return the 3D version of the geometry.
Returns
ProjectionGeometry The new geometry.
- set_detector_shape_vu(vu: Union[int, Sequence[int], numpy.typing.NDArray]) None [source]
Set the detector VU shape.
Parameters
vu : int | Sequence[int] | NDArray The VU shape of the projection data.
- set_detector_shifts_vu(det_pos_vu: Union[numpy.typing.ArrayLike, numpy.typing.NDArray, None] = None, cor_pos_u: Union[float, None] = None, det_dist_y: numpy.typing.ArrayLike = 0.0) None [source]
Set the detector position in XZ, from VU (vertical, horizontal) coordinates.
Parameters
det_pos_vu : ArrayLike | NDArray | None Detector vertical and horizontal positions. Vertical is optional. cor_pos_u : float | None Center of rotation position along U. det_dist_y : ArrayLike, optional Detector distance from origin along Y. The default is 0.0.
- set_source_shifts_vu(src_pos_vu: Union[numpy.typing.ArrayLike, numpy.typing.NDArray, None] = None) None [source]
Set the source position in XZ, from VU (vertical, horizontal) coordinates.
Parameters
src_pos_vu : ArrayLike | NDArray | None Source vertical and horizontal positions. Vertical is optional.
- set_detector_tilt(angles_t_rad: Union[numpy.typing.ArrayLike, numpy.typing.NDArray], tilt_axis: Union[Sequence[float], numpy.typing.NDArray] = (0, 1, 0), tilt_source: bool = False) None [source]
Rotate the detector by the given angle(s) and axis(axes).
Parameters
angles_t_rad : ArrayLike | NDArray Rotation angle(s) in radians. tilt_axis : Sequence[float] | NDArray, optional The tilt axis or axes. The default is (0, 1, 0) tilt_source : bool, optional Whether to also tilt the source. The default is False.
Notes
When applying multiple axes, they will be applied in order. This means that the application is not going to be independent.
- rotate(angles_w_rad: numpy.typing.ArrayLike, patch_astra_2d: bool = False) corrct.models.ProjectionGeometry [source]
Rotate the geometry by the given angle(s).
Parameters
angles_w_rad : ArrayLike Rotation angle(s) in radians.
Returns
ProjectionGeometry The rotated geometry.
- get_field_scaled(field_name: str) numpy.typing.NDArray [source]
Return the a field content, scaled by the pix2vox ratio.
Parameters
field_name : str Name of the field to access.
Returns
NDArray The scaled field.
- project_displacement_to_detector(disp_zyx: numpy.typing.ArrayLike) numpy.typing.NDArray [source]
Project a given displacement vector in the volume coordinates, over the detector.
Parameters
disp_zyx : ArrayLike The displacement vector in volume coordinates.
Returns
NDArray The projection on u (and if applicable v) coordinates.
Raises
ValueError When projection geometry and vector dimensions don match.
- get_pre_weights(det_shape_vu: Union[Sequence[int], numpy.typing.NDArray, None] = None) Union[numpy.typing.NDArray, None] [source]
Compute the pre-weights of the projector geometry (notably for cone-beam geometries).
Parameters
det_shape_vu : Sequence[int] | NDArray | None, optional Shape of the detector in [V]U coordinates, by default None
Returns
NDArray | None The computed detector weights
- class corrct.models.VolumeGeometry[source]
Bases:
corrct.models.Geometry
Store the volume geometry.
- _vol_shape_xyz: numpy.typing.NDArray
None
- vox_size: float
1.0
- is_square() bool [source]
Compute whether the volume is square in XY.
Returns
bool True is the volume is square in XY.
- property shape_xyz: numpy.typing.NDArray
Return the volume shape (XYZ).
Returns
NDArray Shape of the volume (XYZ).
- property shape_zxy: numpy.typing.NDArray
Return the volume shape (ZXY).
The swap between X and Y is imposed by the astra-toolbox.
Returns
NDArray Shape of the volume (ZXY).
- property mask_shape: numpy.typing.NDArray
Return the XY volume shape for circular masks.
Returns
NDArray Shape of the XY volume.
- property extent: Sequence[float]
Return extent of the volume.
Returns
Sequence[float] The extent of the volume [-x, +x, -y, +y, [-z, +z]].
- is_3D() bool [source]
Tell whether this is a 3D geometry.
Returns
bool Whether this is a 3D geometry or not.
- get_3d() corrct.models.VolumeGeometry [source]
Return the 3D version of the geometry.
Returns
VolumeGeometry The new geometry.
- static get_default_from_data(data: numpy.typing.NDArray, data_format: str = 'dvwu') corrct.models.VolumeGeometry [source]
Generate a default volume geometry from the data shape.
Parameters
data : NDArray The data. data_format : str, optional The ordering and meaning of the dimensions in the data. The deault is “dvwu”.
Returns
VolumeGeometry The default volume geometry.
- static get_default_from_volume(volume: numpy.typing.NDArray) corrct.models.VolumeGeometry [source]
Generate a default volume geometry from the given volume.
Parameters
volume : NDArray The volume.
Returns
VolumeGeometry The default volume geometry.
- corrct.models.combine_shifts_vu(shifts_v: numpy.typing.NDArray, shifts_u: numpy.typing.NDArray) numpy.typing.NDArray [source]
Combine vertical and horizontal shifts.
Parameters
shifts_v : NDArray The vertical shifts shifts_u : NDArray The horizontal shifts
Returns
NDArray The combined shifts
- corrct.models.get_rot_axis_dir(rot_axis_dir: Union[str, numpy.typing.ArrayLike, numpy.typing.NDArray] = 'clockwise') numpy.typing.NDArray [source]
Process the requested rotation axis direction and return a meaningful value.
Parameters
rot_axis_dir : Union[str, ArrayLike, NDArray], optional The requested direction, by default “clockwise”
Returns
NDArray The vector corresponding to the rotation direction.
Raises
ValueError In case of malformed direction.
- corrct.models._get_data_dims(data_shape: Union[Sequence[int], numpy.typing.NDArray], data_format: str = 'dvwu') dict[str, Union[int, None]] [source]
- corrct.models.get_prj_geom_parallel(*, geom_type: str = '3d', rot_axis_shift_pix: Union[numpy.typing.ArrayLike, numpy.typing.NDArray, None] = None, rot_axis_dir: Union[str, numpy.typing.ArrayLike, numpy.typing.NDArray] = 'clockwise', data_shape: Union[Sequence[int], numpy.typing.NDArray, None] = None, data_format: str = 'dvwu') corrct.models.ProjectionGeometry [source]
Generate the default geometry for parallel beam.
Parameters
geom_type : str, optional The geometry type. The default is “parallel3d”. rot_axis_shift_pix : ArrayLike | NDArray | None, optional Rotation axis shift in pixels. The default is None. rot_axis_dir : str | ArrayLike | NDArray, optional Rotation axis direction. It can be either a string or a direction. The default is “clockwise”.
Returns
ProjectionGeometry The default parallel-beam geometry.
- corrct.models.get_prj_geom_cone(*, src_to_sam_dist: float, rot_axis_shift_pix: Union[numpy.typing.ArrayLike, numpy.typing.NDArray, None] = None, rot_axis_dir: Union[str, numpy.typing.ArrayLike, numpy.typing.NDArray] = 'clockwise', data_shape: Union[Sequence[int], numpy.typing.NDArray, None] = None, data_format: str = 'dvwu') corrct.models.ProjectionGeometry [source]
Generate the default geometry for parallel beam.
Parameters
geom_type : str, optional The geometry type. The default is “parallel3d”. rot_axis_shift_pix : ArrayLike | NDArray | None, optional Rotation axis shift in pixels. The default is None. rot_axis_dir : str | ArrayLike | NDArray, optional Rotation axis direction. It can be either a string or a direction. The default is “clockwise”.
Returns
ProjectionGeometry The default cone-beam geometry.
- corrct.models.get_vol_geom_from_data(data: numpy.typing.NDArray, padding_u: Union[int, Sequence[int], numpy.typing.NDArray] = 0, data_format: str = 'dvwu', super_sampling: int = 1) corrct.models.VolumeGeometry [source]
Generate a default volume geometry from the data shape.
Parameters
data : NDArray The data. padding_u : int | Sequence[int] data_format : str, optional The ordering and meaning of the dimensions in the data. The default is “dvwu”. super_sampling: int, optional The super-sampling size of the voxels. The default is 1.
Returns
VolumeGeometry The default volume geometry.
- corrct.models.get_vol_geom_from_volume(volume: numpy.typing.NDArray) corrct.models.VolumeGeometry [source]
Generate a default volume geometry from the given volume.
Parameters
volume : NDArray The volume.
Returns
VolumeGeometry The default volume geometry.