# OptimizeReferences

This logic aligns class averages so that they share the same mutual orientation. After a classification step different classes might contain the same view, but rotated in the image plane (i.e. different α-angles), so an alignment is needed to optimize the class averages before using them as references for image alignment.

The quality of the output heavily depends on the quality of the first class average chosen - preferably, it should show enough details of the molecule or complex and be surrounded by a black rim. The optimal values suggested for radius parameter are around 0.8-0.9.

Parameters Description
Correlation Function The correlation function that is optimized during the image alignment
Fraction The maximal fraction of the image that will be shifted relative to the reference image during the alignment
Interpolation Defines the interpolation function used to get the value between two neighbouring pixels
Radius The value of Circular Mask Fraction (this fraction of image dimension will be used as diameter of the circle cut from the image for cf calculations)
Sampling The maximal fraction of the image shifted during the alignment relative to the reference image

The logic takes a stack of class average images as input. It applies the circular mask of radius changed by parameter 'Radius' to every image, so that only the defined circle and not the surrounding noise will be used for correlation calculations. Then the logic aligns every image to the first one by shifting them in polar coordinates (that corresponds to rotation of image in Cartesian coordinates) and maximizing the correlation function.