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], inputs: ndarray)#

Batch version of coordinate transformation

pymatcal.get_AB_pairs(pAs: ndarray, pBs: ndarray)#

Batch version of get_AB_pairs

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_config(confName: str)#

Load and validate a configuration file in YAML format.

Parameters:

confName (str) – The name of the configuration file.

Returns:

A dictionary containing the parsed configuration values.

Return type:

dict

Raises:

Exception if the configuration file fails validation or parsing.

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(ids: ndarray, nvx: ndarray, mmpvx: ndarray) ndarray#

Vectorized version to calculate multiple voxel centers simultaneously

pymatcal.get_intersections_2d(geoms: ndarray, abpairs: ndarray)#

Batch version of intersection calculation

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#

Batch version of solid angle calculation