Utilities API
Checkpoint Management
CheckpointReader
Helper class to read from either a directory or a ZIP archive checkpoint. Provides unified interface for file access.
- class cryoPARES.utils.checkpointReader.CheckpointReader(checkpoint_path)[source]
Bases:
object
Helper class to read from either a directory or a ZIP archive checkpoint. Provides unified interface for file access.
- Parameters:
checkpoint_path (str)
- __init__(checkpoint_path)[source]
Initialize checkpoint reader.
- Parameters:
checkpoint_path (
str
) – Path to checkpoint directory or ZIP file
- load_torch(relative_path, **kwargs)[source]
Load PyTorch model/tensor from checkpoint.
- Parameters:
relative_path (str)
- load_jit(relative_path)[source]
Load TorchScript model from checkpoint.
- Parameters:
relative_path (str)
Checkpoint Utils
- cryoPARES.utils.checkpointUtils.get_best_checkpoint(checkpoint_dir, best_is_less=True)[source]
Get the best checkpoint from a directory.
Parameters: checkpoint_dir (str): Path to the directory containing the checkp Returns: str: The path to the best checkpoint.
- cryoPARES.utils.checkpointUtils.increment_generic(generic_string, pattern, count_group_idx)[source]
- cryoPARES.utils.checkpointUtils.increment_version(fname_string, path_basename='(.*version_)(\\d+)$', extension=None)[source]
- cryoPARES.utils.checkpointUtils.find_last_version(rootdir, count_group_idx=1, path_pattern='(.*version_)(\\d+)$', dir_only=False)[source]
Path Utilities
- cryoPARES.utils.paths.find_configs_root()[source]
Find the project configs root by looking for constants.py
- Return type:
- cryoPARES.utils.paths.find_project_root()[source]
Find the project root by looking for pyproject.toml
- Return type:
PyTorch Utilities
Reconstruction Utilities
Geometry Utilities
Angle Conversions
- cryoPARES.geometry.convert_angles.euler_angles_to_matrix(euler_angles, convention)[source]
Convert rotations given as Euler angles in radians to rotation matrices.
Angle Metrics
- cryoPARES.geometry.metrics_angles.rotation_magnitude(rot)[source]
Compute rotation magnitude in radians.
- Parameters:
rot – tensor of shape (…,3,3)
- Returns:
The rotation magnitude in radians
- cryoPARES.geometry.metrics_angles.nearest_rotmat_idx(src, targets)[source]
Return index of target that is nearest to each element in src.
Uses negative trace of the dot product to avoid arccos operation.
- Parameters:
src – tensor of shape (B, 3, 3)
targets – tensor of shape (…, 3, 3)
- Returns:
dot_trace: The value of the trace of the selected nearest rotmat idxs
idxs: The idxs of the nearest rotation matrices
- cryoPARES.geometry.metrics_angles.rotation_error_rads(rotA, rotB)[source]
Compute rotation error in radians between two rotation matrices.
- Parameters:
rotA – tensor of shape (…,3,3). Rotation matrix
rotB – tensor of shape (…,3,3). Rotation matrix
- Returns:
rotation error in radians, tensor of shape (…)
- cryoPARES.geometry.metrics_angles.rotation_error_with_sym(rotA, rotB, symmetry=None)[source]
Compute rotation error in radians between two rotation matrices with symmetry.
- Parameters:
rotA – tensor of shape (…,3,3). Rotation matrix
rotB – tensor of shape (…,3,3). Rotation matrix
symmetry – string or None. Symmetry group (e.g., ‘I’, ‘O’, ‘T’, ‘D7’, etc.) If None, computes standard rotation error without symmetry
- Returns:
rotation error in radians, tensor of shape (…)