recovar.utils¶
General-purpose utilities for I/O, array manipulation, and timing.
helpers¶
recovar.utils.helpers
¶
General-purpose utilities: I/O, array manipulation, timing.
AlgorithmOptions(volume_mask_option, zs_dim_to_test, contrast, ignore_zero_frequency, keep_intermediate)
dataclass
¶
Typed container for pipeline algorithm options.
RobustStreamHandler
¶
Bases: StreamHandler
StreamHandler that silently handles stale NFS/GPFS file handles.
RobustFileHandler
¶
Bases: FileHandler
FileHandler that reopens the file on stale NFS/GPFS handles.
make_radial_image_half(average_image_PS, image_shape, extend_last_frequency=True)
¶
Like :func:make_radial_image but outputs rfft-packed half-spectrum.
Uses get_grid_of_radial_distances_real so the output has shape
(H * (W//2+1),) instead of (H * W,).
set_gpu_memory_limit(gb)
¶
Set the GPU memory limit (in GB) used for batch-size calculations.
safe_batch_size(raw_size)
¶
Clamp a raw batch size to at least 1 and convert to int.
get_image_batch_size(grid_size, gpu_memory)
¶
Calculate batch size for image processing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
Size of the grid |
required | |
gpu_memory
|
Available GPU memory in GB |
required |
Returns:
| Type | Description |
|---|---|
|
Integer batch size with reasonable bounds |
get_vol_batch_size(grid_size, gpu_memory)
¶
Calculate batch size for volume processing.
get_column_batch_size(grid_size, gpu_memory)
¶
Calculate batch size for column processing.
compute_batch_sizes(grid_size, gpu_memory)
¶
Compute all batch sizes at once.
Returns a BatchSizes(image, volume, column) namedtuple.
R_to_relion(rot, degrees=True)
¶
Convert rotation matrices to RELION Euler angles.
Converts rotation matrices to RELION's ZXZ Euler angle convention with appropriate coordinate frame transformations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rot
|
ndarray
|
Rotation matrix or matrices of shape (3,3) or (N,3,3) |
required |
degrees
|
bool
|
If True, return angles in degrees; otherwise radians |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Euler angles in RELION convention, shape (N,3) |
R_from_relion(euler_, degrees=True)
¶
Convert RELION Euler angles to rotation matrices.
Converts RELION's ZXZ Euler angle convention to rotation matrices with appropriate coordinate frame transformations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
euler_
|
ndarray
|
Euler angles of shape (3,) or (N,3) in RELION convention |
required |
degrees
|
bool
|
If True, input angles are in degrees; otherwise radians |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Rotation matrices of shape (N,3,3) |