Project

General

Profile

RE: Extracting stage positions from mrc files ยป imagepositions.py

Anchi Cheng, 10/26/2015 02:26 PM

 
#!/usr/bin/env python
"""
Program to list a scope parameter x y values in microns
based on session name and preset name
"""
import sys

# import data objects used in query
from leginon import leginondata

def format_input(msg=''):
print ''
return raw_input(msg)

# get sessiondata from sessionname
sessions = []
while len(sessions) != 1:
sessionname = format_input('Enter session name: ')
if not sessionname:
continue
sessions = leginondata.SessionData(name=sessionname).query()
sessiondata = sessions[0]

# get all imagedata from preset name
images = []
while len(images) == 0:
presetname = format_input('Enter preset name to display info: ')
if not presetname:
continue
presetq = leginondata.PresetData(session=sessiondata,name=presetname)
images = leginondata.AcquisitionImageData(session=sessiondata,preset=presetq).query()

# display infos
choices = ['stage position','image shift']

try:
choice_str = format_input("""
Choose what parameter to display\n
1 - stage position\n
2 - image shift\n
""")
choice = int(choice_str)
param = choices[choice-1]
except:
print 'invalid choice. Please rerun'
sys.exit(1)

print '%s\t%s\t%s' % ('filename','x (micron)','y (micron)')
for image in images:
print '%s\t%.2f\t%.2f' % (image['filename']+'.mrc',
image['scope'][param]['x']*1e6,
image['scope'][param]['y']*1e6)

    (1-1/1)