Backend
leopard_em.backend
Submodule for computationally intensive backend functions.
cross_correlate_particle_stack
cross_correlate_particle_stack(particle_stack_dft: Tensor, template_dft: Tensor, rotation_matrices: Tensor, projective_filters: Tensor, mode: Literal['valid', 'same'] = 'valid', batch_size: int = 1024, mag_matrix: Tensor | None = None) -> torch.Tensor
Cross-correlate a stack of particle images against a template.
Here, the argument 'particle_stack_dft' is a set of RFFT-ed particle images with necessary filtering already applied. The zeroth dimension corresponds to unique particles.
Parameters:
-
particle_stack_dft(Tensor) –The stack of particle real-Fourier transformed and un-fftshifted images. Shape of (N, H, W).
-
template_dft(Tensor) –The template volume to extract central slices from. Real-Fourier transformed and fftshifted.
-
rotation_matrices(Tensor) –The orientations of the particles to take the Fourier slices of, as a long list of rotation matrices. Shape of (N, 3, 3).
-
projective_filters(Tensor) –Projective filters to apply to each Fourier slice particle. Shape of (N, h, w).
-
mode(Literal['valid', 'same'], default:'valid') –Correlation mode to use, by default "valid". If "valid", the output will be the valid cross-correlation of the inputs. If "same", the output will be the same shape as the input particle stack.
-
batch_size(int, default:1024) –The number of particle images to cross-correlate at once. Default is 1024. Larger sizes will consume more memory. If -1, then the entire stack will be cross-correlated at once.
-
mag_matrix(Tensor | None, default:None) –Anisotropic magnification matrix of shape (2, 2). If None, no magnification transform is applied. Default is None.
Returns:
-
Tensor–The cross-correlation of the particle stack with the template. Shape will depend on the mode used. If "valid", the output will be (N, H-h+1, W-w+1). If "same", the output will be (N, H, W).
Raises:
-
ValueError–If the mode is not "valid" or "same".