Skip to content

Tomographic Reconstruction

FriedrichFoerster edited this page May 26, 2020 · 9 revisions

Overview

Pytom supports the complete workflow of tomography, ranging from alignment of tilt series to reconstruction. For tilt series alignment, Pytom currently supports the alignment of projections by fiducials. Reconstruction by weighted backprojection and Iterative Nonuniform Fourier Reconstruction (INFR).

Theory and Implementation

Theory and Implementation

Alignment of tilt series

Prior to a 3D reconstruction projections must be aligned to a common coordinate system because despite the best efforts to keep the feature of interest in the center during acquisition movement is inevitable. Moreover, the electron optical lens system causes image rotations and even subtle focus-dependent magnification changes, which need to be compensated for.

Currently, PyTom only supports alignment by fiducials (gold beads). The positions of markers in the projection images need to be provided in the form of a text file (result of interactive marker localisation in the PyTomGUI) or in an EM-file (This file can be obtained by interactive marker localization in the AV3/TOM or EM packages). There is also a function in AV3 to convert IMOD marker files to an EM file (av3_wimp2em.m) and a direct import function into PyTom.

The PyTom alignment function simply minimizes the residual error of the coordinates projected from a 3D model (i.e., each marker has 3 coordinates assigned) and the observed coordinates in the projections. In more detail, 3D coordinates of the marker model, the projection shifts, and the image rotation are first computed using an analytical approach, in which a constant rotation (=tilt axis) and magnification is assumed (TiltAlignment.computeCoarseAlignment). This function determines a tilt axis (to x-axis) between 0 and 180 degrees; by definition for a tilt axis x there is a second solution, x+180 deg, that would satisfy the marker equations equally well. You need prior knowledge to decide, which tilt axis is correct - assuming the wrong tilt axis will yield reconstructions with the inverted handedness. In the alignment it can be specified if the solution 180<x<360 deg is supposed to be correct rather than the default solution 0<x<180 (handflip=True).

To determine the 3D coordinate system of the markers the coordinates of one marker point need to be defined. Thus, a reference marker needs to be chosen (irefmark). Reference coordinates (r) can be assigned to this reference marker or default values can be chosen. The default value is r=(x_iref-center,y_iref-center,0). x_iref and y_iref are the coordinates of the marker in a reference projection iref. The choice of the coordinates will determine the determined shifts of projections. In other words: different choices of the coordinates of the reference marker will result in shifted 3D reconstructions!

After approximate determination of the image rotations, translations, and 3D coordinates of the markers an optimization algorithm (TiltAlignment.alignFromFiducials) determines the tilt-angle specific image rotation, tilt-angle specific magnification, and again translations and 3D coordinates. For the reference projection iref the magnification is defined as 1.

The projections are aligned by inverse application of the determined translations, rotations, and magnifications to each projection. The transformation is carried out as a single interpolation in real space (default interpolation method: 3rd order spline).

Weighted Backprojection

If a tomogram were reconstructed from the unprocessed projections the low-frequency information would be artificially enhanced as illustrated in Fig.1. To obtain a truthful 3D image the information below the so-called Crowther frequency need to be attenuated. This is accomplished by weighting the projections in Fourier space proportional to its frequency perpendicular to the tilt axis. This can be approximated as a 'ramp' function (analytical weighting). A more accurate weighting scheme would be to explicitly compute the overlapping information in Fourier space (exact weighting, not yet implemented in PyTom). In many cases it makes sense to furthermore apply a low-pass filter to the data to eliminate noise, which is dominant in the higher frequencies.

Crowther criterion and sampling Fig. 1Sampling of Fourier space by projections in 2D. The Fourier transform of each projection samples a slice of Fourier space (black lines); its normal is determined by the tilt angle. The signal ‘leak’ of each sample point into the neighboring area is reciprocally proportional to the diameter D of the object. For reconstruction, the Fourier coefficients on the 3D grid (intersected lines) need to be approximated from the sampling points of the projections by an appropriate algorithm. In principle, the 3D signal can be reconstructed without any gaps to a resolution ''k_C'' if the entire tilt range of +/-90 deg was accessible. Restricting the tilting to +/-90 deg gives rise to a ‘missing wedge’.


