9. Essentials of Fourier Analysis#

Signals, and therefore also images in electron microscopy, are often most conveniently described and processed in terms of their spatial frequencies. This section summarises the concepts and results of Fourier analysis that are used in the remainder of the book: the Fourier transform and its properties, sampling and resolution, the two-dimensional transform of images, convolution with a point spread function, and the projection theorem. The concepts are explored in exercises in the corresponding practical of the CryoEM doeboek (see the end of this chapter). They are applied in the following chapter to the formation of contrast in the TEM (Section 10). The chapter ends with the projection theorem (Section 9.5), which underlies the reconstruction of three-dimensional structures from projection images.

9.1. Waves, spectra and the Fourier transform#

A sinusoidal wave \(f(x) = A\cos(2\pi\nu x - \varphi)\) is described by three parameters: its amplitude \(A\), its spatial frequency \(\nu\) (the number of periods per unit length, so that the period is \(d = 1/\nu\)), and its phase \(\varphi\), which shifts the wave along the axis. A central result of Fourier analysis is that a periodic signal can be written as a sum of such waves with suitably chosen amplitudes, frequencies and phases (a Fourier series). A signal that is not periodic can be regarded as the limit of a periodic signal with an infinite period; the frequencies of the waves then form a continuum and the sum becomes an integral. The amplitudes and phases of the waves are given by the Fourier transform \(\hat{f}(\nu)\), and the signal is reconstructed by the inverse transform:

(9.1)#\[ \hat{f}(\nu) = \int_{-\infty}^{\infty} f(x)\, e^{-2\pi i \nu x}\, \mathrm{d}x, \qquad f(x) = \int_{-\infty}^{\infty} \hat{f}(\nu)\, e^{2\pi i \nu x}\, \mathrm{d}\nu, \]

where the integral on the left is the Fourier transform and the integral on the right is the inverse transform, which reconstructs the signal from its spectrum. Throughout this book, a hat denotes the Fourier transform of a function, so that \(\hat{f}\) is the transform of \(f\). The transform \(\hat{f}(\nu)\) is complex-valued. Its magnitude \(|\hat{f}(\nu)|\) is the amplitude spectrum, its argument is the phase spectrum, and \(|\hat{f}(\nu)|^2\) is the power spectrum. The value at \(\nu = 0\) is the mean value of the signal (also called the DC component).

The spectrum reveals how a signal is built. Smooth, slowly varying signals consist of low spatial frequencies, whereas sharp edges and fine details require high spatial frequencies. A box function, for example, has a spectrum that extends to high frequencies because of its sharp edges, and truncating its spectrum at a finite frequency produces oscillations near the edges (ringing, or the Gibbs phenomenon). The most important properties of the transform are summarised in the expandable box below.

The demonstration below builds a signal from its lowest harmonics, which are sinusoids with integer multiples of the fundamental frequency. With few harmonics, only the coarse shape of the signal is reproduced. Adding higher harmonics sharpens the edges, and the oscillations at the edges of the box and the sawtooth (ringing) do not disappear. The amplitude spectrum shows which frequencies carry the signal. Select the different signals to compare how many harmonics each of them needs.

Interactive element

Click the rocket symbol at the top of the page and select Live Code, or expand the Show code toggle and click ▶ to run the cell. The dropdown selects the signal and the slider the number of harmonics (besides the DC component) that are included in the sum. The orange bars in the amplitude spectrum are the components that are included.

Hide code cell source

import io
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from ipywidgets import IntSlider, Dropdown, VBox, HBox, Image as ImageWidget
from IPython.display import display

_P = 512
_x = np.arange(_P) / _P
_signals = {
    'Box': (np.abs(_x - 0.5) < 0.2).astype(float),
    'Triangle': 1 - np.abs(2*(_x - 0.5)),
    'Sawtooth': _x,
    'Gaussian': np.exp(-((_x - 0.5)/0.08)**2),
}

