def main(): usage = " " parser = EMArgumentParser(usage=usage, version=EMANVERSION) parser.add_argument("--label", type=str, help="Load previous contour segmentation.", default="tomobox") parser.add_argument("--gpuid", type=str, help="Specify the gpu to use", default="") parser.add_argument("--mult", type=float, help="multiply data by factor. useful for vpp data...", default=1) #parser.add_argument("--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID",default=-2) (options, args) = parser.parse_args() logid = E2init(sys.argv) app = EMApp() test = EMImage2DWidget() drawer = EMTomobox(app, options) drawer.show() app.execute() E2end(logid)
def main(): usage = " " parser = EMArgumentParser(usage=usage, version=EMANVERSION) #parser.add_argument("--path", type=str,help="path", default="het_3d") parser.add_argument("--noupdate", action="store_true", help="do not erase shapes", default=False) parser.add_argument("--fromedge", action="store_true", help="draw from edge", default=False) (options, args) = parser.parse_args() logid = E2init(sys.argv) img = EMData(args[0]) app = EMApp() drawer = EMDrawWindow(app, options, datafile=img) drawer.show() drawer.raise_() app.execute() E2end(logid)
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)
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() control.raise_() app.execute()
def main(): usage = "Electron Microscope simulation" parser = EMArgumentParser(usage=usage, version=EMANVERSION) parser.add_argument( "--mode", type=int, help= "operating mode. 0: imaging mode with all lens; 1:diffraction mode with all lens; 2: imaging mode with single lens and phase plate; else: imaging mode with one lens.", default=0) parser.add_argument("--cs", type=float, help="Cs of microscope.", default=0.0) parser.add_argument( "--twod", action="store_true", help= "Show twod image instead of 1D plot and beam propagation in the microscope.", default=False) (options, args) = parser.parse_args() logid = E2init(sys.argv) app = EMApp() # app=QtGui.QApplication([""]) window = MainWindow(options.mode, options.cs, options.twod) window.show() window.raise_() app.execute() E2end(logid)
def main(): usage = " " parser = EMArgumentParser(usage=usage, version=EMANVERSION) parser.add_pos_argument( name="tomogram", help="Specify the tomogram to be segmented.", default="", guitype='filebox', browser="EMTomoTable(withmodal=True,multiselect=False)", row=0, col=0, rowspan=1, colspan=2, mode="tomoseg") #parser.add_argument("--load", type=str,help="Load previous contour segmentation.", default=None, guitype='filebox', browser="EMBrowserWidget(withmodal=True,multiselect=False)", row=1, col=0,rowspan=1, colspan=2, mode="tomoseg") parser.add_argument("--nooptimize", action="store_true", help="do not optimize path", default=False) parser.add_argument( "--ppid", type=int, help="Set the PID of the parent process, used for cross platform PPID", default=-2) (options, args) = parser.parse_args() logid = E2init(sys.argv) app = EMApp() drawer = EMDrawWindow(app, options, datafile=args[0]) drawer.show() app.execute() E2end(logid)
def main(): # an application em_app = EMApp() control1 = TestControl(em_app) control2 = TestControl(em_app) em_app.execute()
def main(): usage = """This shows the alignment result from e2tomogram.py uing the information from a tomorecon_xx folder. Example: e2tomo_showali.py --path <tomorecon_xx> """ parser = EMArgumentParser(usage=usage, version=EMANVERSION) parser.add_argument( "--path", type=str, help="path to tomorecon_xx directory to examine fiducial error.", default="", guitype='filebox', browser="EMBrowserWidget(withmodal=True,multiselect=False)", row=0, col=0, rowspan=1, colspan=2, mode="fiderr") #parser.add_argument("--iteration", type=int,help="Refinement iteration number", default=2,guitype="intbox",row=1, col=0, rowspan=1, colspan=1,mode="fiderr") parser.add_argument("--ppid", type=int, help="ppid", default=-2) (options, args) = parser.parse_args() logid = E2init(sys.argv) app = EMApp() drawer = EMDrawWindow(app, options) drawer.show() app.execute() E2end(logid)
def main(): from eman2_gui.emapplication import EMApp em_app = EMApp() pref_task = EMPreferencesTask() pref_task.run_form() em_app.execute()
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()
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, read_from=args) em_app.show_specific(window) em_app.execute() E2end(logid)
def main(): global cur_data,data,imdisp # an application em_app = EMApp() widget=TestDisplay() widget.show() em_app.execute()
def main(): progname = os.path.basename(sys.argv[0]) usage = """prog [options] WARNING: This program still under development. This program is designed to work interactively with Gaussian mixture models, automating as much as possible of the tasks associated with studying dynamics using GMMs. It requires either a refine_XX folder or a set of particles with known orientations as a starting point.""" parser = EMArgumentParser(usage=usage, version=EMANVERSION) # parser.add_argument("--path",type=str,default=None,help="Path for the gmm_XX folder to work in, by default a new folder will be created") parser.add_argument( "--threads", default=-1, type=int, help= "Number of alignment threads to run in parallel on a single computer.") 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("gmm",True) # os.makedirs(options.path) if options.threads < 1: options.threads = num_cpus() #if not os.path.exists(options.path) : #os.mkdir(options.path) # parms=js_open_dict("{}/0_a2d_parms.json".format(options.path)) pid = E2init(argv) app = EMApp() emgmm = EMGMM(app, options) emgmm.show() emgmm.raise_() QtWidgets.QMessageBox.warning( None, "Warning", """This program is still experimental. While functional many capabilities of the underlying e2gmm_refine program are not yet available through this interface. Matching number of gaussians to resolution/volume is key in obtaining good distributions.""") app.execute() E2end(pid)
def main(): progname = os.path.basename(sys.argv[0]) usage = """%prog [options] <input ali> This program will allow the user to select a specific feature within a tomogram and track it, boxing out the feature from all slices. Generally best for uniform objects like vesicles.""" parser = OptionParser(usage=usage, version=EMANVERSION) parser.add_option("--prefix", type="string", help="Output file prefix", default=None) parser.add_option("--tiltstep", type="float", help="Step between tilts in degrees, default=2", default=2.0) parser.add_option("--maxshift", type="int", help="Maximum shift in autoalign, default=8", default=8) parser.add_option( "--seqali", action="store_true", default=False, help= "Average particles in previous slices for better alignments of near-spherical objects" ) parser.add_option("--invert", action="store_true", default=False, help="Inverts image data contrast on the fly") #parser.add_option("--boxsize","-B",type="int",help="Box size in pixels",default=64) #parser.add_option("--writeoutput",action="store_true",default=False,help="Uses coordinates stored in the tomoboxer database to write output") #parser.add_option("--stack",action="store_true",default=False,help="Causes the output images to be written to a stack") #parser.add_option("--force",action="store_true",default=False,help="Force overwrite output") #parser.add_option("--normproc", help="Normalization processor to apply to particle images. Should be normalize, normalize.edgemean or None", default="normalize.edgemean") #parser.add_option("--invertoutput",action="store_true",help="If writing output only, this will invert the pixel intensities of the boxed files",default=False) #parser.add_option("--dbls",type="string",help="data base list storage, used by the workflow. You can ignore this argument.",default=None) #parser.add_option("--outformat", help="Format of the output particles images, should be bdb,img, or hdf", default="bdb") (options, args) = parser.parse_args() logid = E2init(sys.argv) app = EMApp() track = TrackerControl(app, options.maxshift, options.invert, options.seqali, options.tiltstep) track.set_image(args[0]) app.execute() E2end(logid)
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], higher 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()
def main(): usage=""" !!! Experimental program.... Cleaned and modified version of e2spt_boxer.py. Allow multiple type of features in one tomogram and save metadata in the new EMAN2 tomogram framework. [prog] <tomogram> """ parser = EMArgumentParser(usage=usage,version=EMANVERSION) #parser.add_argument("--path", type=str,help="path", default=None) parser.add_pos_argument(name="tomogram",help="Specify a tomogram from which you want to extract particles.", default="", guitype='filebox', browser="EMTomoBoxesTable(withmodal=True,multiselect=False)", row=0, col=0,rowspan=1, colspan=2, mode="box3d,box2d") parser.add_argument("--box2d",action="store_true",help="Boxing 2D particls from tomograms.",default=False, guitype='boolbox', row=4, col=0, rowspan=1, colspan=1, mode='box2d[True]') parser.add_argument("--box3d",action="store_true",help="Boxing 3D particls from tomograms (default).",default=False, guitype='boolbox', row=4, col=0, rowspan=1, colspan=1, mode='box3d[True]') parser.add_header(name="instruction0", help='instruction', title="### Use '~' and '1' to go through slices along Z axis. ###", row=10, col=0, rowspan=1, colspan=2, mode="box3d,box2d") parser.add_header(name="instruction1", help='instruction', title="### Hold Shift to delete particles ###", row=11, col=0, rowspan=1, colspan=2, mode="box3d,box2d") #parser.add_argument("--mode", type=str,help="Boxing mode. choose from '2D' and '3D'. Default is '3D'", default="3D",guitype='combobox',choicelist="('2D', '3D')",row=1, col=0, rowspan=1, colspan=1,mode="boxing") parser.add_argument("--ppid", type=int,help="ppid", default=-2) (options, args) = parser.parse_args() logid=E2init(sys.argv) if len(args) == 0: print("INPUT ERROR: You must specify a tomogram.") sys.exit(1) if options.box2d==True and options.box3d==False: options.mode="2D" else: options.mode="3D" img = args[0] app = EMApp() img=args[0] imghdr = EMData(img,0,True) options.apix = imghdr['apix_x'] box = 32 boxer=EMTomoBoxer(app,options,datafile=img) boxer.show() app.execute() E2end(logid) return
def main(): progname = os.path.basename(sys.argv[0]) usage = """prog [options] WARNING: This program still under development. This program is designed to work interactively with Gaussian mixture models, automating as much as possible of the tasks associated with studying dynamics using GMMs. It requires either a refine_XX folder or a set of particles with known orientations as a starting point.""" parser = EMArgumentParser(usage=usage, version=EMANVERSION) # parser.add_argument("--path",type=str,default=None,help="Path for the gmm_XX folder to work in, by default a new folder will be created") parser.add_argument( "--threads", default=-1, type=int, help= "Number of alignment threads to run in parallel on a single computer. This is the only parallelism supported by e2spt_align at present." ) 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("gmm",True) # os.makedirs(options.path) if options.threads < 1: options.threads = num_cpus() #if not os.path.exists(options.path) : #os.mkdir(options.path) # parms=js_open_dict("{}/0_a2d_parms.json".format(options.path)) pid = E2init(argv) app = EMApp() emgmm = EMGMM(app, options) emgmm.show() emgmm.raise_() app.execute() E2end(pid)
def main(): progname = os.path.basename(sys.argv[0]) usage = """prog <simmx file> <projection file> <particles file> This program allows you to look at per-particle classification based on a pre-computed similarity matrix. If a particle seems to be mis-classified, you can use this program to help figure out why. It will display a single asymmetric triangle on the unit sphere, with cylinders representing the similarity value for the selected particle vs. each possible reference projection. Use the normal middle-click on the asymmetric unit viewer for more options. """ 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) 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) em_app = EMApp() window = EMSymViewerWidget() explorer = EMSimmxExplorer(window) window.model = explorer if len(args) > 0: explorer.set_simmx_file(args[0]) if len(args) > 1: explorer.set_projection_file(args[1]) if len(args) > 2: explorer.set_particle_file(args[2]) em_app.show() em_app.execute() E2end(logid)
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("--phaseplate",action="store_true",help="Include phase/amplitude contrast in CTF estimation. For use with hole-less phase plates.",default=False, guitype='boolbox', row=3, col=2, rowspan=1, colspan=1, mode='filter[False]') 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 eman2_gui.emapplication import EMApp app=EMApp() gui=GUIEvalImage(args,options.voltage,options.apix,options.cs,options.ac,options.box,options.usefoldername,options.constbfactor,options.astigmatism,options.phaseplate) 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)
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 eman2_gui.emapplication import EMApp app = EMApp() hist = HistoryForm(app, os.getcwd()) hist.form.show() hist.form.raise_() app.show() app.execute() else: print_to_std_out(options.all)
def main(): usage=" " parser = EMArgumentParser(usage=usage,version=EMANVERSION) parser.add_argument("--path", type=str,help="path", default=None) parser.add_argument("--loadali2d", type=str,help="previous 2d alignment", default=None) parser.add_argument("--loadali3d", type=str,help="previous 3d alignment", default=None) #parser.add_argument("--inplace", action="store_true", default=False ,help="overwrite input.") #parser.add_argument("--invert", action="store_true", default=False ,help="invert direction.") (options, args) = parser.parse_args() logid=E2init(sys.argv) app = EMApp() win=EMSptEval(app, options) win.show() app.execute() E2end(logid)
def main(): usage=" " parser = EMArgumentParser(usage=usage,version=EMANVERSION) parser.add_argument("--jsout", type=str,help="json output", default=None) parser.add_argument("--inplace", action="store_true", default=False ,help="overwrite input.") parser.add_argument("--invert", action="store_true", default=False ,help="invert direction.") parser.add_argument("--mode", type=str,help="choose from rad/line, default is line", default="line") parser.add_argument("--vec", type=str,help="vector direction, default 0,0,1", default="0,0,1") (options, args) = parser.parse_args() logid=E2init(sys.argv) app = EMApp() win=EMSptEval(app,args[0], options) win.show() app.execute() E2end(logid)
def main(): usage="""This shows the alignment result from e2tomogram.py uing the information from a tomorecon_xx folder. Example: e2tomo_showali.py --path <tomorecon_xx> --iteration <iteration number> """ parser = EMArgumentParser(usage=usage,version=EMANVERSION) parser.add_argument("--path", type=str,help="path to tomorecon_xx directory to examine fiducial error.", default="", guitype='filebox', browser="EMBrowserWidget(withmodal=True,multiselect=False)", row=0, col=0,rowspan=1, colspan=2, mode="fiderr") parser.add_argument("--iteration", type=int,help="Refinement iteration number", default=2,guitype="intbox",row=1, col=0, rowspan=1, colspan=1,mode="fiderr") parser.add_argument("--ppid", type=int,help="ppid", default=-2) (options, args) = parser.parse_args() logid=E2init(sys.argv) fname=os.path.join(options.path, "ali_{:02d}.hdf".format(options.iteration)) pname=os.path.join(options.path, "landmarks_{:02d}.txt".format(options.iteration)) pks=np.loadtxt(pname) imgs = EMData.read_images(fname) img=EMData(imgs[0]["nx"],imgs[0]["ny"], len(imgs)) xfs=[] for i,m in enumerate(imgs): img.insert_clip(m, (0,0,i)) xfs.append(m["xform.projection"]) aname=os.path.join(options.path, "ptclali_{:02d}.hdf".format(options.iteration)) n=EMUtil.get_image_count(aname) dirs=np.zeros((len(imgs),len(pks),2)) for i in range(n): e=EMData(aname, i, True) s=e["score"] dirs[e["nid"], e["pid"]]=[s[1], -s[0]] print(dirs) app = EMApp() drawer=EMDrawWindow(app,options,img, pks, xfs, dirs) drawer.show() app.execute() E2end(logid)
def main(): usage = " " parser = EMArgumentParser(usage=usage, version=EMANVERSION) parser.add_argument("--midinput", type=str, help="middle layer input", default=None) parser.add_argument("--decoder", type=str, help="decoder input", default=None) (options, args) = parser.parse_args() logid = E2init(sys.argv) app = EMApp() win = EMSptEval(app, options) win.show() app.execute() E2end(logid)
def main(): usage = """ Visualize particle motion in individual tilts. After a refinement with the new spt protocol, run e2spt_evalsubtlt.py --path spt_xx --loadali2d spt_xx/aliptcls2d_yy.lst --loadali3d spt_xx/aliptcls3d_zz.lst It will take a while to load all metadata, and plot the trajectory of each particle on each tilt image in each tomogram. In the top panel, the blue curve represents the average score of all 2D particles in that tilt, and the red curve represents the average distance of the subtilt motion with respect to the alignment of the 3D particle. The quiver plot below shows the trajectory of each individual particle, colored by its alignment score. """ parser = EMArgumentParser(usage=usage, version=EMANVERSION) parser.add_argument("--path", type=str, help="path", default=None) parser.add_argument("--loadali2d", type=str, help="previous 2d alignment", default=None) parser.add_argument("--loadali3d", type=str, help="previous 3d alignment", default=None) parser.add_argument("--submean", action="store_true", default=False, help="substract mean movement of the vector field") parser.add_argument("--defocus", action="store_true", default=False, help="plot defocus refinement result") (options, args) = parser.parse_args() logid = E2init(sys.argv) app = EMApp() win = EMSptEval(app, options) win.show() app.execute() E2end(logid)
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], higher \ 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 = [EMDataItem3D(pdb_file=pdbf) for pdbf in options.pdbfiles] viewer.addChildren(models) viewer.show() app.execute() E2end(logid)
def main(): usage = """prog --path <spt_xx> --iter <X> --tomo <tomogram> map aligned particles back to tomograms """ parser = EMArgumentParser(usage=usage, version=EMANVERSION) parser.add_argument("--path", type=str, help="spt_xx path", default="", guitype='strbox', row=0, col=0, rowspan=1, colspan=1) parser.add_argument("--iter", type=int, help="iteration number", default=1, guitype='intbox', row=0, col=1, rowspan=1, colspan=1) parser.add_argument( "--tomo", type=str, help="tomogram file name", default="", guitype='filebox', browser="EMBrowserWidget(withmodal=True, startpath='tomograms')", row=2, col=0, rowspan=1, colspan=2, ) parser.add_argument( "--avg", type=str, help="3D volume to insert. spt_xx/threed_xx if unspecified", default="", guitype='filebox', browser="EMBrowserWidget(withmodal=True, startpath='.')", row=3, col=0, rowspan=1, colspan=2) parser.add_argument("--postxf", type=str, help="extra shift after alignment", default="") parser.add_argument( "--keep", type=float, help= "propotion to keep. will exclude bad particles if this is smaller than 1.0", default=1.0) parser.add_argument( "--gui", action="store_true", help="open the resulting map and tomogram in a GUI display", default=False, guitype="boolbox", row=4, col=0, rowspan=1, colspan=1) parser.add_argument("--ppid", type=int, help="ppid...", default=-1) (options, args) = parser.parse_args() logid = E2init(sys.argv) path = options.path itr = options.iter try: postxf = options.postxf.split(',') postxf = [float(i) for i in postxf] print("post shift : ", postxf) except: postxf = [0, 0, 0] js = js_open_dict("{}/particle_parms_{:02d}.json".format(path, itr)) tomo = EMData(options.tomo) if options.gui: tomo_orig = tomo.copy() if len(options.avg) == 0: options.avg = "{}/threed_{:02d}.hdf".format(path, itr) avg = EMData(options.avg, 0) print("Using averaged map {}".format(options.avg)) apix_tomo = tomo["apix_x"] apix_ptcl = avg["apix_x"] shrink = apix_tomo / apix_ptcl print( "Apix from tomogram {:.2f}, apix from average {:.2f}. Shrinking factor {:.1f}" .format(apix_tomo, apix_ptcl, shrink)) avg.process_inplace("math.fft.resample", {"n": shrink}) avg.process_inplace("normalize.edgemean") tomo.to_zero() ptcl = [] scr = [] llfile = "" bname = base_name(options.tomo) for k in js.keys(): fsp, i = eval(k) if fsp[-4:] == ".lst": if llfile != fsp: llfile = fsp lsx = LSXFile(fsp, True) i, fsp, x = lsx.read(i) if base_name(fsp) == bname: ptcl.append((js[k]["score"], fsp, i, js[k]["xform.align3d"])) ptcl.sort() print(ptcl) nptcl = int(len(ptcl) * options.keep) if options.keep < 1.0: sthr = ptcl[nptcl][0] else: sthr = 100 pts = [] print("{:d} particles total.".format(int(nptcl))) if nptcl == 0: print("No particles. Exiting") sys.exit(0) for s, fsp, i, xf in ptcl: if s > sthr: continue a = EMData(fsp, i, True) if tomo.has_attr("zshift"): zs = tomo["zshift"] else: zs = 0 crd = np.array(a["ptcl_source_coord"]) / shrink + [ tomo["nx"] // 2, tomo["ny"] // 2, tomo["nz"] // 2 + zs / shrink ] ts = np.array(xf.get_trans()) ts += postxf xf.set_trans((ts / shrink).tolist()) xf = xf.inverse() t = avg.process("xform", {"transform": xf}) pts.append(crd - ts / 4) tomo.insert_scaled_sum(t, crd.tolist()) print("\t{}/{} finished.".format(len(pts), nptcl), end='\r') sys.stdout.flush() pts = np.array(pts) pfile = "{}/ptcls_pos_{:02d}.pdb".format(path, itr) tfile = "{}/ptcls_in_tomo_{}_{:02d}.hdf".format(path, bname, itr) tomo.write_compressed(tfile, 0, 8) numpy2pdb(fname=pfile, data=pts) print("Map {} particles to the tomogram".format(len(pts))) print("Particle coordinates written to {}".format(pfile)) print("Map with particles written to {}".format(tfile)) js = None E2end(logid) if options.gui: print("opening GUI") from eman2_gui.emapplication import get_application, EMApp from eman2_gui.emscene3d import EMScene3D from eman2_gui.emdataitem3d import EMDataItem3D, EMIsosurface, EMSliceItem3D from eman2_gui.emshape import EMShape app = EMApp() view = EMScene3D() # slice through the original tomogram tomo_orig_di = EMDataItem3D(tomo_orig, transform=Transform()) view.insertNewNode('Data', tomo_orig_di, parentnode=view) volslice = EMSliceItem3D(tomo_orig_di, transform=Transform()) view.insertNewNode("Slice", volslice, parentnode=tomo_orig_di) # isosurface of reconstituted particles tomo_di = EMDataItem3D(tomo, transform=Transform()) view.insertNewNode('Data', tomo_di, parentnode=view) isosurface = EMIsosurface(tomo_di, transform=Transform()) view.insertNewNode("Iso", isosurface, parentnode=tomo_di) view.show() try: view.raise_() except: pass app.execute() print("Done.")
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("--threads", default=0,type=int,help="Number of alignment threads to run in parallel on a single computer. This is the only parallelism supported by e2spt_align at present.") parser.add_argument("--path",type=str,default=None,help="Path for the refinement, default=auto") parser.add_argument("--iter",type=int,help="Iteration number within path. Default = start a new iteration",default=0) 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("m2d",True) # os.makedirs(options.path) if options.threads<1 : options.threads=num_cpus() if options.path==None: fls=[int(i[-2:]) for i in os.listdir(".") if i[:4]=="m2d_" and len(i)==6 and str.isdigit(i[-2:])] if len(fls)==0 : fls=[1] options.path = "m2d_{:02d}".format(max(fls)) if options.verbose : print("Using --path ",options.path) if not os.path.exists(options.path) : os.mkdir(options.path) if itr==0 : itr=1 parms=js_open_dict("{}/0_a2d_parms.json".format(options.path)) if options.iter not in parms : try: options.iter=max([int(i) for i in parms.keys()]) except: options.iter=0 print("Iteration: ",options.iter) pid=E2init(argv) app = EMApp() motion=EMMotion(app,options.path,options.iter,options.threads) motion.show() motion.raise_() app.execute() E2end(pid)
g4a = subplot(311) g4a.clear() g4a.hist(s1,50, histtype='bar') g4a.scatter(s1[:1],blank[:1],color="red") g4a.set_xlabel("Real space correlation") g4b = subplot(312) g4b.clear() g4b.hist(s2,50, histtype='bar') g4b.scatter(s2[:1], blank[:1],color="red") g4b.set_xlabel("Atom Inclusion Percentage") g4c = subplot(313) g4c.clear() g4c.hist(s3,50, histtype='bar') g4c.scatter(s3[:1], blank[:1],color="red") g4c.set_xlabel("Volume inclusion") show() ################################################# if __name__ == '__main__': from eman2_gui.emapplication import EMApp em_app = EMApp() window = E2ValidateMed() window.start() #em_app.show() em_app.execute()
def main(): progname = os.path.basename(sys.argv[0]) usage = """prog [options] <untilted micrograph> <tilted micrograph>.... This is a tilted - untilted particle particle picker, for use in RCT particle picking. A tilted and untilted micrograph are loaded and the user picks a untilted particle and a corresponding tilted particle. After atleast 3 particle pairs are picked a transformation matrix is completed which can be used to predict the postion of the tilted or untilted particle from a untilted or tilted particle respectily. From the transform matrix, the tilt angle, tilit axis(with respect to Y) and the gamma angle are all computed. The program uses the mediator pattern. The mediator, a RCTboxer object HAS A strategy(itself a strategy pattern), HAS A set of windows(in this case 2, but more can be added), HAS A control pannel, and HAS a particle list. The strategy object implements the strategy pattern(currently a maunal and a pair picker strategy are implemented). This code is in 'emrctstrategy'. The control pannel object HAS A strategy widget(so there must be one widget for each strategy) and the strategy GUI widget and the strategy itself are tightly coupled. The window object each HAS A EMBoxList, which is a composite of EMBox objects. (A class diagram is located in my lab notebook, page16) Usage: e2RCTboxer.py untilted.hdf tilted.hdf options. """ parser = EMArgumentParser(usage=usage, version=EMANVERSION) parser.add_pos_argument( name="untilted micrograph", help="List the untilted micrograph here.", default="", guitype='filebox', browser="EMRCTBoxesTable(withmodal=True,multiselect=False)", row=0, col=0, rowspan=1, colspan=3, mode="boxing,extraction") parser.add_pos_argument( name="tilted micrograph", help="List the tilted micrograph here.", default="", guitype='filebox', browser="EMRCTBoxesTable(withmodal=True,multiselect=False)", row=1, col=0, rowspan=1, colspan=3, mode="boxing,extraction") parser.add_header( name="RCTboxerheader", help='Options below this label are specific to e2RCTboxer', title="### e2RCTboxer options ###", row=2, col=0, rowspan=1, colspan=3, mode="boxing,extraction") 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="boxing,extraction") parser.add_argument("--write_boxes", action="store_true", help="Write coordinate file (eman1 dbbox) files", default=False, guitype='boolbox', row=4, col=0, rowspan=1, colspan=1, mode="extraction") parser.add_argument("--write_ptcls", action="store_true", help="Write particles to disk", default=False, guitype='boolbox', row=4, col=1, rowspan=1, colspan=1, mode="extraction[True]") parser.add_argument( "--format", help="Format of the output particles images, should be hdf", default="hdf", guitype='combobox', choicelist="['hdf']", row=7, col=0, rowspan=1, colspan=2, mode="extraction") parser.add_argument( "--shrink", type=int, help="Shrink the images by an integer, uses math.meanshrink", default=0, guitype='shrinkbox', row=6, col=2, rowspan=1, colspan=1, mode="extraction") parser.add_argument( "--norm", type=str, help= "Normalization processor to apply to written particle images. Should be normalize, normalize.edgemean,etc.Specifc \"None\" to turn this off", default="normalize.edgemean", guitype='combobox', choicelist='re_filter_list(dump_processors_list(),\'normalize\')', row=6, col=0, rowspan=1, colspan=2, mode="extraction") parser.add_argument("--invert", action="store_true", help="If writing outputt inverts pixel intensities", default=False, guitype='boolbox', row=4, col=2, rowspan=1, colspan=1, mode="extraction") parser.add_argument( "--suffix", type=str, help= "suffix which is appended to the names of output particle and coordinate files", default="_ptcls", guitype='strbox', expert=True, row=5, col=1, rowspan=1, colspan=2, mode="extraction") 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 need to be accessible, anywhere (options, args) = parser.parse_args() logid = E2init(sys.argv, options.ppid) # The RCT DB needs to be accessible, anywhere rctdb = js_open_dict(EMBOXERRCT_DB) # Get and set the boxsize cache_box_size = True if options.boxsize == -1: cache_box_size = False options.boxsize = rctdb.get("box_size", dfl=128) if cache_box_size: rctdb["box_size"] = options.boxsize if len(args) != 2: print( "You need to supply both untiled and tilted micrographs.\nUsage: e2RCTboxer.py [options] <untilted micrograph> <tilted micrograph>" ) sys.exit(1) if options.write_boxes or options.write_ptcls: # Just write output and don't move to GUI mode rctproc = RCTprocessor(args, options) if options.write_ptcls: rctproc.write_particles() if options.write_boxes: rctproc.write_boxes() else: # Open Application, setup rct object, and run application = EMApp() rctboxer = RCTboxer(application, options.boxsize) # Initialize the boxertools rctboxer.load_untilt_image(args[0]) # Load the untilted image rctboxer.load_tilt_image(args[1]) # Load the tilted image rctboxer.init_control_pannel() rctboxer.init_control_pannel_tools( ) # Initialize control panel tools, this needs to be done last as loaded data maybe be used application.execute() # Clean up E2end(logid) js_close_dict(EMBOXERRCT_DB)