NOTE This is an additional information for optimized_ali2d_c. If you want to back to the main page, please click optimized_ali2d_c.
Description how to perform the test ali2d_cm
Before you start
1. Input file is the output of a certain initial alignment processing. We can generate test data sets using sparx/test/3DA/3da.py. It takes test 3D model model001.tcp, which is in cvs appearing in the sparx/test directory. It writes the test data sets proj.hdf in the same directory. The basic idea is that by changing parameters of even_angles you can generate various sets.
cd home/sparx/test/3DA 3da.py check_param.py proj.hdf
3da.py generates a list of quasi-uniformly distributed Eulerian angles which are 'phi','theta', rotaional angle 'psi'(set to zero) and two shift 'sx', 'sy'(set to zero). For rotational alignment, all particles to be placed at center(sx=sy=0). For exmaple, if you choose 90.0 and 90.1 for lower and upper range of theta, 0.0 and 179.9 for lower and upper range of phi, then you will 178 images in a stack. Note that 3da.py does not delete the output stack before filling it.
phi theta psi sx sy 1.010674119 90.0 0.0 0 0 2.02134823799 90.0 0.0 0 0 3.0320224762 90.0 0.0 0 0 4.04269647598 90.0 0.0 0 0 ~ ~ ~ ~ ~ 175.857299805 90.0 0.0 0 0 176.867965698 90.0 0.0 0 0 177.878646851 90.0 0.0 0 0 178.889312744 90.0 0.0 0 0- Likewise, if you choose 90.0 and 93.1 for lower and upper range of theta, 0.0 and 179.9 for lower and upper range of phi, then you will 712 images in a stack. Note that 3da.py does not delete the output stack before filling it.
phi theta psi sx sy 1.010674119 90.0 0.0 0 0 2.02134823799 90.0 0.0 0 0 3.0320224762 90.0 0.0 0 0 4.04269647598 90.0 0.0 0 0 ~ ~ ~ ~ ~ 175.857299805 90.0 0.0 0 0 176.867965698 90.0 0.0 0 0 177.878646851 90.0 0.0 0 0 178.889312744 90.0 0.0 0 0 ~ ~ ~ ~ ~ 175.857299805 91.0 0.0 0 0 176.867965698 91.0 0.0 0 0 177.878646851 91.0 0.0 0 0 178.889312744 91.0 0.0 0 0 ~ ~ ~ ~ ~ 175.857299805 92.0 0.0 0 0 176.867965698 92.0 0.0 0 0 177.878646851 92.0 0.0 0 0 178.889312744 92.0 0.0 0 0 ~ ~ ~ ~ ~ 175.857299805 93.0 0.0 0 0 176.867965698 93.0 0.0 0 0 177.878646851 93.0 0.0 0 0 178.889312744 93.0 0.0 0 0 To prevent the next program in line from using incorrect length stack file, we can simply add below code in 3d.py
nima = EMUtil.get_image_count(stack) if nima>nangles: os.remove("proj.hdf")2. We will align images using ali2d_c in cvs. However, we can use six Python programs for the optimazation purpose.
i. ali2d_cm.py in home/sparx/bin: This is an excute file to run ali2d_cm. Usage is discribed below.
ii. ali2d cm in home/sparx/libpy/applications.py
iii. check_params in home/sparx/libpy/utilities.py: It simply displays alignment parameters tored in the headers on the window.
iv. reset_params in home/sparx/libpy/utilities.py: To compare processing speed of ali2d_cm.py and ali2d_c.py, make sure that we need to reset all transformation parmeters to zeros before processing with reset_params.py. Otherwise, we will have diffrent translation parameters as an input for next processing and it will produce diffrent transformation parameters as an output.
v. start_time in home/sparx/libpy/utilities.py: It can measure the processing time for program or function.
vi. finish_time in home/sparx/libpy/utilities.py: This command should be located at the end of program. It prints a total processing time on the window. For example,
import utilities from start_time, finish_time t=start_time() # # function or program # finish_time(t)
Running ali2d_c
1. To start running ali2d c.py, type below line on the window. Make sure that you need to reset parameters before aligning since the program will use aligned paramers as an input for the next running.
reset_params.py proj.hdf ali2d_c.py input_stack.hdf output_directory --ir=1 --ou=-1 --rs=1 --xr=0 --yr=0 --ts=0 --c=1 --maxit=10
where the line parameters are ali2d_cm.py proj.hdf output_directory --ir=inner_radius --ou=outer_radius --rs=ring_step --c=center --maxit=max_iter. (*for detail information, please see ali2d_c.py)
i. proj.hdf: set of 2-D images in a stack file (format hdf)
ii. output_directory: directory name into which the output files will be written. If it does not exist, the directory will be created. If it does exist, the files will be written to this directory, so the files with the same names will be overwritten.
iii. inner_radius: inner radius for rotational correlation > 0 (set to 1)
iv. outer_radius: outer radius for rotational correlation <nx-1 (set to nx-2, should be set to the radius of the particle)
v. ring_step: step between rings in rotational correlation >0 (set to 1)
vi. x_range: range for translation search in x direction, search is +/xr (is set to zero, which corresponds to rotational alignment only)
NOTE If you set x_range = 0, then you will have the same result as we see in ali2d_cm
vii. y_range: range for translation search in y direction, search is +/yr (is set to zero, which corresponds to rotational alignment only)
NOTE If you set y_range = 0, then you will have the same result as we see in ali2d_cm
viii. translation_step: step of translation search in both directions direction, search is -xr, -xr+ts, 0, xr-ts, xr (set to 1, larger value increase the speed, but decrease the accuracy)
NOTE If you set x_range and y_range = 0, then you don't need to this parameter.
ix. center: 0 - if you do not want the average to be centered, 1 - center the average (default=1)
x. max_iter: maximum number of iterations the program will perform (set to 10)
- 2. The program starts alignment from the current alignment parameters 'psi', 'sx', 'sy', and 'mirror' stored in file headers. During the processing, it will print criterion values on the window.
Initial criterion= 0.0575985088944 ITERATION # 0 criterion = 0.0576094016433 ITERATION # 1 criterion = 0.0576277300715 ITERATION # 2 criterion = 0.0576285012066 ~ ITERATION # 7 criterion = 0.0576241239905 ITERATION # 8 criterion = 0.0576174110174 ITERATION # 9 criterion = 0.0576352216303 Running time is 20.522 3. The program writes two kind of files in the output_directory the average of the aligned image series (aqm***.spi) and the Fourier Resolution Criterion curve (drm***). Both files are numbered by the iteration number. The alignment parameters are stored in the headers of input files as 'psi', 'sx', 'sy', 'mirror'
4. The program contains start_time and finish_time. At the end of processing, it prints running time on the window.
- 5. To check the aligned parameters, just type,
check_params.py proj.hdf
- Then, you will see aligned parameters.
-89.9067382812 0.209929034114 -0.217901274562 0 -89.9067382812 0.209929034114 -0.217901274562 0 -89.3520507812 -2.13379240036 0.669863820076 0 -0.072021484375 -2.06623792648 1.11014401913 0 ~ 91.5833129883 2.93219470978 1.40046691895 0 -179.914611816 -0.620821535587 -0.190729439259 0 -0.101806640625 -2.06264472008 1.11613178253 0 -0.0067749023437 -2.06216406822 1.11863136292 0
Running ali2d_cm
1. To start running ali2d cm.py, type below line on the window. Make sure that you need to reset parameters before aligning since the program will use aligned paramers as an input for the next running.
reset_params.py proj.hdf ali2d_cm.py proj.hdf result --ir = 1 --ir = -1 --rs = 1 --center = 1 --maxit = 10
where the line parameters are ali2d_cm.py proj.hdf output_directory --ir=inner_radius --ou=outer_radius --rs=ring_step --c=center --maxit=max_iter.
i. proj.hdf: set of 2-D images in a stack file (format hdf)
ii. output_directory: directory name into which the output files will be written. If it does not exist, the directory will be created. If it does exist, the files will be written to this directory, so the files with the same names will be overwritten.
iii. inner_radius: inner radius for rotational correlation > 0 (set to 1)
iv. outer_radius: outer radius for rotational correlation <nx-1 (set to nx-2, should be set to the radius of the particle)
v. ring_step: step between rings in rotational correlation >0 (set to 1)
vi. center: 0 - if you do not want the average to be centered, 1 - center the average (default=1)
vii. max_iter: maximum number of iterations the program will perform (set to 10)
- 2. The program starts alignment from the current alignment parameters 'psi', 'sx', 'sy', and 'mirror' stored in file headers. During the processing, it will print criterion values on the window.
Initial criterion= 0.0575985088944 ITERATION # 0 criterion = 0.0576094016433 ITERATION # 1 criterion = 0.0576277300715 ITERATION # 2 criterion = 0.0576285012066 ~ ITERATION # 7 criterion = 0.0576241239905 ITERATION # 8 criterion = 0.0576174110174 ITERATION # 9 criterion = 0.0576352216303 Running time is 20.522 3. The program writes two kind of files in the output_directory the average of the aligned image series (aqm***.spi) and the Fourier Resolution Criterion curve (drm***). Both files are numbered by the iteration number. The alignment parameters are stored in the headers of input files as 'psi', 'sx', 'sy', 'mirror'
4. The program contains start_time and finish_time. At the end of processing, it prints running time on the window.
- 5. To check the aligned parameters, just type,
check_params.py proj.hdf
- Then, you will see aligned parameters.
-89.9067382812 0.209929034114 -0.217901274562 0 -89.9067382812 0.209929034114 -0.217901274562 0 -89.3520507812 -2.13379240036 0.669863820076 0 -0.072021484375 -2.06623792648 1.11014401913 0 ~ 91.5833129883 2.93219470978 1.40046691895 0 -179.914611816 -0.620821535587 -0.190729439259 0 -0.101806640625 -2.06264472008 1.11613178253 0 -0.0067749023437 -2.06216406822 1.11863136292 0