aspire.reconstruction package

Submodules

aspire.reconstruction.estimator module

class aspire.reconstruction.estimator.Estimator(src, basis=None, batch_size=512, preconditioner='circulant', checkpoint_iterations=10, checkpoint_prefix='volume_checkpoint', maxiter=100, boost=True)

Bases: object

An object representing a 2*L-by-2*L-by-2*L array containing the non-centered Fourier transform of the mean least-squares estimator kernel. Convolving a volume with this kernel is equal to projecting and backproject-ing that volume in each of the projection directions (with the appropriate amplitude multipliers and CTFs) and averaging over the whole dataset. Note that this is a non-centered Fourier transform, so the zero frequency is found at index 1.

Parameters:
  • srcImageSource to be used for estimation.

  • basis – 3D Basis to be used during estimation.

  • batch_size – Optional batch size of images drawn from src during back projection and kernel estimation steps.

  • preconditioner – Optional kernel preconditioner (string). Currently supported options are “circulant” or None.

  • checkpoint_iterations – Optionally save cg estimated Volume instance periodically each checkpoint_iterations. Setting to None disables, otherwise checks for positive integer.

  • checkpoint_prefix – Optional path prefix for cg checkpoint files. If the parent directory does not exist, creation is attempted. _iter{N} will be appended to the prefix.

  • maxiter – Optional max number of cg iterations before returning. This should be used in conjunction with checkpoint_iterations to prevent excessive disk usage. None disables.

  • boost – Option to use src symmetry to boost number of images used for mean estimation (Boolean). Default of True employs symmetry boosting.

apply_kernel(vol_coef, kernel=None)

Applies the kernel represented by convolution

Parameters:
  • vol_coef – The volume to be convolved, stored in the basis coefficients.

  • kernel – a Kernel object. If None, the kernel for this Estimator is used.

Returns:

The result of evaluating vol_coef in the given basis, convolving with the kernel given by kernel, and backprojecting into the basis.

compute_kernel()
estimate(b_coef=None, tol=1e-05, regularizer=0)

Return an estimate as a Volume instance.

aspire.reconstruction.kernel module

class aspire.reconstruction.kernel.FourierKernel(kernel)

Bases: Kernel

circularize()
circularize_1d(kernel, dim)
convolve_volume(x, in_place=False)

Convolve volume with kernel

Parameters:
  • x – A Volume instance

  • in_plane – Operate on Volume x in place. Optional bool, defaults False. This saves memory in exchange for mutating the input data.

Returns:

Volume instance convolved by the kernel with the same dimensions as before.

convolve_volume_matrix(x)

Convolve volume matrix with kernel

Parameters:

x – An N-by-…-by-N (6 dimensions) volume matrix to be convolved.

Returns:

The original volume matrix convolved by the kernel with the same dimensions as before.

toeplitz(L=None)

Compute the 3D Toeplitz matrix corresponding to this Fourier Kernel

Parameters:

