Conclusion and Observation
For the test, we run two diffrent programs (original version ali2d c vs. modified version ali2d cd. The alignment parameters are already applied to the images and the header reset. The images in a stack (hdf format) are already centered, but the angle still need to be refined.
If the result of the modified version are reasonable, we can measure and compare the processing time for each program. The modified version contains the simple stop watch and shows its running time on the window. Obviously, the modified version has to be faster, and other redundent commands inside of the original version also removed for optimizing purpose.
One of the experiment output is the average of the aligned image series (aqm***.spi) in /username/result/ directory. Note that the program will not change the input images, only the alignment parameters in their header. V2 is the application to observe image file *.spi. Below steps need to be done using program v2:
i. v2 <stackfile>
- ii. middle-click on the image display.
- iii. select several modes from the instpector window to handle the image.
We choose how many images will be in a stack for test. To obtain the number of images in the stack and write individual images from a stack file, we can increase the im total number of images in the stack file to let ali2d cm work longer.
ima = EMdata() nima = EMUtil.get_timae_count(stackfile) for im in xrange(nima) #if you want to have only 10 images, then nima = 9 ima.write_image(stackfile,im, EMUtil.ImageType.IMAGE_HDF, True)
Why the processing times are diffrent? - Major diffrence between two programs
The ali2d_cm(modified version) dosen't have x range (sx) and y range (sy) which are for translation search in x and y directions. Due to this, we can modify ormq and take out two for loops for searching ranges. Therefore, ormq returns only angt parameter to next step described in below.
for iter in xrange(max_iter): # prepare the reference for im in xrange(nima): # align all images to the reference [angt, sxst, syst, mirrort, peakt] = ormq(ima, cimage, xrng, yrng, step, mode, numr, cnx-sx, cny-sy) # combine parameters and set them to the header, ignore previous angle and mirror # apply params to the image
The original ormq is:
def ormq(image, crefim, xrng, yrng, step, mode, numr, cnx, cny): # Search for iy in range(-yrng, yrng+1, step): for ix in range(-xrng, xrng+1, step): cimage=Util.Polar2Dm(image, cnx+ix, cny+iy, numr, mode) Util.Frngs(cimage, numr) retvals = Util.Crosrng_ms(crefim, cimage, numr) qn = retvals["qn"] qm = retvals["qm"] co = cos(ang*pi/180.0) so = -sin(ang*pi/180.0) sxs = sx*co - sy*so sys = sx*so + sy*co return ang, sxs, sys, mirror, peak
As far as we don't care about yrng and xrin, we can get rid of two for loops and set sxs and sys to zero. Therefore, the modified ormq is:
cimage=Util.Polar2Dm(image, cnx, cny, numr, mode) Util.Frngs(cimage, numr) retvals = Util.Crosrng_ms(crefim, cimage, numr) qn = retvals["qn"] qm = retvals["qm"] return ang, mirror, peak
Reference image and all images will be into Polar coordinates. Those will be complex numbers applying FFT. These steps will allow ali2d c.pyto be compact.
Please click day_to_day_progress for the detail information.