def draw_synth(name, n_harm):
    f = _signals[name]
    c = np.fft.rfft(f) / _P                          # Fourier coefficients c_0 ... c_256
    kept = c.copy(); kept[n_harm+1:] = 0             # keep the DC component and the lowest n_harm harmonics
    approx = np.fft.irfft(kept*_P, n=_P)
    amp = np.where(np.arange(len(c)) == 0, np.abs(c), 2*np.abs(c))   # amplitude of every harmonic
    k = np.arange(len(c))
    fig, ax = plt.subplots(1, 2, figsize=(12, 3.6))
    ax[0].plot(_x, f, color='lightgray', lw=3, label='signal')
    ax[0].plot(_x, approx, color='#d95f02', lw=1.8, label=f'sum of {n_harm} harmonics')
    ax[0].set_xlabel('Position x (periods)'); ax[0].legend(fontsize=8, loc='upper right'); ax[0].set_ylim(-0.3, 1.4)
    ax[0].set_title("Signal and its Fourier synthesis", fontsize=9)
    nshow = 40
    colors = ['#d95f02' if i <= n_harm else 'lightgray' for i in k[:nshow]]
    ax[1].bar(k[:nshow], amp[:nshow], color=colors)
    ax[1].set_xlabel('Frequency (harmonic number)'); ax[1].set_ylabel('Amplitude')
    ax[1].set_title("Amplitude spectrum (orange: included in the sum)", fontsize=9)
    fig.tight_layout()
    buf = io.BytesIO(); fig.savefig(buf, format='png', dpi=96); buf.seek(0)
    plt.close(fig); return buf.getvalue()

style = {'description_width': '130px'}
sig_dd = Dropdown(options=list(_signals), value='Box', description='Signal', style=style, layout={'width': '240px'})
n_sl = IntSlider(value=3, min=0, max=40, step=1, description='Number of harmonics', style=style, layout={'width': '420px'})

out_syn = ImageWidget(format='png', layout={'max_width': '100%'})
def update_syn(_=None):
    out_syn.value = draw_synth(sig_dd.value, n_sl.value)
for w in [sig_dd, n_sl]:
    w.observe(update_syn, names='value')
display(VBox([HBox([sig_dd, n_sl]), out_syn]))
update_syn()

9.2. Sampling and resolution#

Digital signals are sampled at discrete positions, which for images are the pixels with size \(\Delta x\). A sampled signal can only represent spatial frequencies up to the Nyquist frequency,

\[ \nu_\mathrm{N} = \frac{1}{2\Delta x}. \]

Features with a period shorter than \(2\Delta x\) cannot be represented, and components with higher frequencies are not lost but reappear at lower frequencies (aliasing). To record information down to a resolution \(d\), the pixel size must therefore be at most \(d/2\). For a resolution of 3 Å, for example, it must not exceed 1.5 Å. The resolution of an image or a map is the period \(d = 1/\nu\) of the highest spatial frequency at which signal can be measured reliably. In cryo-EM, it is assessed with the Fourier shell correlation (Section 11.7.1).

9.3. The Fourier transform in two and three dimensions#

For an image \(f(x,y)\), the Fourier transform is two-dimensional,

(9.2)#\[ \hat{f}(k_x, k_y) = \iint f(x,y)\, e^{-2\pi i (k_x x + k_y y)}\, \mathrm{d}x\, \mathrm{d}y, \]

