Project

General

Profile

Make DDD movie stack » correctframes.py

Anchi Cheng, 07/20/2014 08:08 AM

 
#!/usr/bin/env python
import sys
from appionlib import apDDprocess, apDatabase
from pyami import mrc, imagefun

if __name__ == '__main__':
dd = apDDprocess.DirectDetectorProcessing()
if len(sys.argv) != 4:
print 'Usage: correctframes.py start_frame nframe image'
print ' start_frame (int): first frame to use (minimal=0)'
print ' nframe (int): number of frames to sum up'
print ' image (str or int): imagefilename or imageid'
sys.exit()
start_frame = int(sys.argv[1])
nframe = int(sys.argv[2])
imagevalue = sys.argv[3]
try:
imageid = int(imagevalue)
# imagevalue is database imageid (an integer)
imagedata = apDatabase.getImageDataFromSpecificImageId(imageid)
except ValueError:
# imagevalue is filename
imgtree = apDatabase.getSpecificImagesFromDB([imagevalue])
imagedata = imgtree[0]
# replace filename with database imageid
imageid = imagedata.dbid
# choose the subclass to initiate using the session name
dd = apDDprocess.initializeDDFrameprocess(imagedata['session']['name'],False)
dd.setImageData(imageid)

corrected = dd.correctFrameImage(start_frame,nframe,False)
#outfile = 'corrected_frame%d_%d.mrc' % (start_frame,nframe)
outfile = 'corrected_frame%d.mrc' % (start_frame)
powfile = 'power.mrc'
mrc.write(corrected,outfile)
print ' '
print 'Saved as %s' % (outfile)
(1-1/3)