3D Reconstruction of tomogram

Reconstruction using weighted backprojection
xx
Reconstruction using weighted backprojection In PyTom reconstructions are performed using backprojection. The algorithm can use different interpolation kernels. By default we use a 3rd order spline.

Reconstruct a tomogram using reconstructTomogram.py In our tutorial data-set you will find a directory reconstructTomo where you can perform reconstruction of a full tomogram by weighted backprojection. Projections will be aligned and weighted during this step so that the data you start with are unaligned and unweighted projections. Essentially raw projections only sorted according to the tilt angle. Running this script will generate a full tomogram.em file, either 2x binned (4x downscaled) (512,512,128) or in original size (2048,2048,512). The reconstructTomo.sh is essentially the only script you have to run to obtain the aligned, weighted projections and the 2x binned tomogram.

reconstructTomogram.py --tiltSeriesPath ../projections/ \ 
						--tiltSeriesPrefix tomo01_sorted \
					 	--firstIndex 1 \
					 	--lastIndex 41 \
					 	--referenceIndex 21 \
					 	--markerFile ../projections/markfile_temp.mark \
					 	--referenceMarkerIndex 1 \
					 	--projectionTargets ./alignedProjections/tomo01 \
					 	--projectionBinning 4 \
					 	--lowpassFilter 0.5 \
					 	--tomogramFile tomogram.em \
					 	--fileType em \
					 	--tomogramSizeX 512 \
					 	--tomogramSizeY 512 \
					 	--tomogramSizeZ 128 \
					 	--reconstructionCenterX 0 \
					 	--reconstructionCenterY 0 \
					 	--reconstructionCenterZ 0 

In order to get acquainted with the parameters of reconstructTomogram.py, simply run reconstructTomogram.py --help In detail the provided parameters for reconstruction are:

  • tiltSeriesPath: Relative or absolute path to tilt series EM
  • tiltSeriesPrefix: Prefix of projections before running index (projections in EM or MRC format)
  • firstIndex: Index of first projection
  • lastIndex: Index of last projection
  • referenceIndex: Index of reference projection used for alignment
  • markerFile: Name of markerfile (in EM format, .e.g., generated using TOM)
  • referenceMarkerIndex: Index of reference marker to set up coordinate system
  • handflip: Is your tilt series outside of 0-180deg
  • projectionTargets: Relative or absolute path to the aligned projections that will be generated + file prefix
  • fineAlignFile: Relative or absolute path to the file with fineAlign parameters (type should be *.dat)
  • projectionBinning: Binning of projections during read (factor!)
  • lowpassFilter: Lowpass filter (after binning)
  • tomogramFile: Relative or absolute path to final tomogram (no tomogram written if not specified)
  • fileType: File type (can be EM or MRC - no tomogram written if not specified)
  • tomogramSizeX: Size of tomogram in x (no tomogram written if not specified)
  • tomogramSizeY: Size of tomogram in y (no tomogram written if not specified)
  • tomogramSizeZ: Size of tomogram in z (no tomogram written if not specified)
  • reconstructionCenterX: Center where tomogram will be reconstructed (no tomogram written if not specified)
  • reconstructionCenterY: Center where tomogram will be reconstructed (no tomogram written if not specified)
  • reconstructionCenterZ: Center where tomogram will be reconstructed (no tomogram written if not specified)
  • weightingType: type of weighting. -1: r-weighting (default), 0: no weighting.
  • verbose: verbose mode All further steps shown in the tutorial are based on particles detected within this tomogram.
Reconstruction using INFR PyTom also supports a reconstruction algorithm called Iterative Nonuniform fast Fourier transform based Reconstruction method (INFR). For more details about this algorithm, please check: Iterative reconstruction of cryo-electron tomograms using nonuniform fast Fourier transforms, Y. Chen et al., JSB 2014.

The way to use it is simple:

