tomosipo.geometry.det_vec module
Vector geometry containing just the detector
The class in this file can be encapsulated by ConeVectorGeometry and ParallelVectorGeometry.
- class tomosipo.geometry.det_vec.DetectorVectorGeometry(shape, det_pos, det_v, det_u)[source]
Bases:
ProjectionGeometryA class for representing detector vector geometries.
This class is a helper for the ConeVectorGeometry and ParallelVectorGeometry. It represents the detector part of these geometries. It does not have any references to a source or ray directions.
- property angles
The angles from which projections are acquired.
This property is specific to non-vector geometries.
- Returns:
A numpy array of shape with length num_angles containing the angles in radians.
- Return type:
np.array
- property corners
Returns a vector with the corners of each detector
- Returns:
np.array Array with shape (num_angles, 4, 3), describing the 4 corners of each detector in (Z, Y, X)-coordinates.
- Return type:
np.array
- property det_normal
The detector normal vectors of the geometry.
In tomosipo, the normal vector usually points “into” the detector and away from the source/object. It is orthogonal to the v and u vectors.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the normal vectors.
- Return type:
- property det_pos
The detector positions of the geometry.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the detector positions.
- Return type:
- property det_size
The size of the detector.
This property is dangerous for vector geometries, because for vector geometries it is not guaranteed that the detector size is constant through time. If the detector size is not constant, this property raises a ValueError. Otherwise, it returns the detector size.
- Returns:
The absolute size of the detector in the v and the u direction.
- Return type:
(scalar, scalar)
- property det_sizes
The size of each detector.
- Returns:
np.array Array with shape (num_angles, 2) in v and u direction (height x width)
- Return type:
np.array
- property det_u
The detector u-vectors of the geometry.
The ‘u’ vector is usually the “sideways” pointing vector describing the distance from the (0, 0) to (0, 1) pixel.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the u vectors.
- Return type:
- property det_v
The detector v-vectors of the geometry.
The ‘v’ vector is usually the “upward” pointing vector describing the distance from the (0, 0) to (1, 0) pixel.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the v vectors.
- Return type:
- from_astra()[source]
- property lower_left_corner
Returns a vector with the positions of the lower-left corner the detector
- Returns:
np.array Array with shape (num_angles, 3), describing the position of the lower-left corner of each detector in (Z, Y, X)-coordinates.
- Return type:
np.array
- property num_angles
The number of angles in the projection geometry
- Returns:
The number of angles in the projection geometry.
- Return type:
integer
- project_point(point)[source]
Projects point onto detectors
This function projects onto the virtual detectors described by the projection geometry.
For each source-detector pair, this function returns
(detector_intersection_y, detector_intersection_x)
where the distance is from the detector origin (center) and the units are in detector pixels.
This function returns np.nan if the source-point ray is parallel to the detector plane.
This function projects onto the detector even if the ray is moving away from the detector instead of towards it, or if the detector is between the source and point instead of behind the point.
- Parameters:
point – A three-dimensional vector (preferably np.array)
- Returns:
np.array([[detector_intersection_y, detector_intersection_x], …..])
- Return type:
np.array (num_angles * 2)
- property ray_dir
The ray direction of the geometry.
This property is not supported on cone geometries.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the ray direction vectors.
- Return type:
- rescale_det(scale)[source]
Rescale detector pixels
Rescales detector pixels without changing the size of the detector.
- Parameters:
scale – int or (int, int) Indicates how many times to enlarge a detector pixel. Per convention, the first coordinate scales the pixels in the v coordinate, and the second coordinate scales the pixels in the u coordinate.
- Returns:
a rescaled cone vector geometry
- Return type:
ConeVectorGeometry
- reshape(new_shape)[source]
Reshape detector pixels without changing detector size
- Parameters:
new_shape – int or (int, int) The new shape of the detector in pixels in v (height) and u (width) direction.
- Returns:
self
- Return type:
- property src_pos
The source positions of the geometry.
Not supported on parallel geometries.
- Returns:
np.array A (num_angles, 3)-shaped numpy array containing the (Z,Y,X)-coordinates of the source positions.
- Return type:
- to_astra()[source]
Convert geometry to astra geometry
- Returns:
An astra representation of the current geometry.
- Return type:
dict
- to_vec()[source]
Return a vector geometry of the current geometry
- Returns:
- Return type:
- to_vol()[source]
Returns a volume vector geometry representing the detector
- Returns:
a volume vector geometry representing the detector
- Return type:
VolumeVectorGeometry
- tomosipo.geometry.det_vec.det_vec(shape, det_pos, det_v, det_u)[source]
Create a detector vector geometry
- Parameters:
shape – (int, int) or int The detector shape in pixels. If tuple, the order is (height, width). Otherwise, the pixel has the same number of pixels in the U and V direction.
det_pos – A numpy array of dimension (num_positions, 3) with the detector center positions in (Z, Y, X) order.
det_v – A numpy array of dimension (num_positions, 3) with the vector pointing from the detector (0, 0) to (1, 0) pixel (up).
det_u – A numpy array of dimension (num_positions, 3) with the vector pointing from the detector (0, 0) to (0, 1) pixel (sideways).
- Returns:
- Return type:
- tomosipo.geometry.det_vec.random_det_vec()[source]
Generates a random cone vector geometry
- Returns:
a random cone vector geometry
- Return type:
ConeVectorGeometry