with the spatial frequency vector \(\mathbf{k} = (k_x, k_y)\). Its magnitude \(|\mathbf{k}|\) is the inverse of the period, and its direction is perpendicular to the stripes of the corresponding two-dimensional wave. The properties of the one-dimensional transform carry over. A shift of the image changes only the phases, so that the amplitude and power spectra are unchanged, and a rotation of the image rotates its transform by the same angle. The definition extends to three dimensions, where a volume \(f(\mathbf{r})\), such as a density map of a macromolecule, has the transform \(\hat{f}(\mathbf{k}) = \iiint f(\mathbf{r})\, e^{-2\pi i\, \mathbf{k}\cdot\mathbf{r}}\, \mathrm{d}^3 r\) with \(\mathbf{k} = (k_x, k_y, k_z)\), and the properties above remain valid. The three-dimensional transform is the basis of the reconstruction from projections, because as we will see the transform of a projection image is a central section of the transform of the volume (Section 9.5).

In the usual display of the transform, with the zero frequency in the centre, the centre is the mean value of the image, low frequencies close to the centre describe coarse structure, and high frequencies far from the centre describe fine detail. Characteristic features of an image have recognisable signatures in its Fourier equivalent. For example, a line gives a line through the origin that is perpendicular to it, a ring gives a ring with the reciprocal radius, and a uniform disc gives a pattern of concentric rings. The following figure shows a few such examples. In cryo-EM, the power spectrum of a micrograph is the basis of the estimation of the CTF (Section 10.4).

../_images/c239d81e576ce7732674763a3c3c10af1c9dec4af86d9838771ab2f1c7c50dae.png

9.4. Convolution and the point spread function#

Convolution appears in this book in three places. The image recorded by a microscope is the convolution of the specimen with the point spread function of the instrument, and the Fourier transform of that function is the contrast transfer function (Section 10). Filtering operations, such as the removal of noise or the ramp filter in filtered backprojection, are convolutions as well. Finally, the cross-correlation that is used to align particle images (Section 11.2.2) is calculated with the same relation, as the product of the Fourier transform of one image with the complex conjugate of the transform of the other. The relation is therefore summarised here.

Every imaging system has a point spread function (PSF), which is the image of an ideal point source. The image \(g\) of an object \(f\) is the convolution of the object with the PSF \(h\),

