-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathice_thickness_als.py
More file actions
executable file
·51 lines (42 loc) · 1.85 KB
/
Copy pathice_thickness_als.py
File metadata and controls
executable file
·51 lines (42 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/env python
# to get ice thickness from mean values of images by comparing with intensity
# wjr
# from
# Rice WJ, Cheng A, Noble AJ, Eng ET, Kim LY, Carragher B, Potter CS.
# Routine determination of ice thickness for cryo-EM grids. J Struct Biol. 2018
# Oct;204(1):38-44. doi: 10.1016/j.jsb.2018.06.007. Epub 2018 Jul 4. PubMed PMID:
# 29981485; PubMed Central PMCID: PMC6119488.
import global_def
from global_def import *
from glob import glob as glob
from math import log # natural log
from EMAN2 import *
from optparse import OptionParser
def GetData():
parser=OptionParser()
parser.add_option("--mfp", dest="mfp", help="default=300", default=300,metavar="MEAN_FREE_PATH")
# parser.add_option("--type", dest="img_type", help="default=enn-a", default = 'enn-a', metavar="IMAGE_TYPE")
parser.add_option("--vac", dest="Ivac", help="default=10", default = 10, metavar="VACUUM_INTENSITY")
parser.add_option("--outfile", dest="outfile", help="default=thickness.txt", default = 'thickness.txt', metavar="OUTPUT FILE")
parser.add_option("--filetype", dest="filetype", help="default=mrc", default = 'mrc', metavar="FILETYPE")
(options, args) = parser.parse_args()
#return (options.mfp,options.img_type,options.Ivac)
return (options.mfp,options.Ivac,options.outfile,options.filetype)
(mfp,Ivac,outfile,filetype) = GetData()
mfp = float(mfp)
Ivac = float(Ivac)
filestring = '*.' + filetype
icelist = glob.glob(filestring)
icelist.sort()
img_u=EMData() #placeholder for loading unfilt images
f=open(outfile,'w')
for image in icelist:
try:
img_u.read_image(image,0,True) # read only header
except (RuntimeError, TypeError, NameError):
print "error reading %s" %image
next
I = img_u.get_attr('MRC.mean')
thickness = log (Ivac/I)
calc = thickness * mfp
f.write("image %s calc_thickness (nm) %.1f\n" %(image,calc))