API reference#
- pymatcal.append_subdivs(geoms: ndarray, focs: ndarray, subdiv_geoms: ndarray)#
Append subdivisions to the existing array of geometries.
- Parameters:
geoms (ndarray) – The existing subdivisions.
focs (ndarray) – The detector units geometries in focus.
subdiv_geoms (ndarray) – The subdivisions geometries to be appended.
- Returns:
The updated array of geometries.
- Return type:
ndarray
- pymatcal.coord_transform(m: tuple[ndarray], input: ndarray)#
Apply coordinate transformation to the input array.
- Parameters:
m (tuple[numpy.ndarray,numpy.ndarray]) – A tuple containing two numpy arrays representing the transformation matrix.
input (numpy.ndarray) – The input array to be transformed.
- Returns:
The transformed array.
- Return type:
- pymatcal.get_AB_pairs(pAs, pBs)#
Generate pairs of points from two arrays of points.
- Parameters:
pAs (numpy.ndarray) – Array of points A.
pBs (numpy.ndarray) – Array of points B.
- Returns:
Array of pairs of points, where each row contains the coordinates of a pair (Ax, Ay, Az, Bx, By, Bz).
- Return type:
- pymatcal.get_centroids(geoms: ndarray) ndarray #
Get the centroids of the subdivisions.
- Parameters:
geoms (ndarray) – The subdivisions of the detector.
- Returns:
The centroids of the subdivisions.
- Return type:
ndarray
- pymatcal.get_det_subdivs(focs: ndarray, nsubs: ndarray)#
Get the subdivisions of a detector.
- Parameters:
focs (ndarray) – The focal points of the detector.
nsubs (ndarray) – The number of subdivisions in the x, y, and z directions.
- Returns:
A dictionary containing the subdivisions and increments.
- Return type:
dict - geoms (ndarray): The subdivisions of the detector. - incs (ndarray): The increments of the subdivisions.
- pymatcal.get_fov_voxel_center(id: uint64, nvx: ndarray, mmpvx: ndarray) ndarray #
Calculate the center coordinates of a voxel given its index.
- Parameters:
id (np.uint64) – The index of the voxel.
nvx (np.ndarray) – The number of voxels in each dimension.
mmpvx (np.ndarray) – The size of each voxel in millimeters.
- Returns:
The center coordinates of the voxel.
- Return type:
np.ndarray
- Raises:
AssertionError – If the given voxel index is invalid.
- pymatcal.get_intersections_2d(geoms: ndarray, abpairs: ndarray)#
Calculate the intersection length between a set of geometries and given set of rays in 2D.
- Parameters:
geoms (numpy.ndarray) – Array of geometries, where each geometry is represented as [x0, x1, y0, y1,z0, z1, sequence, mu].
abpairs (numpy.ndarray) – Array of rays, where each ray is represented as [Ax, Ay, Az, Bx, By, Bz].
- Returns:
Dictionary containing the intersection lengths and t values. - ‘intersections’: Array of intersection points, where elements are intersection lengths. - ‘ts’: Array of t values, where each t value represents the parameterization of the intersection point along the rays.
- Return type:
- pymatcal.get_mtransform(angle_deg: float, tx, ty) tuple[ndarray, ndarray] #
Get the transformation matrix for a given angle in degrees and translation values.
- Parameters:
angle_deg – The angle in degrees.
tx – The translation value along the x-axis.
ty – The translation value along the y-axis.
- Returns:
The transformation matrix as a tuple of two numpy arrays.
- pymatcal.get_pair_ppdf(ida: uint64, idb: uint64, idrot: int, idr: int, idt: int, fov_subdivs: dict, config: dict) float64 #
Calculate the pair projection probability density function (PPDF) for a pair of FOV voxel and detector unit.
- Parameters:
ida (numpy.uint64) – The ID of the FOV voxel.
idb (numpy.uint64) – The ID of the second detector.
idrot (int) – The ID of the rotation.
idr (int) – The ID of the r-shift.
idt (int) – The ID of the t-shift.
fov_subdivs (dict) – A dictionary containing the subdivisions of the image.
config (dict) – A dictionary containing the configuration parameters.
- Returns:
The PPDF value of the pair.
- Return type:
numpy.float64
- Raises:
None
- pymatcal.get_pair_ppdf_area(ida: uint64, idb: uint64, idrot: int, idr: int, idt: int, fov_subdivs: dict, config: dict) float64 #
Calculate the pair projection probability density function (PPDF) for a pair of FOV voxel and detector unit. This function uses the projection area as the solid angle. The solid angle will not decrease as the distance between the FOV voxel and the detector unit increases.
- Parameters:
ida (numpy.uint64) – The ID of the FOV voxel.
idb (numpy.uint64) – The ID of the second detector.
idrot (int) – The ID of the rotation.
idr (int) – The ID of the r-shift.
idt (int) – The ID of the t-shift.
fov_subdivs (dict) – A dictionary containing the subdivisions of the image.
config (dict) – A dictionary containing the configuration parameters.
- Returns:
The PPDF value of the pair.
- Return type:
numpy.float64
- Raises:
None
- pymatcal.get_pair_ppdf_binary(ida: uint64, idb: uint64, idrot: int, idr: int, idt: int, fov_subdivs: dict, config: dict) float64 #
Calculate the pair projection probability density function (PPDF) for a pair of FOV voxel and detector unit. The PPDF value is binary, where 1 indicates that the ray is NOT blocked and 0 indicates that the pair is blocked.
- Parameters:
ida (numpy.uint64) – The ID of the FOV voxel.
idb (numpy.uint64) – The ID of the second detector.
idrot (int) – The ID of the rotation.
idr (int) – The ID of the r-shift.
idt (int) – The ID of the t-shift.
fov_subdivs (dict) – A dictionary containing the subdivisions of the image.
config (dict) – A dictionary containing the configuration parameters.
- Returns:
The PPDF value of the pair.
- Return type:
numpy.float64
- Raises:
None
- pymatcal.get_solid_angles(abpairs: ndarray, incs: ndarray) ndarray #
Calculate the solid angles of the detector units subdivisions, B, to the given set of FOV voxel subdivision centroids, A.
- Parameters:
abpairs (numpy.ndarray) – An array of shape (M x N, 6) containing the coordinates of FOV voxel subdivision centroids and detector unit subdivison centroids.
incs (numpy.ndarray) – An array of shape (3,) containing the x,y,z sizes of the detector unit subdivisions in millimeter .
- Returns:
An array of shape (M x N,) containing the solid angles of the AB pairs.
- Return type:
np.ndarray