本文整理汇总了Python中emapplication.EMApp.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python EMApp.exec_方法的具体用法?Python EMApp.exec_怎么用?Python EMApp.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类emapplication.EMApp
的用法示例。
在下文中一共展示了EMApp.exec_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
usage="[prog] <2D image file> "
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
(options, args) = parser.parse_args()
logid=E2init(sys.argv)
filename=args[0]
app = EMApp()
img=EMData(filename)
#print img[0]["mean"]
w=EMBreakBrick(img,app)
#w.set_data(img,filename)
app.show_specific(w)
app.exec_()
E2end(logid)
示例2: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog 3Dstack [options]
Visulaizse and compute the mean amplitude and sigma in the missing wedge region. After you are sasified that the missing wedge looks sane, compute missing wedge stats
on all volumes. These stats are used by the aligner tomo.fsc, for subtomogram alignment and averaging.
"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_pos_argument(name="tdstack",help="The 3D stack to examine.", default="", guitype='filebox', row=0, col=0,rowspan=1, colspan=2)
parser.add_header(name="wedgeheader", help='Options below this label are specific to e2wedge', title="### e2wedge options ###", row=1, col=0, rowspan=1, colspan=2)
parser.add_argument("--wedgeangle",type=float,help="Missing wedge angle",default=60.0, guitype='floatbox', row=2, col=0, rowspan=1, colspan=1)
parser.add_argument("--wedgei",type=float,help="Missingwedge begining", default=0.05)
parser.add_argument("--wedgef",type=float,help="Missingwedge ending", default=0.5)
parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-1)
parser.add_argument("--nogui", action="store_true", default=False, help="Do not launch the GUI and set the average of the missing wedge statistics on all the volumes.")
parser.add_argument("--averagestats", action="store_true", default=False, help="Do not launch the GUI and set the average of the missing wedge statistics on all the volumes.")
(options, args) = parser.parse_args()
stack=args[0]
if not options.nogui:
em_app = EMApp()
wedgeviewer = MissingWedgeViewer(stack, options.wedgeangle, wedgei=options.wedgei, wedgef=options.wedgef)
wedgeviewer.show()
ret=em_app.exec_()
sys.exit(ret)
else:
means=[]
sigmas=[]
n=EMUtil.get_image_count(stack)
for i in range(n):
a = EMData(stack,i)
retr = wedgestats(a,options.wedgeangle,options.wedgei,options.wedgef)
mean = retr[0]
sigma = retr[1]
if options.averagestats:
means.append(mean)
sigmas.append(sigma)
else:
a['spt_wedge_mean'] = mean
a['spt_wedge_sigma'] = sigma
print "The mean and sigma for subvolume %d are: mean=%f, sigma=%f" % (i,mean,sigma)
a.write_image(stack,i)
if options.averagestats:
meanavg = sum(means)/len(means)
sigmaavg = sum(sigmas)/len(sigmas)
print "The average mean and sigma for the wedges in the stack are", meanavg, sigmaavg
for i in range(n):
a = EMData(stack,i)
a['spt_wedge_mean'] = meanavg
a['spt_wedge_sigma'] = sigmaavg
a.write_image(stack,i)
return()
示例3: display_validation_plots
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def display_validation_plots(path, radcut, planethres, plotdatalabels=False, color='#00ff00', plotzaxiscolor=False):
from emimage2d import EMImage2DWidget
from emapplication import EMApp
r = []
theta = []
datap = []
zaxis = []
try:
tpdb = js_open_dict("%s/perparticletilts.json"%path)
tplist = tpdb["particletilt_list"]
maxcolorval = max(tplist, key=lambda x: x[3])[3]
for tp in tplist:
if tp[3] > planethres: # if the out of plane threshold is too much
continue
if plotdatalabels: datap.append(tp[0])
r.append(tp[1])
theta.append(math.radians(tp[2]))
# Color the Z axis out of planeness
zaxis.append(computeRGBcolor(tp[3],0,maxcolorval))
tpdb.close()
except:
print "Couldn't load tp from DB, not showing polar plot"
data = None
try:
data = EMData("%s/contour.hdf"%path)
except:
print "Couldn't open contour plot"
if not data and not (theta and r): return
app = EMApp()
if theta and r:
plot = EMValidationPlot()
plot.set_data((theta,r),50,radcut,datap)
# Color by Z axis if desired
if plotzaxiscolor: plot.set_scattercolor([zaxis])
plot.set_datalabelscolor(color)
plot.show()
if data:
image = EMImage2DWidget(data)
image.show()
app.exec_()
示例4: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
progname = os.path.basename(sys.argv[0])
usage = progname + """ [options] <xml>
Convert xml to txt and optionally display them.
"""
args_def = {'display':1}
parser = argparse.ArgumentParser()
parser.add_argument("xml", nargs='*', help="specify xml files to be processed")
parser.add_argument("-d", "--display", type=int, help="disply (1) or not (0), by default {}".format(args_def['display']))
args = parser.parse_args()
if len(sys.argv) == 1:
print "usage: " + usage
print "Please run '" + progname + " -h' for detailed options."
sys.exit(1)
# get default values
for i in args_def:
if args.__dict__[i] == None:
args.__dict__[i] = args_def[i]
#
for xml in args.xml:
with open(xml+'.txt', 'w') as w_txt:
for coord in XE.parse(xml).getroot():
for xy in coord:
if xy.tag == 'x':
w_txt.write(xy.text + '\t')
else:
w_txt.write(xy.text + '\n')
# display
if args.display == 1:
app = EMApp()
for xml in args.xml:
filename = xml+'.txt'
w = EMWidgetFromFile(filename,application=app,force_2d=False)
w.setWindowTitle(base_name(filename))
app.show_specific(w)
app.exec_()
示例5: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog [options]
A simple CTF simulation program. Doesn't read or process data. Just does mathematical simulations.
"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_argument("--apix",type=float,help="Angstroms per pixel for all images",default=1.0, guitype='floatbox', row=4, col=0, rowspan=1, colspan=1, mode="autofit['self.pm().getAPIX()']")
parser.add_argument("--voltage",type=float,help="Microscope voltage in KV",default=300.0, guitype='floatbox', row=4, col=1, rowspan=1, colspan=1, mode="autofit['self.pm().getVoltage()']")
parser.add_argument("--cs",type=float,help="Microscope Cs (spherical aberation)",default=4.1, guitype='floatbox', row=5, col=0, rowspan=1, colspan=1, mode="autofit['self.pm().getCS()']")
parser.add_argument("--ac",type=float,help="Amplitude contrast (percentage, default=10)",default=10, guitype='floatbox', row=5, col=1, rowspan=1, colspan=1, mode='autofit')
parser.add_argument("--samples",type=int,help="Number of samples in the plotted curve",default=256)
parser.add_argument("--verbose", "-v", dest="verbose", action="store", metavar="n", type=int, default=0, help="verbose level [0-9], higner number means higher level of verboseness")
(options, args) = parser.parse_args()
from emapplication import EMApp
app=EMApp()
gui=GUIctfsim(app,options.apix,options.voltage,options.cs,options.ac,options.samples)
gui.show_guis()
app.exec_()
示例6: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog [options]
This is a program to compute the resolution of a n averaged subtomogram. Right now it is very simple simple divide the aligned
subtomos into even/odd classes, average and then compute the FSC. In the future this program will be extended to compute
resolution of an averged subtomo vs a reference and hopefuly of a single sub/tomogram.
"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_pos_argument(name="tomodir",help="The refinement directory to use for tomoresolution.", default="", guitype='dirbox', dirbasename='spt_', row=0, col=0,rowspan=1, colspan=2)
parser.add_header(name="tomoresoheader", help='Options below this label are specific to e2tomoresolution', title="### e2tomoresolution options ###", row=1, col=0, rowspan=1, colspan=2)
parser.add_argument("--averager",type=str,help="The averager used to generate the averages. Default is \'mean\'.",default="mean", guitype='combobox', choicelist='dump_averagers_list()', row=2, col=0, rowspan=1, colspan=2)
parser.add_argument("--sym", type=str,help="The recon symmetry", default="c1", guitype='symbox', row=3, col=0, rowspan=1, colspan=2)
parser.add_argument("--mask", type=str,help="The mask to apply before FSC calculation", default=None, guitype='comboparambox', choicelist='re_filter_list(dump_processors_list(),\'mask\')', row=4, col=0, rowspan=1, colspan=2)
parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-1)
(options, args) = parser.parse_args()
if options.mask: options.mask = parsemodopt(options.mask)
logid=E2init(sys.argv,options.ppid)
fscstrategy = EvenOddReso(args[0], options)
fscstrategy.execute()
results_db = db_open_dict("bdb:%s#convergence.results"%args[0])
results_db["tomo_fsc"] = [fscstrategy.getFreq(),fscstrategy.getFSC(),fscstrategy.getError()]
results_db.close()
E2end(logid)
# Plot FSC
app = EMApp()
plot = EMPlot2DWidget()
plot.set_data((fscstrategy.getFreq(),fscstrategy.getFSC()))
plot.show()
app.exec_()
示例7: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
global debug,logid
progname = os.path.basename(sys.argv[0])
usage = """%prog [options]
This program allows the user to play around with Fourier synthesis graphically
"""
parser = OptionParser(usage=usage,version=EMANVERSION)
# parser.add_option("--gui",action="store_true",help="Start the GUI for interactive fitting",default=False)
parser.add_option("--verbose", "-v", dest="verbose", action="store", metavar="n", type="int", default=0, help="verbose level [0-9], higner number means higher level of verboseness")
(options, args) = parser.parse_args()
app=EMApp()
win=GUIFourierSynth(app)
win.show()
try:
win.raise_()
win.synthplot.raise_()
except: pass
app.exec_()
示例8: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
#.........这里部分代码省略.........
parser.add_option("--voltage",type="float",help="Microscope voltage in KV",default=0)
parser.add_option("--cs",type="float",help="Microscope Cs (spherical aberation)",default=0)
parser.add_option("--ac",type="float",help="Amplitude contrast (percentage, default=10)",default=10)
parser.add_option("--autohp",action="store_true",help="Automatic high pass filter of the SNR only to remove initial sharp peak, phase-flipped data is not directly affected (default false)",default=False)
#parser.add_option("--invert",action="store_true",help="Invert the contrast of the particles in output files (default false)",default=False)
parser.add_option("--nonorm",action="store_true",help="Suppress per image real-space normalization",default=False)
parser.add_option("--nosmooth",action="store_true",help="Disable smoothing of the background (running-average of the log with adjustment at the zeroes of the CTF)",default=False)
#parser.add_option("--phaseflip",action="store_true",help="Perform phase flipping after CTF determination and writes to specified file.",default=False)
#parser.add_option("--wiener",action="store_true",help="Wiener filter (optionally phaseflipped) particles.",default=False)
parser.add_option("--oversamp",type="int",help="Oversampling factor",default=1)
parser.add_option("--sf",type="string",help="The name of a file containing a structure factor curve. Can improve B-factor determination.",default=None)
parser.add_option("--debug",action="store_true",default=False)
(options, args) = parser.parse_args()
if len(args)<1 : parser.error("Input image required")
if global_def.CACHE_DISABLE:
from utilities import disable_bdb_cache
disable_bdb_cache()
if options.auto_fit:
if options.voltage==0 : parser.error("Please specify voltage")
if options.cs==0 : parser.error("Please specify Cs")
if options.apix==0 : print "Using A/pix from header"
debug=options.debug
global sfcurve
if options.sf :
sfcurve=XYData()
sfcurve.read_file(options.sf)
logid=E2init(sys.argv)
# if options.oversamp>1 : options.apix/=float(options.oversamp)
db_project=db_open_dict("bdb:project")
db_parms=db_open_dict("bdb:e2ctf.parms")
db_misc=db_open_dict("bdb:e2ctf.misc")
options.filenames = args
### Power spectrum and CTF fitting
if options.auto_fit:
img_sets=pspec_and_ctf_fit(options,debug) # converted to a function so to work with the workflow
### This computes the intensity of the background subtracted power spectrum at each CTF maximum for all sets
global envelopes # needs to be a global for the Simplex minimizer
# envelopes is essentially a cache of information that could be useful at later stages of refinement
# as according to Steven Ludtke
for i in img_sets:
envelopes.append(ctf_env_points(i[2],i[3],i[1]))
# we use a simplex minimizer to try to rescale the individual sets to match as best they can
scales=[1.0]*len(img_sets)
if (len(img_sets)>3) :
incr=[0.2]*len(img_sets)
simp=Simplex(env_cmp,scales,incr)
scales=simp.minimize(maxiters=1000)[0]
# print scales
print " "
# apply the final rescaling
envelope=[]
for i in range(len(scales)):
cur=envelopes[i]
for j in range(len(cur)):
envelope.append((cur[j][0],cur[j][1]*scales[i]))
envelope.sort()
envelope=[i for i in envelope if i[1]>0] # filter out all negative peak values
db_misc=db_open_dict("bdb:e2ctf.misc")
db_misc["envelope"]=envelope
#db_close_dict("bdb:e2ctf.misc")
#out=file("envelope.txt","w")
#for i in envelope: out.write("%f\t%f\n"%(i[0],i[1]))
#out.close()
### GUI - user can update CTF parameters interactively
if options.gui :
img_sets = get_gui_arg_img_sets(options.filenames)
if len(img_sets) == 0:
E2end(logid)
sys.exit(1)
app=EMApp()
gui=GUIctf(app,img_sets)
gui.show_guis()
app.exec_()
print "done execution"
### Process input files
#if debug : print "Phase flipping / Wiener filtration"
# write wiener filtered and/or phase flipped particle data to the local database
#if options.phaseflip or options.wiener: # only put this if statement here to make the program flow obvious
# write_e2ctf_output(options) # converted to a function so to work with the workflow
E2end(logid)
示例9: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog [options] <image file> ...
This program can be used to visualize most files used in EMAN2. Running it without arguments
will open a browser window with more flexible functionality than the command-line.
"""
global app,win,options
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_argument("--classmx",type=str,help="<classmx>,<#> Show particles in one class from a classification matrix. Pass raw particle file as first argument to command.")
parser.add_argument("--classes",type=str,help="<rawptcl>,<classmx> Show particles associated class-averages")
parser.add_argument("--pdb",type=str,help="<pdb file> Show PDB structure.")
parser.add_argument("--singleimage",action="store_true",default=False,help="Display a stack in a single image view")
parser.add_argument("--plot",action="store_true",default=False,help="Data file(s) should be plotted rather than displayed in 2-D")
parser.add_argument("--plot3",action="store_true",default=False,help="Data file(s) should be plotted rather than displayed in 3-D")
parser.add_argument("--fullrange",action="store_true",default=False,help="A specialized flag that disables auto contrast for the display of particles stacks and 2D images only.")
parser.add_argument("--newwidget",action="store_true",default=False,help="Use the new 3D widgetD. Highly recommended!!!!")
parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-2)
parser.add_argument("--verbose", "-v", dest="verbose", action="store", metavar="n", type=int, default=0, help="verbose level [0-9], higner number means higher level of verboseness")
(options, args) = parser.parse_args()
# logid=E2init(sys.argv)
app = EMApp()
#gapp = app
#QtGui.QApplication(sys.argv)
win=[]
if options.fullrange:
fullrangeparms = set_full_range()
if len(args) < 1:
global dialog
file_list = []
dialog = embrowser.EMBrowserWidget(withmodal=False,multiselect=False)
dialog.show()
try: dialog.raise_()
# QtCore.QObject.connect(dialog,QtCore.SIGNAL("ok"),on_browser_done)
# QtCore.QObject.connect(dialog,QtCore.SIGNAL("cancel"),on_browser_cancel)
except: pass
elif options.pdb:
load_pdb(args,app)
elif options.plot:
plot(args,app)
elif options.plot3:
plot_3d(args,app)
elif options.classes:
options.classes=options.classes.split(",")
imgs=EMData.read_images(args[0])
display(imgs,app,args[0])
QtCore.QObject.connect(win[0].child,QtCore.SIGNAL("mousedown"),lambda a,b:selectclass(options.classes[0],options.classes[1],a,b))
try:
out=file("selected.lst","w")
out.write("#LST\n")
out.close()
except: pass
elif options.classmx:
options.classmx=options.classmx.split(",")
clsnum=int(options.classmx[1])
imgs=getmxim(args[0],options.classmx[0],clsnum)
display(imgs,app,args[0])
else:
for i in args:
if not file_exists(i):
print "%s doesn't exist" %i
sys.exit(1)
display_file(i,app,options.singleimage,usescenegraph=options.newwidget)
if options.fullrange:
revert_full_range(fullrangeparms)
app.exec_()
示例10: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog [options] <image> <image2>....
The even newer version of e2boxer. Complete rewrite. Incomplete.
This program
"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_pos_argument(name="micrographs",help="List the file to process with e2boxer here.", default="", guitype='filebox', browser="EMBoxesTable(withmodal=True,multiselect=True)", row=0, col=0,rowspan=1, colspan=3, mode="boxing,extraction")
parser.add_argument("--invert",action="store_true",help="If specified, inverts input contrast. Particles MUST be white on a darker background.",default=False, guitype='boolbox', row=3, col=2, rowspan=1, colspan=1, mode="extraction")
parser.add_argument("--boxsize","-B",type=int,help="Box size in pixels",default=-1, guitype='intbox', row=2, col=0, rowspan=1, colspan=3, mode="boxing,extraction")
parser.add_argument("--ptclsize","-P",type=int,help="Longest axis of particle in pixels (diameter, not radius)",default=-1, guitype='intbox', row=2, col=0, rowspan=1, colspan=3, mode="boxing,extraction")
parser.add_argument("--apix",type=float,help="Angstroms per pixel for all images",default=-1, guitype='floatbox', row=4, col=0, rowspan=1, colspan=1, mode="autofit['self.pm().getAPIX()']")
parser.add_argument("--voltage",type=float,help="Microscope voltage in KV",default=-1, guitype='floatbox', row=4, col=1, rowspan=1, colspan=1, mode="autofit['self.pm().getVoltage()']")
parser.add_argument("--cs",type=float,help="Microscope Cs (spherical aberation)",default=-1, guitype='floatbox', row=5, col=0, rowspan=1, colspan=1, mode="autofit['self.pm().getCS()']")
parser.add_argument("--ac",type=float,help="Amplitude contrast (percentage, default=10)",default=10, guitype='floatbox', row=5, col=1, rowspan=1, colspan=1, mode='autofit')
parser.add_argument("--no_ctf",action="store_true",default=False,help="Disable CTF determination", guitype='boolbox', row=3, col=0, rowspan=1, colspan=1, mode="extraction")
parser.add_argument("--autopick",type=str,default=None,help="Perform automatic particle picking. Provide mode and parameter string")
parser.add_argument("--write_dbbox",action="store_true",default=False,help="Export EMAN1 .box files",guitype='boolbox', row=3, col=0, rowspan=1, colspan=1, mode="extraction")
parser.add_argument("--write_ptcls",action="store_true",default=False,help="Extract selected particles from micrographs and write to disk", guitype='boolbox', row=3, col=1, rowspan=1, colspan=1, mode="extraction[True]")
parser.add_argument("--gui", action="store_true", default=False, help="Interactive GUI mode")
parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-1)
parser.add_argument("--verbose", "-v", dest="verbose", action="store", metavar="n", type=int, default=0, help="verbose level [0-9], higner number means higher level of verboseness")
(options, args) = parser.parse_args()
global invert_on_read
if options.invert : invert_on_read = True
#####
# Parameter Validation
project_db = js_open_dict("info/project.json")
if not (options.gui or options.write_ptcls or options.write_dbbox or options.autopick):
print "Error: No actions specified. Try --gui for interactive/semi-automated particle picking."
if not options.no_ctf :
if options.voltage>1500 :
options.voltage/=1000
print "Voltage specified in kV. Adjusting specified value to ",options.voltage
if options.voltage<10 :
try:
options.voltage=project_db["global.microscope_voltage"]
print "Using project voltage of ",options.voltage,"kV"
except:
print "Error: No voltage specified, and no project settings available. Disabling CTF mode."
options.no_ctf=True
if options.cs<0 :
try:
options.cs=project_db["global.microscope_cs"]
print "Using project Cs of ",options.cs,"mm"
except:
print "Error: No Cs specified, and no project settings available. Disabling CTF mode."
options.no_ctf=True
if options.ac<0 and not options.no_ctf:
print "Error: Invalid %AC value. Disabling CTF mode."
options.no_ctf=True
if options.ac<1.0 :
print "Warning: %AC should be specified as a %. If you intended a %AC>1%, please try again. Will proceed with the specified value"
if options.apix<=0 :
try:
options.apix=project_db["global.apix"]
print "Warning: No A/pix specified. Using ",options.apix," from project. Please insure this is correct for the images being boxed!"
except:
print "Error: Value required for A/pixel. If this is a non TEM image, suggest --apix=1 and --no_ctf."
sys.exit(1)
logid=E2init(sys.argv,options.ppid)
if options.autopick!=None :
pass
if options.gui :
if isinstance(QtGui,nothing) :
print "====================================="
print "ERROR: GUI mode unavailable without PyQt4"
sys.exit(1)
from emapplication import EMApp
app=EMApp()
gui=GUIBoxer(args,options.voltage,options.apix,options.cs,options.ac,options.boxsize,options.ptclsize)
gui.show()
app.exec_()
if options.write_dbbox:
pass
if options.write_ptcls:
pass
E2end(logid)
示例11: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
progname = os.path.basename(sys.argv[0])
helpstring = """Help is available on the following topics:
processors, cmps, aligners, averagers, projectors, reconstructors, analyzers, symmetries, orientgens, rotationtypes"""
usage = """prog <topic> [contains]
Interactive help on a variety of the eman2 library's modular functions. The optional 'contains' argument will
act as a filter on the names of the algorithms."""
usage += " "+helpstring
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
#parser.add_argument("--res", "-R", type=float, help="Resolution in A, equivalent to Gaussian lowpass with 1/e width at 1/res",default=2.8)
#parser.add_argument("--box", "-B", type=str, help="Box size in pixels, <xyz> or <x>,<y>,<z>")
parser.add_argument("--gui", action="store_true", help="Use the GUI for display help", default=False)
parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-2)
parser.add_argument("--verbose", "-v", dest="verbose", action="store", metavar="n", type=int, default=0, help="verbose level [0-9], higner number means higher level of verboseness")
(options, args) = parser.parse_args()
if options.gui:
from e2projectmanager import TheHelp
from emapplication import EMApp
app = EMApp()
thehelp = TheHelp()
thehelp.show()
if args:
print args[0]
if args[0] in ("aligner","aligners"):
thehelp._helpchange(0)
elif args[0] in ("analyzer","analyzers"):
thehelp._helpchange(1)
elif args[0] in ("averager","averagers"):
thehelp._helpchange(2)
elif args[0] in ("cmp","cmps"):
thehelp._helpchange(3)
elif args[0] in ("orientgen","orientationgen","orientgens","orientationgens","orientationgenerators"):
thehelp._helpchange(4)
elif args[0] in ("processor","processors"):
thehelp._helpchange(5)
elif args[0] in ("projector","projectors"):
thehelp._helpchange(6)
elif args[0] in ("reconstructor","reconstructors"):
thehelp._helpchange(7)
elif args[0] in ("sym","symmetry","symmetries"):
thehelp._helpchange(8)
app.exec_()
exit(0)
if len(args)<1 :
print helpstring
exit(0)
l=None
if args[0] in ("cmp","cmps") :
print "Available comparators:"
l=dump_cmps_list()
elif args[0] in ("analyzer","analyzers") :
print "Available analysers:"
l=dump_analyzers_list()
elif args[0] in ("averager","averagers") :
print "Available averagers:"
l=dump_averagers_list()
elif args[0] in ("processor","processors") :
print "Available processors:"
l=dump_processors_list()
elif args[0] in ("projector","projectors") :
print "Available projectors:"
l=dump_projectors_list()
elif args[0] in ("reconstructor","reconstructors") :
print "Available reconstructors:"
l=dump_reconstructors_list()
elif args[0] in ("aligner","aligners") :
print "Available aligners:"
l=dump_aligners_list()
elif args[0] in ("sym","symmetry","symmetries") :
print "Available symmetries:"
l=dump_symmetries_list()
elif args[0] in ("orientgen","orientationgen","orientgens","orientationgens","orientationgenerators") :
print "Available orientation generators:"
l=dump_orientgens_list()
elif args[0][:8]=="rotation" :
print "Available rotation conventions:"
l={"eman":["EMAN convention, az(Z),alt(X),phi(Z') Eulers","alt","FLOAT","Altitude, X-axis","az","FLOAT","Azimuth, Z-axis","phi","FLOAT","Z' Axis. in-plane rotation in 2-D"],
"imagic":["IMAGIC convention","alpha","FLOAT","alpha","beta","FLOAT","beta","gamma","FLOAT","gamma"],
"spider":["SPIDER convention","phi","FLOAT","phi","theta","FLOAT","theta","psi","FLOAT","psi"],
"mrc":["MRC/CCP4 convention","omega","FLOAT","omega","theta","FLOAT","theta","psi","FLOAT","psi"],
"xyz":["XYZ convention (Chimera)","x","FLOAT","X-axis","y","FLOAT","Y-axis","z","FLOAT","Z-axis"],
"spin":["Spin-Axis (n1,n2,n3) vector with angle omega","n1","FLOAT","X vector component","n2","FLOAT","Y vector component","n3","FLOAT","Z vector component","omega","FLOAT","Angle of rotation in degrees"],
"sgirot":["SGI Spin-Axis (n1,n2,n3) vector with angle q","n1","FLOAT","X vector component","n2","FLOAT","Y vector component","n3","FLOAT","Z vector component","q","FLOAT","Angle of rotation in degrees"],
"quaternion":["Standard 4 component quaternion (e0,e1,e2,e3)","e0","FLOAT","e0","e1","FLOAT","e1","e2","FLOAT","e2","e3","FLOAT","e3"]}
elif args[0] in ("version"):
print EMANVERSION + ' (CVS' + DATESTAMP[6:-2] +')'
else:
print helpstring
print "unknown option:",args[0]
if l:
if options.verbose>0:
#.........这里部分代码省略.........
示例12: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
usage="Generate training set for tomogram segmentation. This program is still experimental. Please consult the developers before using. "
print usage
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_header(name="tmpheader", help='temp label', title="### This program is NOT avaliable yet... ###", row=0, col=0, rowspan=1, colspan=2, mode="box,seg,set")
#### boxing ####
parser.add_argument("--boxing",action="store_true",help="Boxing particles.",default=False, guitype='boolbox', row=4, col=0, rowspan=1, colspan=1, mode='box[True]')
parser.add_pos_argument(name="micrographs",help="List the file to process with e2boxer here.", default="", guitype='filebox', browser="EMRawDataTable(withmodal=True,startpath=\"rawtomograms\")", row=1, col=0,rowspan=1, colspan=3, mode="box")
parser.add_argument("--boxsize","-B",type=int,help="Box size in pixels",default=-1, guitype='intbox', row=3, col=0, rowspan=1, colspan=3, mode="box")
#### segment ####
#parser.add_header(name="instruction", help='instruction', title="### Mark the target features white ###", row=0, col=0, rowspan=1, colspan=2, mode="seg")
parser.add_argument("--segment",action="store_true",help="Segment particles.",default=False, guitype='boolbox', row=4, col=0, rowspan=1, colspan=1, mode='seg[True]')
parser.add_pos_argument(name="particles",help="Particle file.", default="", guitype='filebox', browser="EMParticlesTable(withmodal=True)", row=1, col=0,rowspan=1, colspan=3, mode="seg")
parser.add_argument("--output", type=str,help="output file name. Default is the input particle file name plus _seg.hdf", default=None,guitype='strbox', row=3, col=0, rowspan=1, colspan=3, mode="seg")
#### build set ####
parser.add_argument("--buildset",action="store_true",help="Segment particles.",default=False, guitype='boolbox', row=7, col=0, rowspan=1, colspan=1, mode='set[True]')
parser.add_argument("--particles_raw", type=str,help="Input raw particle file", default=None,guitype='filebox',browser="EMParticlesTable(withmodal=True)", row=1, col=0, rowspan=1, colspan=3, mode="set")
parser.add_argument("--particles_label", type=str,help="Input labels for particle file", default=None,guitype='filebox',browser="EMParticlesTable(withmodal=True)", row=2, col=0, rowspan=1, colspan=3, mode="set")
parser.add_argument("--boxes_negative", type=str,help="Input boxes of negative samples", default=None,guitype='filebox',browser="EMParticlesTable(withmodal=True)", row=3, col=0, rowspan=1, colspan=3, mode="set")
parser.add_argument("--ncopy",type=int,help="Number of copies for NEGATIVE samples. (number of copies of particles is calculated accordingly) ",default=20, guitype='intbox', row=5, col=0, rowspan=1, colspan=1, mode="set")
parser.add_argument("--trainset_output", type=str,help="output file name of the training set.Default is the input particle file name plus _trainset.hdf", default=None,guitype='strbox', row=4, col=0, rowspan=1, colspan=3, mode="set")
##################
parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-1)
(options, args) = parser.parse_args()
logid=E2init(sys.argv)
#### boxing ###
if options.boxing:
db = js_open_dict(EMBOXERBASE_DB)
cache_box_size = True
if options.boxsize == -1:
cache_box_size = False
options.boxsize = db.setdefault("box_size",64)
application = EMApp()
module = EMBoxerModule(args,options.boxsize)
module.show_interfaces()
application.execute(logid)
#### segment ###
if options.segment:
filename=args[0]
if options.output==None:
options.output=filename[:-4]+"_seg.hdf"
app = EMApp()
img=EMData.read_images(filename)
#print img[0]["mean"]
w=EMImageWidget(data=img,old=None,app=app,force_2d=True)
#w = EMWidgetFromFile(filename,application=app,force_2d=True)
w.setWindowTitle(base_name(filename))
w.show_inspector(1)
ins=w.get_inspector()
ins.mmtab.setCurrentIndex(5)
ins.dtpenv.setText('100')
w.set_mouse_mode(5)
app.show_specific(w)
app.exec_()
try: os.remove(options.output)
except:pass
for e in img:
e.process_inplace("threshold.belowtozero", {"minval":99})
e.process_inplace("threshold.binary", {"value":1})
e.write_image(options.output,-1)
#### build set ###
if options.buildset:
tomo_in=options.particles_raw
seg_in=options.particles_label
neg_in=options.boxes_negative
if tomo_in and neg_in and seg_in:
n_ptcl=EMUtil.get_image_count(tomo_in)
n_neg=EMUtil.get_image_count(neg_in)
if options.trainset_output==None:
options.trainset_output=tomo_in[:-4]+"_trainset.hdf"
p_copy=options.ncopy*n_neg/n_ptcl
else:
p_copy=options.ncopy
try: os.remove(options.trainset_output)
except: pass
print "making {} copies for particles, and {} copies for negative samples".format(p_copy,options.ncopy)
if tomo_in and seg_in:
n_ptcl=EMUtil.get_image_count(tomo_in)
for i in range(n_ptcl):
t=EMData(tomo_in,i)
s=EMData(seg_in,i)
for c in range(p_copy):
tr=Transform()
rd=random.random()*360
tr.set_rotation({"type":"2d","alpha":rd})
e=t.process("xform",{"transform":tr})
#e.process_inplace("normalize")
e.write_image(options.trainset_output,-1)
#.........这里部分代码省略.........
示例13: IPY
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def IPY():
global ttx
launch_new_instance()
# app = TerminalIPythonApp.instance()
# app.initialize()
# app.start()
print "Exiting e22.py"
ttx = True
def on_timer():
global ttx
if ttx:
QtGui.qApp.quit()
ipythr = threading.Thread(target=IPY)
ipythr.run()
app = EMApp()
EMAN2.GUIMode = True
EMAN2.app = app
mytimer = QtCore.QTimer()
QtCore.QObject.connect(mytimer, QtCore.SIGNAL("timeout()"), on_timer)
mytimer.start(500)
app.exec_()
示例14: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog Refinement directory [options]
Plot Euler angle distributions for refinement results. Poiont size is proportional to Euler bin count.
>"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
#parser.add_pos_argument(name="plot_files",help="List the directories to plot here.", default="", guitype='filebox', browser="EMBrowserWidget(withmodal=True,multiselect=True)", row=0, col=0,rowspan=1, colspan=2)
parser.add_pos_argument(name="refinedir",help="The refinement directory to use for FSC plotting.", default="", guitype='dirbox', dirbasename='refine|TiltValidate', row=0, col=0,rowspan=1, colspan=2)
parser.add_header(name="eulerheader", help='Options below this label are specific to e2plotEuler', title="### e2plotEuler options ###", row=1, col=0, rowspan=1, colspan=1)
parser.add_argument("--iteration",type=int,help="Refinement iteration to plot", default=0, guitype='intbox', row=2, col=0, rowspan=1, colspan=1)
parser.add_argument("--pointwidth",type=float,help="The relative scale of the points plotted. The absoule size is dpenedent on particle count", default=1.0, guitype='floatbox', row=2, col=1, rowspan=1, colspan=1)
parser.add_argument("--sym", dest="sym", default="c1", help="Set the symmetry; if no value is given then the model is assumed to have no symmetry.\nChoices are: i, c, d, tet, icos, or oct.", guitype='symbox', row=3, col=0, rowspan=1, colspan=2)
parser.add_argument("--norticklabels",action="store_true",help="Disable radius tick labels", guitype='boolbox', row=4, col=0, rowspan=1, colspan=1, default=False)
parser.add_argument("--nothetaticklabels",action="store_true",help="Disable Theta tick labels", guitype='boolbox', row=4, col=1, rowspan=1, colspan=1, default=False)
parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-1)
(options, args) = parser.parse_args()
# Grab the data
iteration = 0
data = EMData.read_images("bdb:%s#classify_%02d"%(args[0],iteration))
projections = EMData.read_images("bdb:%s#projections_%02d"%(args[0],iteration))
# We use a hash data structure to count same Eulers(could also use an array an sort it)
eulerhash = {}
for i in xrange(data[0].get_ysize()):
# Get Eulers
projnum = int(data[0][i])
euler = projections[projnum].get_attr('xform.projection')
#Loop over all syms
for sym in Symmetries.get(options.sym).get_syms():
eulerangles = (sym*euler).get_rotation('eman')
# Use has to count unique eulers
hashkey = "%3.2f %3.2f"%(eulerangles['az'],eulerangles['alt'])
if eulerhash.has_key(hashkey):
eulerhash[hashkey] += 1
else:
eulerhash[hashkey] = 1
# Now plot these eulers
theta = []
r = []
size = []
for euler, count in eulerhash.items():
eulers = euler.split()
theta.append(float(eulers[0]))
r.append(float(eulers[1]))
size.append(count*options.pointwidth)
# Make the QT app and plot
app = EMApp()
plot = EMPolarPlot2DWidget()
plot.set_yticklabels(not options.norticklabels)
plot.set_xticklabels(not options.nothetaticklabels)
plot.setAxisParms(False,False)
plot.set_data((theta,r),linewidth=50,radcut=180)
plot.setPointSizes(size)
plot.show()
app.exec_()
示例15: main
# 需要导入模块: from emapplication import EMApp [as 别名]
# 或者: from emapplication.EMApp import exec_ [as 别名]
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog Refinement directory [options]
Plot FSC curvers produced by e2refine, eotest, etc.
>"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
#dirbasename='refine|frealign',
#parser.add_pos_argument(name="plot_files",help="List the directories to plot here.", default="", guitype='filebox', browser="EMBrowserWidget(withmodal=True,multiselect=True)", row=0, col=0,rowspan=1, colspan=2)
parser.add_header(name="filterheader", help='There is no help', title="This program is currently not functional. The table below is still useful,\n but for actual plots, suggest using e2evalrefine.py for now.", row=0, col=0, rowspan=1, colspan=2)
parser.add_pos_argument(name="fscdir",help="The refinement directory to use for FSC plotting.", default="", guitype='fsctable', row=1, col=0,rowspan=1, colspan=2)
parser.add_header(name="filterheader", help='Options below this label are specific to e2plotFSC', title="### e2plotFSC options ###", row=2, col=0, rowspan=1, colspan=2)
parser.add_argument("--plote2res",action="store_false",help="Plot curves from e2resoltion",default=True,guitype='boolbox',row=3,col=0,rowspan=1,colspan=1)
parser.add_argument("--plote2eotest",action="store_false",help="Plot curves from e2eotest",default=True,guitype='boolbox',row=3,col=1,rowspan=1,colspan=1)
parser.add_argument("--plotconvergence",action="store_false",help="Plot curves from refinement convergence",default=True,guitype='boolbox',row=4,col=0,rowspan=1,colspan=1)
parser.add_argument("--ploteoconvergence",action="store_false",help="Plot curves from refine_even_odd convergence",default=True,guitype='boolbox',row=4,col=1,rowspan=1,colspan=1)
parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-1)
(options, args) = parser.parse_args()
# Make the QT app
app = EMApp()
# display table
if len(args) == 0:
fsctable = PMFSCTableWidget("fsc","",None,resize=True)
fsctable.show()
# or let user choose FSC plotting pars
else:
module = EMPlot2DWidget()
# Get data from data base
db_name = "bdb:"+args[0]+"#convergence.results"
if not db_check_dict(db_name):
print "Rubbish!!!, no FSC curves found!!!"
return
db = db_open_dict(db_name,ro=True)
keys = db.keys()
# Load desired FSC curves
res = []
eo = []
conv = []
eoconv = []
# Method to the maddness, I use not here because I need to only plot when open is not presented AND I need to keep presentation on in the GUI
if not options.plote2res: res= get_e2resolution_results_list(keys)
if not options.plote2eotest: eo = get_e2eotest_results_list(keys)
if not options.plotconvergence: conv = get_convergence_results_list(keys)
if not options.ploteoconvergence: eoconv = get_e2refine_even_odd_results_list(keys)
# Plot FSC curves
i = 0
max = len(colortypes)
for k in conv:
module.set_data(db[k],k,color=(i%max),linewidth=1) # there are only a ceratin number of colors
i += 1
# plot e2refine_even_odd curves
for k in eoconv:
module.set_data(db[k],k,color=(i%max),linewidth=2) # there are only a ceratin number of colors
i += 1
#plot eo test and res
for plot in [eo,res]:
for k in plot:
module.set_data(db[k],k,color=(i%max),linewidth=3) # there are only a ceratin number of colors
i += 1
module.show()
app.exec_()