# Aligning micrographs

In Bsoft, micrographs are grouped into fields-of-view (or field for short). In many cases there will only be one micrograph per field. In other cases each field may contain two or more micrographs of the same area, such as:

- Focal pairs or series
- Dose series
- Tilt pairs or series (the latter could be tomographic series)

Each of these cases are treated separately.

## 1. Focal pairs

In a typical strategy for single particle analysis, focal pairs of micrographs are taken, with the first micrograph close to focus, and the second micrograph further from focus. The following treatment assumes that this strategy has been followed.

The recommended sequence of micrograph processing is: (i) determine the CTF parameters, (ii) pick particles in the further-from-focus micrograph, and (iii) align the closer-to-focus micrograph with the further-from-focus micrograph and calculate the particle positions in the former.

To do the alignment, the following are required to be set in the parameter (STAR) file:

1. All the micrograph data blocks for both close to focus and further from focus micrographs must be specified in the parameter file(s).
2. Each pair of micrographs must be specified within the same field-of-view, with the closer to focus micrograph first.
3. The sampling or pixel size must be correctly specified for each micrograph.
4. There should be particle records for the further from focus micrographs.

Here is an example setup for micrograph alignment starting from a set of parameter files:

bmg -v 7 -number 2 -Pixel 2.4 -output mg_67xx.star 670*.star

    Project hierarchy:
    Field: 6701
            Micrograph: 6701        Particles: 0 (0)        Filaments: 0 (0)
            Micrograph: 6702        Particles: 27 (27)      Filaments: 0 (0)
    Field: 6705
            Micrograph: 6705        Particles: 0 (0)        Filaments: 0 (0)
            Micrograph: 6706        Particles: 48 (48)      Filaments: 0 (0)
    Field: 6707
            Micrograph: 6707        Particles: 0 (0)        Filaments: 0 (0)
            Micrograph: 6708        Particles: 43 (43)      Filaments: 0 (0)
    Field: 6709
            Micrograph: 6709        Particles: 0 (0)        Filaments: 0 (0)
            Micrograph: 6710        Particles: 59 (59)      Filaments: 0 (0)
    Totals: 177 particles   177 selected    (100.0%)        0 filaments     0 filament nodes

bmgalign generates a set of panels or tiles for each micrograph, and then cross-correlates the corresponding tiles to produce a set of shift vectors. This set of shift vectors are then fit to a five-parameter model (xy shift, xy scale, and rotation angle) to determine the final alignment. The locations of the picked particles in the reference micrograph (the further from focus micrograph) is then transformed to predict the locations in the closer to focus micrograph.

bmgalign -v 7 -align mic -ref 2 -resol 5000,30 -correlate 2048,2048,1 -out mg_67xx_aln.star mg_67xx.star

Important options:

1. -resolution: The resolution limits are in angstrom and thus linked to the pixel size. Generally the idea is to cut out very low resolution features that does not contribute to alignment information, and high resolution information that is dominated by noise.
2. -correlate: The default tile size of 512,512,1 for cross-correlation is usually sufficient to get a successful alignment. However, when the alignment fails, increasing the tile size often works.

The key lines generated in the ouput shows the two micrographs compared, the shift vector (3 values), the scale vector (3 values), the rotation angle (in degrees), and the residual (in pixels). The aim is to get a low residual, typically on the order of 1-3 pixels. Usually when the alignment fails, the residual is large (10-100 pixels) and the key options mentioned above should be modified.

Example output lines:

    Best fit:       6702.tif        6701.tif         163.53  183.10    0.00 1.00228 1.00227 1.00000    0.06464         0.98
    Best fit:       6706.tif        6705.tif         -18.59 -107.90    0.00 1.00291 1.00315 1.00000    0.08264         1.29
    Best fit:       6708.tif        6707.tif         238.96   74.60    0.00 1.00286 1.00299 1.00000    0.13664         0.99
    Best fit:       6710.tif        6709.tif          47.01  146.23    0.00 1.00148 1.00299 1.00000   -0.09736         2.48

## 2. Dose series

The typical MRC file generated by CCD and direct cameras specify the images as slices of a 3D volume. Before processing in Bsoft, this needs to be corrected so that the programs interpret it as a stack of 2D images:

bhead -verb 1 -images May27_18.31.49.mrc 2014_05_27_18_31_49.mrc

Next generate a parameter file where each set of frames is configured as a field-of-view with the frames as individual micrographs:

bmg -verb 7 -extract mg -num 10 -out phi6_set1.star 2014_05_27_18_31_49.mrc

Then the micrographs within each field-of-view can be aligned by cross-correlation:

bseries -verb 1 -align 0 -resol 10,10000 -edge 20,10 -dat f -average phi6_set1 -out phi6_set1_aln.star phi6_set1.star

The resolution limits can be changed if the alignment did not work well. The edge smoothing option avoids artifacts associated with the micrograph edges.

## 3. Tilt pairs

The particles are picked in the two micrographs simultaneously to ensure the same numbering. There is no current method to align the micrographs and transfer the particle locations as is done for focal pairs.