Differences between revisions 5 and 6
Revision 5 as of 2013-07-01 13:12:46
Size: 5973
Editor: localhost
Comment: converted to 1.6 markup
Revision 6 as of 2015-05-28 20:04:00
Size: 5774
Editor: penczek
Deletions are marked like this. Additions are marked like this.
Line 56: Line 56:
 * Also, for the program to work, attribute 'active' has to be set in the header of each file. If the image is going to be used, set to one, otherwise, set to zero, please refer to [[sxheader]].


sxstability - WILL WRITE LATER


usage in command line:

sxali2d.py stack outdir mask.hdf --ir=inner_radius --ou=outer_radius --rs=ring_step --xr=x_range --yr=y_range --ts=translation_step --dst=delta --center=center --maxit=max_iteration --CTF --snr=SNR --Fourvar --Ng=group_number --Function=user_function_name --MPI

usage in python programming:

ali2d (stack, outdir, maskfile=None, ir=1, ou=-1, rs=1, xr="4 2 1 1", yr="-1", ts="2 1 0.5 0.25", dst=0.0, center=-1, maxit=0, CTF=False, snr=1.0, Fourvar=False, Ng=-1, user_func_name="ref_ali2d", GPUID="", MPI=False)

  • To use MPI version:
  • mpirun -np 32 sxali2d.py ... --MPI
  • The above example is for mympi.

Typical usage

  1. Rotational alignment, set the particle radius:

    • sxali2d.py input_stack.hdf output_directory --ou=27
  2. 2-D alignment, set the particle radius, and x-y range and translational step for translational search:

    • sxali2d.py input_stack.hdf output_directory --ou=27 --xr="3 2 1" --yr="3 2 1" --ts="1 1 0.5"
  3. The above command can be written in Python code as:
    • ali2d(input_stack, output_directory, ou=27, xr="3 2 1", yr="3 2 1", ts="1 1 0.5")



set of 2-D images in a stack file (format hdf or bdb), images have to be square (nx=ny)

optional mask file to be used internally during alignment
  • The parameters preceded with -- are optional and default values are given in parenthesis.

  • inner_radius

    inner radius for rotational correlation > 0 (set to 1)


    outer radius for rotational correlation < nx/2-1 (set to nx/2-2, should be set to the radius of the particle)


    step between rings in rotational correlation > 0 (set to 1)

    range for translation search in x direction, search is +/xr (is set to "4 2 1 1", if set to "0" it corresponds to rotational alignment only)
    range for translation search in y direction, search is +/yr (is set to same as x_range, if set to "0" it corresponds to rotational alignment only)
    step of translation search in both directions, (set to "2 1 0.5 0.25", larger value increase the speed, but decrease the accuracy)

    -1 - use average centering method (default), 0 - if you do not want the average to be centered, 1 - phase approximation of the center of gravity phase_cog, 2 - cross-correlate with Gaussian function, 3 - cross-correlate with donut shape image (e.g. inner radius=2, outer radius=7), 4 - cross-correlate with reference image provided by user, 5 - cross-correlate with self-rotated average. Centering is performed in user-supplied function.

    maximum number of iterations the program will perform (default is 0, which means the maximum iteration is 10 and it will automatically stop should the criterion falls, otherwise the number of iteration reach the max_iteration without stop by the criterion)

    if this flag is set, the program will use CTF information provided in file headers (for details see I_O). (default no CTF)

    signal-to-noise ratio of the data (default SNR=1.0)
    use Fourier variance to weight the reference (recommended, default False)
    number of groups in the new CTF filteration

    name of the user-supplied-function that prepares reference image for each iteration (default ref_ali2d)

    if this flag is set, use MPI version
    use CUDA program
    ID of GPUs available


    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 program will crash and an error message will come up. Please change the name of directory and restart the program . The files will be written to this directory. The program will write two kind of files: the average of the aligned image series (aqc_***.hdf), (aqf_***.hdf), and the Fourier Resolution Criterion curve (drc***). These files are numbered by the iteration number starting at 1, not 0.
    the alignment parameters are stored in the headers of input files as 'xform.align2d'.


    • For the program to work, attribute 'xform.align2d' has to be set in the header of each file. If their values are not known, all should be set to zero, please refer to sxheader.

    • The program will start alignment from the current alignment parameter 'xform.align2d' stored in file headers. To erase previous alignment result, set them all to zero.
    • The program prints the value of the alignment criterion (see the reference). If the program is started using results of the previous alignment, the initial value of the criterion may be slightly lower than that achieved at the end of the previous alignment - this is due to numerical accuracy and it is not a reason to be concerned. However, for the same reason, the alignment may slightly change during the second run.
    • The program will not change the input images, only the alignment parameters in their header. In order to apply the alignment parameters to the images, use program sxtransform2d.



    Penczek 1992

    Author / Maintainer

    Pawel A. Penczek


    category 1


    sparx/bin/sxali2d.py, applications.py

    See also

    sxlocal_ali2d, sxmref_ali2d, sxtransform2d


    works for author, often works for others.


    The centering may fail. It will also fail if the images are not very similar to each other, say circles and rectangles.

    sxstability (last edited 2015-05-28 20:04:00 by penczek)