13. Practical: Single-Particle Analysis#
13.1. The reconstruction problem#
In electron microscopy we want to deduce the 3D structure of a structurally homogeneous ‘particle’ — for example a protein — from cryo-EM images. Each image shows the particle in a different, unknown orientation. To make the problem tractable we work in 2D: we treat the unknown structure as a 2D image \(A\) and each observation as a rotated, noisy version:
where \(R^{\theta_i}\) is rotation by the unknown angle \(\theta_i\) and \(G_i\) is i.i.d. Gaussian noise. If we can estimate \(\theta_i\) for each image, we can recover \(A\) by rotating each image back and averaging.
We use the letter Q as our 2D ‘particle’ because it is immediately recognisable and its asymmetry makes orientation unambiguous. In real SPA the structure is of course unknown.
Interactive elements
Click Live Code in the top toolbar to activate the kernel, then expand each Show code toggle and click ▶ to run the cell.
13.1.1. Helper functions#
The cell below defines all functions used throughout this chapter. Run it first.
13.2. Part 0 – The test image#
13.3. Simulating cryo-EM images#
The interactive below shows a single simulated particle image. The image formation model is:
Drag the angle slider to rotate the particle and the σ slider to add noise.
13.4. Part 1 – Choosing an initial reference#
The alignment algorithm needs a starting reference to compare images against. Three strategies are common:
Reference |
Advantage |
Risk |
|---|---|---|
Low-pass filtered true structure |
Fast convergence |
Only works if structure is already known (circular reasoning) |
Featureless circle |
No reference bias |
Slow convergence; poor angular discrimination |
Random noise / another structure |
Quick to obtain |
Risk of converging to wrong answer (model bias) |
In practice, a featureless circle or a low-pass-filtered version of a prior reconstruction is used. The interactive below lets you choose the starting reference and see how much angular discrimination it provides for a single noisy image.
13.5. Part 2 – Alignment algorithm#
For a set of \(N\) images \(\{X_i\}\), we align each to the reference by searching over discrete candidate angles \(\Delta\theta\) apart. For each image we rotate the reference to all candidate angles and pick the best-matching one:
After estimating all angles, the scatter plot of true vs estimated angles reveals how well alignment worked. A tight diagonal indicates good alignment; spread indicates confusion.
Task
Part 2, step 1: Implement the alignment loop in the code cell below. For each image, compute the correlation against every rotated reference and record the best angle. Run the cell to see the scatter plot of true vs estimated angles.
13.6. Part 3 – Reconstruction#
Given estimated angles, rotating each image back and averaging gives the reconstruction:
Task
Part 3: Complete the reconstruction: for each image, rotate it back by \(-\hat\theta_i\) and sum all rotated images. Divide by \(N\) to get the average.
13.7. Interactive reconstruction#
The widget below runs the complete pipeline — from noisy images to reconstruction — with adjustable parameters. It also shows the scatter of estimated vs true angles and the correlation between reconstruction and true image as a quality metric.
13.8. Bonus 1 – Adding translation#
So far we assumed particles are perfectly centred. In reality, particle positions within the extracted box vary. The model extends to:
where \(T^{t_i}\) is a translation by vector \(\mathbf{t}_i = (dx_i, dy_i)\). We can handle integer-pixel translations by rolling the image array. The search grid is now \(N_\theta \times N_{dx} \times N_{dy}\), so runtime increases by a factor of \((2 t_\text{max}+1)^2\).
13.9. Bonus 2 – Bayesian maximum-likelihood alignment#
Hard assignment to the single best-fitting angle ignores alignment uncertainty. The maximum-likelihood approach instead computes a probability for each angle:
The soft reconstruction then uses all angles weighted by their posterior:
At high SNR the weights collapse onto the single best angle (recovering hard assignment); at low SNR they spread across many angles, effectively averaging out alignment noise.
13.10. Bonus 3 – Iterative refinement#
The previous examples used the initial reference for all alignment. A better strategy is to use the reconstruction from one round as the reference for the next:
Start from initial reference \(A^{(0)}\) (e.g. blurred Q or a circle)
Align images to \(A^{(k)}\) → estimate \(\hat\theta_i^{(k)}\)
Reconstruct \(A^{(k+1)}\) from aligned images
Repeat from step 2
The quality of the reconstruction typically improves each iteration. The widget below lets you choose the starting reference and the number of iterations.
13.11. Bonus 4 – 2D Classification#
Real datasets contain multiple particle types (different proteins, conformations, or viewing directions). 2D classification assigns each image to one of \(K\) classes simultaneously with the alignment:
Maintain \(K\) references \(\{A_1, \ldots, A_K\}\)
For each image, find the best (class, angle) pair by correlation
Reconstruct each class from the images assigned to it
Update references and iterate
The interactive below mixes \(K\) letters (Q, P, R) and attempts to recover them. The classification accuracy depends on the noise level and the number of images per class.
13.12. Summary#
Topic |
Key concept |
|---|---|
Observation model |
\(X_i = R^{\theta_i}A + \sigma G_i\) |
Reference selection |
Circular, blurred prior, or oracle; avoid reference bias |
Alignment |
Maximise correlation \(\langle X_i, R^{\theta_j}A\rangle\) over discrete candidates |
Reconstruction |
Average back-rotated images |
Model bias |
Wrong reference → biased reconstruction; correct with iterative refinement |
ML alignment |
Soft weights via \(\exp(-|X_i - R^\theta A|^2/2\sigma^2)\); better at low SNR |
Iterative refinement |
Use reconstruction as new reference; converges toward true structure |
Classification |
\(K\)-class joint alignment+assignment; separates heterogeneous datasets |