\[ g(x) = (f * h)(x) = \int f(x')\, h(x - x')\, \mathrm{d}x', \]

in which every point of the object is replaced by a copy of the PSF, weighted by the value of the object at that point. The convolution theorem states that convolution in real space corresponds to multiplication in Fourier space,

(9.3)#\[ g = f * h \quad \Longleftrightarrow \quad \hat{g} = \hat{f} \cdot \hat{h}. \]

The Fourier transform \(\hat{h}\) of the PSF is the transfer function of the imaging system. It states how strongly each spatial frequency is transferred to the image. For an electron microscope in phase-contrast mode, it is the contrast transfer function (CTF), which is derived in the next chapter (Section 10).

The demonstration below convolves an image with several kernels. Each kernel is the point spread function of an operation: a Gaussian or box kernel blurs the image, and the Laplacian and Sobel kernels emphasise edges. The third panel shows the Fourier transform of the kernel, which is the transfer function of the operation. The result is calculated by multiplying the Fourier transform of the image with it, as the convolution theorem states. Blurring kernels transfer low spatial frequencies and suppress high ones, whereas the edge-detecting kernels do the opposite.

Interactive element

Click the rocket symbol at the top of the page and select Live Code, or expand the Show code toggle and click ▶ to run the cell. The dropdown selects the kernel, and the slider sets the width of the Gaussian and box kernels.

Hide code cell source

import io, zlib, base64
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from ipywidgets import FloatSlider, Dropdown, VBox, HBox, Image as ImageWidget
from IPython.display import display

# Test image: the rubber duck of the CryoEM doeboek practicals (128 x 128, 8 bit, compressed)
_DUCK_128 = 'eNrtWmtMm+cVrm8YsB2T2CEQLiYQCMVdIBDiBApJKCWKabNgN2lCEy6FGoxtHNsk2GAbAwZjG2yM77c0XZZsWVW1W6tNW7dqVSutWrtJW9utnaZ1WlW1TXrR1EvSpp32fp/v5jP+TEx++fmD+OPnfM8573nPOe+5554MMsgggwwyyCCDDBIDkwh3hxuLw+GRgMNhN9YGmBtPIOaQyGRKPMhkUg6RgN8wG4LcueQ8ekFxKWM1SosL6Hnk3KAN6ScPcBeW7mTW729uaWmNRUtL8/565s7SwoANaTUhQE6lQdwNTW1sbndPX19/LPr6erq57LamBsgGGjVgQto+PYdC215eU9/U1sk9MyiQKZRq9VQs1GqlQiYYPMPtbGuqrynfTqPkpEMEwI4nkqj5pdUNrUcBt1A2oZkzmJYtFstKNMD/yybDnGZCJgQ2HG1tqC7Np5KI+Du0ALBnQ59+34EObi9fCnOv2JwuDxJcTtsKbIOU38vtOHAfJEI2/g68gMHgski0kuqGg52neFLlLMzt9nh9fmT4vB43bMOsUso71XmwobqERsrCrVcC6OOphVWN7dxewQXNgtnqCHJfTISgDQ6reUFzQdDLbW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70tTO3kfDpX86CaqCiOjZPuWiPnj+E8/+K0+22gf6PXVdEIWA3YDkMeABU7sf5SkPM60vw/gPsrmD/SyViN2Y3DXQuFQeO8+TQ60f0uoLPC+BxWnRylP3/ukMgl16xjw3tSwSWRaJWglw2aAeCva+CnovfsO1ALD6Xxqhr7xapdGZoEhSE2+WwmnQqUXd7HQPd/OcOFrWoRczWrgHJ5Kwe7o8t8E6YfnZSMtDVyiyiZuOxG7ocCe0LVTa2c3r5UnmgP1arlXIpv5fT3lgZW+ltkAQE0pZiaE+OczrQH/f19ZzmQG1k8RYSAbvh26lQAU2mbd9Rs4cV6I9bWpoD7cyqQnOj9lOBBblUWqQ/Li0ugHYh8di7spsb2hMN98eBnVjc3WIPm4CL3Qm+5y7jbu9EZ5BBBhlkkEEGGWSQKv4PPkrrzg=='
_duck = np.frombuffer(zlib.decompress(base64.b64decode(_DUCK_128)),
                      dtype=np.uint8).reshape(128, 128).astype(float)[::-1, :] / 255
_N = 160
_img = np.zeros((_N, _N)); _o = (_N - 128)//2
_img[_o:_o+128, _o:_o+128] = _duck
_F = np.fft.fft2(_img)

def _kernel(name, width):
    r = np.arange(-8, 9)
    X, Y = np.meshgrid(r, r)
    if name == 'Gaussian blur':
        k = np.exp(-(X**2 + Y**2)/(2*width**2))
    elif name == 'Box blur':
        k = ((np.abs(X) <= width) & (np.abs(Y) <= width)).astype(float)
    else:
        k = np.zeros_like(X, dtype=float)
        c = 8
        if name == 'Laplacian':
            k[c-1:c+2, c-1:c+2] = [[0, 1, 0], [1, -4, 1], [0, 1, 0]]
        elif name == 'Sobel (x)':
            k[c-1:c+2, c-1:c+2] = [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]
        else:
            k[c-1:c+2, c-1:c+2] = [[1, 2, 1], [0, 0, 0], [-1, -2, -1]]
        return k
    return k / k.sum()

def draw_conv(name, width):
    k = _kernel(name, width)
    kpad = np.zeros((_N, _N)); kpad[:17, :17] = k
    kpad = np.roll(kpad, (-8, -8), axis=(0, 1))                  # kernel centred at the origin
    Hk = np.fft.fft2(kpad)
    result = np.real(np.fft.ifft2(_F * Hk))                      # convolution = multiplication in Fourier space
    fig, ax = plt.subplots(1, 4, figsize=(14, 3.7))
    ax[0].imshow(_img, cmap='gray'); ax[0].set_title("Image", fontsize=9)
    ax[1].imshow(k[3:14, 3:14], cmap='RdBu_r', vmin=-np.abs(k).max(), vmax=np.abs(k).max()); ax[1].set_title("Kernel (point spread function)", fontsize=9)
    ax[2].imshow(np.fft.fftshift(np.abs(Hk)), cmap='viridis'); ax[2].set_title("|FT of the kernel| (transfer function)", fontsize=9)
    lo, hi = np.percentile(result, [0.5, 99.5])
    ax[3].imshow(result, cmap='gray', vmin=lo, vmax=hi); ax[3].set_title("Convolved image", fontsize=9)
    for a in ax: a.axis('off')
    fig.tight_layout()
    buf = io.BytesIO(); fig.savefig(buf, format='png', dpi=96); buf.seek(0)
    plt.close(fig); return buf.getvalue()

style = {'description_width': '130px'}
ker_dd = Dropdown(options=['Gaussian blur', 'Box blur', 'Laplacian', 'Sobel (x)', 'Sobel (y)'], value='Gaussian blur',
                  description='Kernel', style=style, layout={'width': '260px'})
w_sl = FloatSlider(value=2.0, min=1.0, max=6.0, step=0.5, description='Width (px)', style=style, layout={'width': '340px'})

out_conv = ImageWidget(format='png', layout={'max_width': '100%'})
def update_conv(_=None):
    out_conv.value = draw_conv(ker_dd.value, w_sl.value)
for w in [ker_dd, w_sl]:
    w.observe(update_conv, names='value')
display(VBox([HBox([ker_dd, w_sl]), out_conv]))
update_conv()

Image processing uses the same relation in the opposite direction. A filter multiplies the Fourier transform of an image with a function \(H(\mathbf{k})\), and the result is transformed back. A low-pass filter (\(H = 1\) below a cutoff frequency and \(H = 0\) above it) blurs the image and suppresses high-frequency noise. A high-pass filter does the opposite: it removes slowly varying components and emphasises edges and fine detail, at the cost of amplifying noise. A sharp cutoff produces ringing in real space, so that the edges of a filter are normally smoothed. A radially increasing filter, \(H = |\mathbf{k}|\) (the ramp filter), compensates the uneven sampling of Fourier space in filtered backprojection (Section 12.1.5). Further kernels, and the filtering of images in Fourier space, are explored in the practical of the CryoEM doeboek.

9.5. Projections and the projection theorem#

A transmission electron microscope image of a thin specimen is, to a good approximation, the projection of the three-dimensional electrostatic potential of the specimen along the beam direction (the projection approximation that we will discuss in detail in Section 10.1). The projection theorem relates a projection to the Fourier transform of the object, and it is the basis of all methods that reconstruct a three-dimensional structure from projection images.

Let \(V(x,y,z)\) denote the electrostatic potential of the object. The orientation of the object relative to the microscope is described by a rotation \(R\), which is specified by three Euler angles. In the convention used in cryo-EM (rot, tilt and psi), the first two are the azimuth and polar angle of the viewing direction, and the third is an in-plane rotation of the image about it. The beam runs along \(z\), and the projected potential of the rotated object is

(9.4)#\[ V_{\mathrm{p},R}(x,y) = \int V\!\left(R^{-1}(x,y,z)\right) \mathrm{d}z \]

For the identity rotation (no rotation) this is the projected potential \(V_\mathrm{p}(x,y)\) of the projection approximation (Section 10.1). In the following chapters, we write \(P\) for a projection in general. Equivalently, the object can be kept fixed and projected along the direction \(\mathbf{n} = R^{-1}(0,0,1)\), which is the direction of the beam in the frame of the object. Two projections along \(\mathbf{n}\) and \(-\mathbf{n}\) are mirror images of each other, so that viewing directions on a half-sphere are sufficient. In addition, the image is shifted by the (unknown) position of the object in the field of view. In electron tomography, a single angle (the tilt angle) varies and is typically known. In single-particle analysis, all three angles and the two shifts of every particle are unknown and have to be estimated.

The projection theorem (also called the central section theorem or Fourier slice theorem) states that the two-dimensional Fourier transform of the projection of a three-dimensional object along \(\mathbf{n}\) is the section of the three-dimensional Fourier transform \(\hat{V}\) of the object that passes through the origin and is perpendicular to \(\mathbf{n}\):

(9.5)#\[ \hat{V}_{\mathrm{p},R}(k_x,k_y) = \hat{V}\!\left(R^{-1}(k_x,k_y,0)\right) \]

Projections from different directions measure different planes, and together they fill three-dimensional Fourier space. Once enough of it is filled, an inverse three-dimensional Fourier transform gives the object. The demonstration below shows the theorem for a three-dimensional test object. The projection for the chosen orientation and its Fourier transform are compared with the corresponding section of the three-dimensional Fourier transform. The plane in the last panel is the section, and the red arrow is the viewing direction.

Interactive element

Click the rocket symbol at the top of the page and select Live Code, or expand the Show code toggle and click ▶ to run the cell. The two sliders change the viewing direction. The magnitude of the Fourier transform of the projection (second panel) agrees with the section of the three-dimensional Fourier transform (third panel) for every orientation, apart from small interpolation errors.

Hide code cell source

import io
import numpy as np
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from scipy.ndimage import affine_transform, map_coordinates
from ipywidgets import IntSlider, VBox, Image as ImageWidget
from IPython.display import display

_N_pt = 64
_g_pt = np.arange(_N_pt) - _N_pt/2
_Z_pt, _Y_pt, _X_pt = np.meshgrid(_g_pt, _g_pt, _g_pt, indexing='ij')

def _blob(c, s, a):
    return a*np.exp(-((_X_pt-c[0])**2 + (_Y_pt-c[1])**2 + (_Z_pt-c[2])**2)/(2*s**2))

# an asymmetric test object made of five Gaussian blobs
_vol = (_blob((0, 0, 0), 7, 1.0) + _blob((11, 0, 0), 4, 0.8) + _blob((-9, 6, -4), 4, 0.7)
        + _blob((0, -10, 8), 3.5, 0.9) + _blob((6, 9, 11), 3, 0.6))
_F3 = np.fft.fftshift(np.fft.fftn(_vol))
_k_pt = np.arange(_N_pt) - _N_pt/2
_KX_pt, _KY_pt = np.meshgrid(_k_pt, _k_pt)

def _rotation(rot, tilt):
    a, b = np.radians(rot), np.radians(tilt)
    Rz = np.array([[np.cos(a), -np.sin(a), 0], [np.sin(a), np.cos(a), 0], [0, 0, 1]])
    Ry = np.array([[np.cos(b), 0, np.sin(b)], [0, 1, 0], [-np.sin(b), 0, np.cos(b)]])
    return Ry @ Rz                                        # acts on (x, y, z)

def draw_section(rot, tilt):
    R = _rotation(rot, tilt)
    P = np.eye(3)[::-1]                                   # (x,y,z) <-> array order (z,y,x)
    M = P @ R.T @ P.T
    c = np.full(3, _N_pt/2)
    rotated = affine_transform(_vol, M, offset=c - M @ c, order=1)
    proj = rotated.sum(axis=0)                            # projection along the beam (z)
    ft_proj = np.abs(np.fft.fftshift(np.fft.fft2(proj)))
    q = np.einsum('ij,jn->in', R.T, np.stack([_KX_pt.ravel(), _KY_pt.ravel(), np.zeros(_KX_pt.size)]))
    coords = np.stack([q[2], q[1], q[0]]) + _N_pt/2          # (z, y, x) array indices
    sec = np.abs(map_coordinates(_F3.real, coords, order=1, mode='constant')
                 + 1j*map_coordinates(_F3.imag, coords, order=1, mode='constant')).reshape(_N_pt, _N_pt)

    fig = plt.figure(figsize=(13, 3.8))
    ax = fig.add_subplot(1, 4, 1)
    ax.imshow(proj, cmap='gray'); ax.set_title("2D projection of the 3D object", fontsize=9); ax.axis('off')
    ax = fig.add_subplot(1, 4, 2)
    ax.imshow(np.log1p(ft_proj), cmap='viridis'); ax.set_title("|FT| of the projection", fontsize=9); ax.axis('off')
    ax = fig.add_subplot(1, 4, 3)
    ax.imshow(np.log1p(sec), cmap='viridis'); ax.set_title("central section of the 3D FT", fontsize=9); ax.axis('off')
    ax = fig.add_subplot(1, 4, 4, projection='3d')
    u = np.linspace(-1, 1, 5); U, W = np.meshgrid(u, u)
    pts = np.einsum('ij,jn->in', R.T, np.stack([U.ravel(), W.ravel(), np.zeros(U.size)]))
    ax.plot_surface(pts[0].reshape(5, 5), pts[1].reshape(5, 5), pts[2].reshape(5, 5), alpha=0.35, color='tab:blue')
    n = R.T @ np.array([0, 0, 1.0])
    ax.quiver(0, 0, 0, *n, color='tab:red', length=1.0, arrow_length_ratio=0.15)
    ax.set_xlim(-1, 1); ax.set_ylim(-1, 1); ax.set_zlim(-1, 1)
    ax.set_xlabel('$k_x$'); ax.set_ylabel('$k_y$'); ax.set_zlabel('$k_z$')
    ax.set_title("plane in 3D Fourier space\n(red: viewing direction)", fontsize=9)
    fig.tight_layout()
    buf = io.BytesIO(); fig.savefig(buf, format='png', dpi=96); buf.seek(0)
    plt.close(fig); return buf.getvalue()

_style_sec = {"description_width": "130px"}
rot_sl  = IntSlider(value=30, min=0, max=360, step=10, description="Rotation (°)", style=_style_sec, layout={"width": "380px"})
tilt_sl = IntSlider(value=50, min=0, max=180, step=10, description="Tilt (°)", style=_style_sec, layout={"width": "380px"})

out_sec = ImageWidget(format='png', layout={'max_width': '100%'})
def update_sec(_=None):
    out_sec.value = draw_section(rot_sl.value, tilt_sl.value)
for _sl_sec in [rot_sl, tilt_sl]:
    _sl_sec.observe(update_sec, names='value')

display(VBox([rot_sl, tilt_sl, out_sec]))
update_sec()

9.5.1. From projections to a reconstruction#

Two routes lead from a set of projections to the three-dimensional object. In Fourier inversion, the two-dimensional Fourier transforms of the projections are inserted as sections into a three-dimensional Fourier volume, weighted, and transformed back. This route is used in the final reconstruction step of single-particle analysis (Section 11.6.3). In weighted backprojection, every projection is smeared back through the volume along its viewing direction and the smeared images are added, with the weighting applied by filtering the projections beforehand. This route is the standard in electron tomography, where it is introduced for a two-dimensional slice (Section 12.1.2 and Section 12.1.5). The two routes are equivalent, because backprojection is the real-space counterpart of inserting a section into Fourier space.

Both routes require the orientation of every projection. In electron tomography, it is given by the tilt angle, apart from the alignment of the images (Section 12.4.2). In single-particle analysis, it has to be estimated by comparing every particle image with projections of a reference, and the reconstruction and the orientations are refined iteratively (Section 11).

Practical

The Fourier transform, sampling, convolution and filtering are explored in the corresponding practical of the CryoEM doeboek: CryoEM doeboek: Fourier analysis