tomodrgn.utils#

Common utility functions pertaining to both data processing and script execution

Functions

calc_cc

Helper function to calculate the zero-mean correlation coefficient as defined in eq 2 in https://journals.iucr.org/d/issues/2018/09/00/kw5139/index.html vol1 and vol2 should be maps of the same box size, shape (boxsize, boxsize, boxsize)

calc_fsc

Calculate the FSC between two volumes with optional masking.

calc_lowpass_filter_mask

Calculate a binary mask to later be multiplied into a fourier space volume to lowpass filter said volume.

calc_real_space_mask

Generate a real space mask generated from up to two volumes

check_git_revision_hash

Get the git revision hash of a git repository.

check_memory_usage

Get the current memory usage of the specified device_type.

first_n_factors

Decorator.

flog

Write a string to outfile with a standardized datetime format.

get_default_device

Determine whether a CUDA-capable GPU is availble or not for torch operations.

get_latest_epoch

Detect the latest completed epoch of model training.

load_pkl

Convenience function to read a binary pickle file.

log

Write a string to STDOUT with a standardized datetime format.

lowpass_filter

Lowpass-filters a volume in reciprocal space.

prefix_paths

Test which of various modifications to the image .mrcs files correctly locates the files on disk.

print_progress_bar

Display an ASCII progress bar in STDOUT.

rot_3d_from_eman

Convert Euler angles from EMAN to a 3-D rotation matrix.

rot_3d_from_relion

Convert Euler angles from RELION to a 3-D rotation matrix.

rot_3d_from_relion_scipy

Convert a Nx3 array of RELION euler angles to rotation matrices using Scipy Rotations class.

rot_3d_to_relion_scipy

Convert an array of Nx3x3 rotation matrices to RELION euler angles using Scipy Rotations class.

save_pkl

Convenience function to write data to a binary pickle file.

vlog

Write a string to STDOUT with a standardized datetime format only if _verbose is True.

xrot

Return rotation matrix associated with rotation over the x-axis.

yrot

Return rotation matrix associated with rotation over the y-axis

zero_sphere

Set volume values outside of a sphere inscribed within a cube to zero.

Classes

Memoized

Decorator.