L – The size of the volumes to be convolved (default M/2, where the dimensions of this Fourier Kernel are MxMxM

Returns:

An six-dimensional Toeplitz matrix of size L describing the convolution of a volume with this kernel

class aspire.reconstruction.kernel.FourierKernelMatrix(kermat)

Bases: FourierKernel

circularize()
convolve_volume(x, k, j, in_place=False)

Convolve volume with kernel

Parameters:
  • x – A Volume instance

  • k – Kernel matrix index

  • j – Kernel matrix index

  • in_plane – Operate on Volume x in place. Optional bool, defaults False. This saves memory in exchange for mutating the input data.

Returns:

Volume instance convolved by the kernel with the same dimensions as before.

convolve_volume_matrix(x)

Convolve volume matrix with kernel

Parameters:

x – An N-by-…-by-N (6 dimensions) volume matrix to be convolved.

Returns:

The original volume matrix convolved by the kernel with the same dimensions as before.

toeplitz(L=None)

Compute the 3D Toeplitz matrix corresponding to this Fourier Kernel

Parameters:

L – The size of the volumes to be convolved (default M/2, where the dimensions of this Fourier Kernel are MxMxM

Returns:

An six-dimensional Toeplitz matrix of size L describing the convolution of a volume with this kernel

class aspire.reconstruction.kernel.Kernel

Bases: object

aspire.reconstruction.mean module

class aspire.reconstruction.mean.MeanEstimator(src, **kwargs)

Bases: WeightedVolumesEstimator

Special case of weighted mean volume estimate, for a single volume.

Weighted mean volume estimation.

This class holds the FourierKernelMatrix, stored as a r x r matrix of volumes. The problem being solved here is the minimization given by eq. (14) in the paper, rewritten as the normal equations in eq. (20) and more compactly in eq. (23).

Convolution with each of these kernels is equivalent to performing a projection/backprojection on a volume, with the appropriate amplitude modifiers and CTF, and also a weighting term; the r^2 volumes are each of pairwise products between the weighting vectors given by the columns of wts.

Note that this is a non-centered Fourier transform, so the zero frequency is found at index 0.

Formulas and conventions used for Volume estimation are described in:

“Structural Variability from Noisy Tomographic Projections.” Andén, Joakim, and Amit Singer. SIAM journal on imaging sciences vol. 11,2 (2018): 1441-1492. doi:10.1137/17M1153509

“Cryo-EM reconstruction of continuous heterogeneity by Laplacian spectral volumes” Amit Moscovich, Amit Halevi, Joakim Andén and Amit Singer Inverse Problems, Volume 36, Number 2, 2020 IOP Publishing Ltd Special Issue on Cryo-Electron Microscopy and Inverse Problems https://doi.org/10.1088/1361-6420/ab4f55

Parameters:

weights – Matrix of weights, n x r.

apply_kernel(*args, **kwargs)

See Estimator.apply_kernel.

compute_kernel()

Compute and return FourierKernel instance.

class aspire.reconstruction.mean.WeightedVolumesEstimator(weights, *args, **kwargs)

Bases: Estimator

Weighted mean volume estimation.

This class holds the FourierKernelMatrix, stored as a r x r matrix of volumes. The problem being solved here is the minimization given by eq. (14) in the paper, rewritten as the normal equations in eq. (20) and more compactly in eq. (23).

Convolution with each of these kernels is equivalent to performing a projection/backprojection on a volume, with the appropriate amplitude modifiers and CTF, and also a weighting term; the r^2 volumes are each of pairwise products between the weighting vectors given by the columns of wts.

Note that this is a non-centered Fourier transform, so the zero frequency is found at index 0.

Formulas and conventions used for Volume estimation are described in:

“Structural Variability from Noisy Tomographic Projections.” Andén, Joakim, and Amit Singer. SIAM journal on imaging sciences vol. 11,2 (2018): 1441-1492. doi:10.1137/17M1153509

“Cryo-EM reconstruction of continuous heterogeneity by Laplacian spectral volumes” Amit Moscovich, Amit Halevi, Joakim Andén and Amit Singer Inverse Problems, Volume 36, Number 2, 2020 IOP Publishing Ltd Special Issue on Cryo-Electron Microscopy and Inverse Problems https://doi.org/10.1088/1361-6420/ab4f55

Parameters:

weights – Matrix of weights, n x r.

apply_kernel(vol_coef, kernel=None)

Applies the kernel represented by convolution

Parameters:
  • vol_coef – The volume to be convolved, stored in the basis coefficients.

  • kernel – a Kernel object. If None, the kernel for this Estimator is used.

Returns:

The result of evaluating vol_coef in the given basis, convolving with the kernel given by kernel, and backprojecting into the basis.

compute_kernel()

Compute and return FourierKernelMatrix instance.

conj_grad(b_coef, tol=1e-05, regularizer=0)
src_backward()

Apply adjoint mapping to source

Returns:

The adjoint mapping applied to the images, averaged over the whole dataset and expressed as coefficients of basis.

Module contents