本文整理汇总了Python中emapplication.EMApp类的典型用法代码示例。如果您正苦于以下问题:Python EMApp类的具体用法?Python EMApp怎么用?Python EMApp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EMApp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog [options] <image file>
Provides a GUI interface for applying a sequence of processors to an image, stack of images or a volume."""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
# parser.add_argument("--boxsize","-B",type=int,help="Box size in pixels",default=64)
# parser.add_argument("--shrink",type=int,help="Shrink factor for full-frame view, default=0 (auto)",default=0)
parser.add_argument("--apix",type=float,help="Override the A/pix value stored in the file header",default=0.0)
# parser.add_argument("--force2d",action="store_true",help="Display 3-D data as 2-D slices",default=False)
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()
if len(args) != 1: parser.error("You must specify a single data file on the command-line.")
if not file_exists(args[0]): parser.error("%s does not exist" %args[0])
# if options.boxsize < 2: parser.error("The boxsize you specified is too small")
# # The program will not run very rapidly at such large box sizes anyhow
# if options.boxsize > 2048: parser.error("The boxsize you specified is too large.\nCurrently there is a hard coded max which is 2048.\nPlease contact developers if this is a problem.")
# logid=E2init(sys.argv,options.ppid)
app = EMApp()
pix_init()
control=EMFilterTool(datafile=args[0],apix=options.apix,force2d=False,verbose=options.verbose)
# control=EMFilterTool(datafile=args[0],apix=options.apix,force2d=options.force2d,verbose=options.verbose)
control.show()
try: control.raise_()
except: pass
app.execute()
示例2: main
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)
示例3: main
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog
Presents a graphical representation of the orientation distribution of the particles in a single particle
reconstruction. This is displayed as a single asymmetric unit on a sphere, with cylinders of varying height
representing the number of particles found in each orientation. Middle-click will produce a control-panel
as usual, and clicking on a single peak will permit viewing the class-average and related projection
(and particles).
Normally launched without arguments from a e2workflow project directory.
"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_header(name="e2eulerxplorheader", help="Click Launch to Run e2eulerxplor.py", title="### Click Launch to Run e2eulerxplor.py ###", row=0, col=0, rowspan=1, colspan=3)
parser.add_argument("--eulerdata", "-e", type=str,help="File for Eulerdata, Ryan style, if none is given, data is read from the DB.",default=None)
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")
global options
(options, args) = parser.parse_args()
logid=E2init(sys.argv,options.ppid)
em_app = EMApp()
window = EMEulerWidget(file_name = options.eulerdata)
em_app.show_specific(window)
em_app.execute()
E2end(logid)
示例4: main
def main():
# an application
em_app = EMApp()
control1 = TestControl(em_app)
control2 = TestControl(em_app)
em_app.execute()
示例5: main
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog <projection file> <particles file>
Compare different similarity metrics for a given particle stack. Note that all particles and projections are
read into memory. Do not use it on large sets of particles !!!
"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
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 len(args)<2 :
print "Error, please specify projection file and particles file"
sys.exit(1)
logid=E2init(sys.argv,options.ppid)
em_app = EMApp()
window = EM3DGLWidget() #TODO: see if this should be a subclass of EMSymViewerWidget instead
explorer = EMCmpExplorer(window)
window.set_model(explorer)
explorer.set_data(args[0],args[1])
em_app.show()
em_app.execute()
E2end(logid)
示例6: main
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog [classfile]
This program provides tools for evaluating particle data in various ways. For example it will allow you to select class-averages
containing bad (or good) particles and manipulate the project to in/exclude them. It will locate files with class-averages automatically,
but you can specify additional files at the command-line.
"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_header(name="runeval", help='Click Launch to launch the particle evaluation interface', title="### Click Launch to run e2evalparticles ###", row=0, col=0, rowspan=1, colspan=1)
parser.add_argument("--gui",action="store_true",help="Start the GUI for interactive use (default=True)",default=True)
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()
#logid=E2init(sys.argv, options.ppid)
app = EMApp()
control=EMEvalPtclTool(args,verbose=options.verbose)
control.show()
app.execute()
示例7: main
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()
示例8: main
def main():
from emapplication import EMApp
em_app = EMApp()
pref_task = EMPreferencesTask()
pref_task.run_form()
em_app.execute()
示例9: main
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog [classfile]
THIS PROGRAM IS NOT YET COMPLETE
This program allows you to manually mark bad particles via a graphical interface.
"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_pos_argument(name="particles",help="List the file to process with e2ctf here.", default="", guitype='filebox', browser="EMCTFParticlesTable(withmodal=True,multiselect=True)", filecheck=False, row=0, col=0,rowspan=1, colspan=2, mode='autofit,tuning,genoutp,gensf')
parser.add_argument("--allparticles",action="store_true",help="Will process all particle stacks stored in the particles subdirectory (no list of files required)",default=False, guitype='boolbox',row=1, col=0, mode='autofit,tuning,genoutp,gensf')
parser.add_argument("--minptcl",type=int,help="Files with fewer than the specified number of particles will be skipped",default=0,guitype='intbox', row=2, col=0, mode='autofit,tuning,genoutp,gensf')
parser.add_argument("--minqual",type=int,help="Files with a quality value lower than specified will be skipped",default=0,guitype='intbox', row=2, col=1, mode='autofit,tuning,genoutp,gensf')
parser.add_argument("--gui",action="store_true",help="Start the GUI for interactive use (default=True)",default=True)
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()
if options.allparticles:
args=["particles/"+i for i in os.listdir("particles") if "__" not in i and i[0]!="." and ".hed" not in i ]
args.sort()
if options.verbose : print "%d particle stacks identified"%len(args)
# remove any files that don't have enough particles from the list
if options.minptcl>0 :
args=[i for i in args if imcount(i)>=options.minptcl]
if options.verbose: print "{} stacks after minptcl filter".format(len(args))
# remove files with quality too low
if options.minqual>0 :
outargs=[]
for i in args:
try:
if js_open_dict(info_name(i))["quality"]>=options.minqual : outargs.append(i)
except:
# traceback.print_exc()
print "Unknown quality for {}, including it".format(info_name(i))
outargs.append(i)
args=outargs
if options.verbose: print "{} stacks after quality filter".format(len(args))
#logid=E2init(sys.argv, options.ppid)
app = EMApp()
control=EMMarkPtclTool(args,verbose=options.verbose)
control.show()
app.execute()
示例10: main
def main():
progname = os.path.basename(sys.argv[0])
usage = """e2pdbviewer.py <project directory>
A wrapper program to view a .pdb file on your computer. This is simply an PDB
specific interface to the more general EMScene3D viewer.
"""
parser = EMArgumentParser(usage=usage, version=EMANVERSION)
parser.add_argument(
"--pdbfiles",
type=str,
help="Specify one or mode pdb files you \
wish to view",
nargs="*",
required=False,
default=None,
)
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()
logid = E2init(sys.argv, options.ppid)
app = EMApp()
viewer = EMScene3D()
if options.pdbfiles:
models = [EMStructureItem3D(pdb_file=pdbf) for pdbf in options.pdbfiles]
viewer.addChildren(models)
viewer.show()
app.execute()
E2end(logid)
示例11: main
def main():
global debug,logid
progname = os.path.basename(sys.argv[0])
usage = """prog [options] <single image file> ...
This program will allow you to evaluate an individual scanned micrograph or CCD frame, by looking at its
power spectrum in various ways."""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_pos_argument(name="image",help="Image to process with e2evalimage.", default="", guitype='filebox', browser="EMBrowserWidget(withmodal=True,multiselect=True)", row=0, col=0,rowspan=1, colspan=2, mode="eval")
parser.add_header(name="evalimageheader", help='Options below this label are specific to e2evalimage', title="### e2evalimage options ###", default=None, row=1, col=0, rowspan=1, colspan=2, mode="eval")
parser.add_argument("--gui",action="store_true",help="This is a GUI-only program. This option is provided for self-consistency",default=True)
parser.add_argument("--apix",type=float,help="Angstroms per pixel for all images",default=None, guitype='floatbox', row=3, col=0, rowspan=1, colspan=1, mode="eval['self.pm().getAPIX()']")
parser.add_argument("--constbfactor",type=float,help="Set B-factor to fixed specified value, negative value autofits",default=-1.0, guitype='floatbox', row=8, col=0, rowspan=1, colspan=1, mode='eval[-1.0]')
parser.add_argument("--voltage",type=float,help="Microscope voltage in KV",default=None, guitype='floatbox', row=3, col=1, rowspan=1, colspan=1, mode="eval['self.pm().getVoltage()']")
parser.add_argument("--cs",type=float,help="Microscope Cs (spherical aberation)",default=None, guitype='floatbox', row=4, col=0, rowspan=1, colspan=1, mode="eval['self.pm().getCS()']")
parser.add_argument("--ac",type=float,help="Amplitude contrast (percentage, default=10)",default=10, guitype='floatbox', row=4, col=1, rowspan=1, colspan=1, mode="eval")
parser.add_argument("--astigmatism",action="store_true",help="Includes astigmatism in automatic fitting",default=False, guitype='boolbox', row=8, col=1, rowspan=1, colspan=1, mode='eval')
parser.add_argument("--box",type=int,help="Forced box size in grid mode. Overrides any previous setting. ",default=-1, guitype='intbox', row=5, col=0, rowspan=1, colspan=1, mode="eval")
parser.add_argument("--usefoldername",action="store_true",help="If you have the same image filename in multiple folders, and need to import into the same project, this will prepend the folder name on each image name",default=False,guitype='boolbox',row=5, col=1, rowspan=1, colspan=1, mode="eval")
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()
logid=E2init(sys.argv,options.ppid)
from emapplication import EMApp
app=EMApp()
gui=GUIEvalImage(args,options.voltage,options.apix,options.cs,options.ac,options.box,options.usefoldername,options.constbfactor,options.astigmatism)
gui.show()
try:
gui.wimage.raise_()
gui.wfft.raise_()
gui.wplot.raise_()
gui.raise_()
except: pass
# try: gui.raise_()
# except: pass
app.execute()
E2end(logid)
示例12: display_validation_plots
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_()
示例13: main
def main():
progname = os.path.basename(sys.argv[0])
usage = """prog [options]
WARNING: This program still under development.
This program is used to interactively generate sequences of class-averages from sets of particles. It can be
used for many purposes, but is primarily intended at studies of macromolecular dynamics and variability. A stack
of particles ostensibly in the same 3-D (but not 2-D) orientation are read in, then alignment, classification
and averaging is performed to produce pseudo time-series animations detailing some aspect of the structure's
variability.
This program is NOT designed for use with stacks of tens of thousands of images. All images are kept in system
memory. All images are theoretically supposed to share a common overall orientation. That is, for a normal single
particle project, you would first subclassify the overall image stack used for 3-D using e2refine2d.py or
e2refine.py, then run this program only on a subset of particles.
If an existing project is specified with --path, previous results will be re-opened"""
parser = EMArgumentParser(usage=usage,version=EMANVERSION)
parser.add_argument("--path",type=str,default=None,help="Path for the refinement, default=auto")
parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-1)
global options
(options, args) = parser.parse_args()
if options.path==None:
options.path=numbered_path("motion",True)
# os.makedirs(options.path)
pid=E2init(argv)
app = EMApp()
motion=EMMotion(app,options.path)
motion.show()
app.execute()
E2end(pid)
示例14: main
def main():
progname = os.path.basename(sys.argv[0])
usage = progname + """ [options]
A tool for displaying EMAN2 command history
"""
parser = EMArgumentParser(usage=usage)
parser.add_argument("--gui", "-g",default=False, action="store_true",help="Open history in an interface with a sortable table.")
parser.add_argument("--all", "-a",default=False, action="store_true",help="Show for all directories.")
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()
if options.gui:
from emapplication import EMApp
app = EMApp()
hist = HistoryForm(app,os.getcwd())
app.show()
app.execute()
else: print_to_std_out(options.all)
示例15: main
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_()