NOTE This is an additional information for optimized_ali2d_c. If you want to back to the main page, please click optimized_ali2d_c.
Overview
- The program does alignment from the current alignment parameters 'psi', 'sx', 'sy', and 'mirror' stored in file headers.
The ali2d_c (original version) is for performing 2-D reference-free alignment of an image series (without CTF correction). For the optimization purpose, the optimized ali2d cm (modified version) dosen't have x range (sx) and y range (sy) which are for translation search in x and y directions. Both programs show the same result if you set translation ranges are set to zero which corresponds to rotational alignment only in the case of the original version . We also ignore the translation step in this case since we don't have any search direction.
- For the program to work, attributes 'psi', 'sx', 'sy', and 'mirror' have to be set in the header of each file. If their values are not known, all should be set to zero. The program will not change the input images, only the alignment parameters in their header.
Program structure
1) Stack of images either as a file or as a list and line parameters get into the ali2d cm.py
- 2) Prepare the empty ring and calculate the average to prepare a reference image.
- 3) Iteration starts.
- 4) Reference image gets into the Polar coordinates and apply FFT.
- 5) Align the images in the stack.
- i. Add centering from the previous iteration, if image was mirrored, flip the sign of x center.
- ii. Each image gets into the Polar coordinates and apply FFT.
- iii. Take cross correlation to alignment.
- 6) Combine parameters and set them to the header.
- 7) Write the stack with updated parameters.
- 8) Aligning all images, calculate total average using current alignment parameters.
- 9) End of the processing after all iterations.
Flow chart and data flow
Programs used in the ali2d_cm.py
1) os.path.exists() : checking whether a directory exists or not.
2) os.mkdir() : creating an output directory, if it does not exist.
3) get_image_count() : counting number of images.
4) EMData() : putting an image(data) into a memory.
5) read_image() : reading images.
6) get_xsize : getting the size of image.
7) aves() : calculating total average using current alignment parameters.
8) dropImage() : writing an image to the disk or assign to an output object.
9) cmp : calculating the criterion(norm).
10) Numrinit : rearranging to be a ring vector.
11) ringwe : calculating ring weights for rotational alignment.
12) model_circle : creating a centered circle.
13) Polar2Dm : converting an image to plar coordinates.
14) Frngs : taking 1-D FFT to the ring fromed data.
15) Applywe : applying the weight to the FFT formed data.
16) get_attr() : getting transformation parameters.
17) compose_transforms2 : printing the composition of two transformations T2*T1.
18) combine_params2 : combining 2D alignent parameters.
19) ave_oe_series() : calculating odd an even averages of a image series.
Time - Stopwatch
We can play with below simple python functions to measure execution time. The programs are in utilities.py and just put start_time() and finish_time() in your code. It makes sense to optimize code.
def start_time():
- import time start_time = time.time()
return start_time
def finish_time(start_time):
- import time finish_time = time.time()
- run_time = finish_time-start_time
- print ("Running time is"), run_time
return finish_time