pytom PathToPytom/reconstruction/reconstruct_INFR.py
It requires the following parameters:
  • -d: The directory name, in which all the aligned and unweighted projections are stored. Note that the projections should be EM format and the tilt angle information must be specified in the headers!
  • -i: Optional, the number of iterations to run. 10 by default.
  • -o: Output filename.
Note that INFR requires a lot of memory. Currently it is limited to 1k x 1k projections on most computers (i.e., depending on the amount of memory you have). To create the aligned projections you can also use PyTom. Simply use the script for WBP reconstruction, but omit weighting and reconstruction (--weightingType 0):
pytom PathToPytom/bin/reconstructTomogram.py --tiltSeriesPath MyTiltSeriesDir \
        --tiltSeriesPrefix NameOfTiltSeriesFiles --firstIndex 1 --lastIndex MyLastIndex \
        --referenceIndex MyReferenceProjectionIndex --markerFile MyMarkerFile \
        --referenceMarkerIndex MyReferenceMarkerIndex --projectionTargets \
        MyFileNameOfAlignedProjections --projectionBinning MyBinning --weightingType 0
Import Marker coordinates from IMOD

overview

IMOD is a common program for reconstruction of electron tomograms. In particular, it has handy functionality for tracking fiducial markers and features. The coordinates of these features can be used for alignment in pytom, as described in the following. From the files automatically generated during alignment with etomo the marker coordinates for later use in PyTom can be obtained. You will need one file from IMOD for reconstruction containing the coordinates of the markers in the un-transformed tiltseries: the WIMP file. IMOD itself by default makes use of a pre-transformed tiltseries according to a crude pre-alignment of the tiltseries (see also: tiltalign documentation). Thus, in order to get the raw marker coordimates you need to transform them back, either in PyTom or the built-in IMOD functions. IMOD will internally store the marker coordinates in a .fid file and the pre-transformation in a .prexg file. Moreover, the marker coordinates are stored in a coordinate system that is pre-shifted compared to the original files. The pre-shift binning value is somewhat hidden in the advanced options of the preprocessing tab in IMOD.

If you transform the marker coordinates in PyTom everything is straightforward. You obtain the WIMP files using 3dmod:

  1. Start 3dmod by typing 3dmod in the command line.
  2. Select the model file (myTiltSeries.fid), which is generated by the etomo workflow.
  3. Press 'OK'.
  4. A viewer for the tilt series and the small 3dmod window opens.
  5. Save WIMP file in the 3dmod window using menu: File -> Write Model As -> Wimp.

Alternatively you can convert the coordinates using imod tools, which is mentioned for the sake of completeness here: To convert the pre-transformed marker coordinates back to their original values the following IMOD programs can be used from the command line (see also: xfmodel):

xfmodel -back -prealign myTiltSeries.prexg -input myTiltSeries.fid -o myTiltSeries_raw.fid

For tiltseries myTiltSeries, this command will generate a .fid file with back-transformed marker coordinates (=myTiltSeries_raw.fid). In case you worked with binned images in the IMOD alignment you will also need to revert the binning. For example, the command would be the following for selection scale=1/8 (1/binimod):

xfmodel -back -scale 0.1250 -prealign myTiltSeries.prexg -input myTiltSeries.fid -o myTiltSeries_raw.fid

The _raw.fid file can now be converted into an WIMP file in 3dmod from the IMOD package:

  1. Start 3dmod by typing 3dmod in the command line.
  2. Select the raw model file (the myTiltSeries_raw.fid, which was just generated). If you need to revert binning make sure you select model and also tilt series- otherwise the magnification is somehow not taken into account - weird ...
  3. Press 'OK'.
  4. A viewer for the tilt series and the small 3dmod window opens.
  5. Save WIMP file in the 3dmod window using menu: File -> Write Model As -> Wimp.

Tomogram Alignment from WIMP file

The reconstruction script now supports alignment from WIMP files. Just specify the WIMP file as the markerfile instead of an EM markerfile and there you go. Additionally, you may often need to specify the tilt angles in the form of a tlt file because they are typically not stored anywhere in the header.