def object_picked(self, object_number): if object_number == self.current_projection: return self.current_projection = object_number resize_necessary = False if self.mx_display == None: self.mx_display = EMImage2DWidget() # self.mx_display = EMImageMXWidget() QtCore.QObject.connect(self.mx_display, QtCore.SIGNAL("module_closed"), self.on_mx_display_closed) resize_necessary = True if self.frc_display == None: self.frc_display = EMPlot2DWidget() # QtCore.QObject.connect(self.frc_display,QtCore.SIGNAL("module_closed"),self.on_frc_display_closed) self.update_display(False) if resize_necessary: get_application().show_specific(self.mx_display) self.mx_display.optimally_resize() get_application().show_specific(self.frc_display) # self.frc_display.optimally_resize() else: self.mx_display.updateGL() self.frc_display.updateGL() if object_number != self.special_euler: self.special_euler = object_number self.regen_dl()
def plot(files, app): from emplot2d import EMPlot2DWidget plotw = EMPlot2DWidget(application=app) for f in files: plotw.set_data_from_file(f, quiet=True) plotw.setWindowTitle("2D Plot") app.show_specific(plotw) return plotw
def __init__(self, mode=0, cs=0., twod=False): QtGui.QMainWindow.__init__(self) if twod: self.twodview = EMImage2DWidget() widget = Microscope(self, None, None, self.twodview, mode, cs) else: self.imgview = EMImage2DWidget() self.pltview = EMPlot2DWidget() widget = Microscope(self, self.imgview, self.pltview, None, mode, cs) #widget = Microscope(self, None, None, None, mode, cs) #widget = Microscope(self, None, None) self.closeEvent = widget.closeEvent self.setCentralWidget(widget)
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_()
def __init__(self, application, apix=1.0, voltage=300.0, cs=4.1, ac=10.0, samples=256): """CTF simulation dialog """ try: from emimage2d import EMImage2DWidget except: print "Cannot import EMAN image GUI objects (EMImage2DWidget)" sys.exit(1) try: from emplot2d import EMPlot2DWidget except: print "Cannot import EMAN plot GUI objects (is matplotlib installed?)" sys.exit(1) self.app = weakref.ref(application) self.df_voltage = voltage self.df_apix = apix self.df_cs = cs self.df_ac = ac self.df_samples = samples self.img = None QtGui.QWidget.__init__(self, None) self.setWindowIcon(QtGui.QIcon(get_image_directory() + "ctf.png")) self.data = [] self.curset = 0 self.plotmode = 0 self.guiim = EMImage2DWidget(application=self.app()) self.guiiminit = True # a flag that's used to auto resize the first time the gui's set_data function is called self.guiplot = EMPlot2DWidget(application=self.app()) # self.guirealim=EMImage2DWidget(application=self.app()) # This will show the original particle images # self.guirealim.connect(self.guirealim,QtCore.SIGNAL("keypress"),self.realimgkey) self.guiim.connect(self.guiim, QtCore.SIGNAL("mousedown"), self.imgmousedown) self.guiim.connect(self.guiim, QtCore.SIGNAL("mousedrag"), self.imgmousedrag) self.guiim.connect(self.guiim, QtCore.SIGNAL("mouseup"), self.imgmouseup) self.guiplot.connect(self.guiplot, QtCore.SIGNAL("mousedown"), self.plotmousedown) self.guiim.mmode = "app" # This object is itself a widget we need to set up self.hbl = QtGui.QHBoxLayout(self) self.hbl.setMargin(0) self.hbl.setSpacing(6) self.hbl.setObjectName("hbl") # plot list and plot mode combobox self.vbl2 = QtGui.QVBoxLayout() self.setlist = MyListWidget(self) self.setlist.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) self.vbl2.addWidget(self.setlist) self.splotmode = QtGui.QComboBox(self) self.splotmode.addItem("Amplitude") self.splotmode.addItem("Intensity") self.splotmode.addItem("Int w sum") self.splotmode.addItem("Amp w sum") self.vbl2.addWidget(self.splotmode) self.hbl.addLayout(self.vbl2) # ValSliders for CTF parameters self.vbl = QtGui.QVBoxLayout() self.vbl.setMargin(0) self.vbl.setSpacing(6) self.vbl.setObjectName("vbl") self.hbl.addLayout(self.vbl) #self.samp = ValSlider(self,(0,5.0),"Amp:",0) #self.vbl.addWidget(self.samp) self.imginfo = QtGui.QLabel("Info", self) self.vbl.addWidget(self.imginfo) self.sdefocus = ValSlider(self, (0, 5), "Defocus:", 0, 90) self.vbl.addWidget(self.sdefocus) self.sbfactor = ValSlider(self, (0, 1600), "B factor:", 0, 90) self.vbl.addWidget(self.sbfactor) self.sdfdiff = ValSlider(self, (0, 1), "DF Diff:", 0, 90) self.vbl.addWidget(self.sdfdiff) self.sdfang = ValSlider(self, (0, 180), "Df Angle:", 0, 90) self.vbl.addWidget(self.sdfang) self.sampcont = ValSlider(self, (0, 100), "% AC", 0, 90) self.vbl.addWidget(self.sampcont) self.sapix = ValSlider(self, (.2, 10), "A/Pix:", 2, 90) self.vbl.addWidget(self.sapix) self.svoltage = ValSlider(self, (0, 1000), "Voltage (kV):", 0, 90) self.vbl.addWidget(self.svoltage) self.scs = ValSlider(self, (0, 5), "Cs (mm):", 0, 90) self.vbl.addWidget(self.scs) self.ssamples = ValSlider(self, (32, 1024), "# Samples:", 0, 90) self.ssamples.setIntonly(True) self.vbl.addWidget(self.ssamples) self.hbl_buttons = QtGui.QHBoxLayout() self.newbut = QtGui.QPushButton("New") self.hbl_buttons.addWidget(self.newbut) self.vbl.addLayout(self.hbl_buttons) self.on_new_but() QtCore.QObject.connect(self.sdefocus, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sbfactor, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sdfdiff, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sdfang, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sapix, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sampcont, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.svoltage, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.scs, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.ssamples, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.setlist, QtCore.SIGNAL("currentRowChanged(int)"), self.newSet) QtCore.QObject.connect(self.setlist, QtCore.SIGNAL("keypress"), self.listkey) QtCore.QObject.connect(self.splotmode, QtCore.SIGNAL("currentIndexChanged(int)"), self.newPlotMode) QtCore.QObject.connect(self.newbut, QtCore.SIGNAL("clicked(bool)"), self.on_new_but) self.resize( 720, 380 ) # figured these values out by printing the width and height in resize event E2loadappwin("e2ctfsim", "main", self) E2loadappwin("e2ctfsim", "image", self.guiim.qt_parent) # E2loadappwin("e2ctf","realimage",self.guirealim.qt_parent) E2loadappwin("e2ctfsim", "plot", self.guiplot.qt_parent) self.setWindowTitle("CTF")
def __init__(self, application, data): """Implements the CTF fitting dialog using various EMImage and EMPlot2D widgets 'data' is a list of (filename,ctf,im_1d,bg_1d,im_2d,bg_2d) """ try: from emimage2d import EMImage2DWidget except: print "Cannot import EMAN image GUI objects (EMImage2DWidget)" sys.exit(1) try: from emplot2d import EMPlot2DWidget except: print "Cannot import EMAN plot GUI objects (is matplotlib installed?)" sys.exit(1) self.app = weakref.ref(application) QtGui.QWidget.__init__(self, None) self.setWindowIcon(QtGui.QIcon(get_image_directory() + "ctf.png")) self.data = data self.curset = 0 self.plotmode = 0 self.guiim = EMImage2DWidget(application=self.app()) self.guiplot = EMPlot2DWidget(application=self.app()) self.guiim.connect(self.guiim, QtCore.SIGNAL("mousedown"), self.imgmousedown) self.guiim.connect(self.guiim, QtCore.SIGNAL("mousedrag"), self.imgmousedrag) self.guiim.connect(self.guiim, QtCore.SIGNAL("mouseup"), self.imgmouseup) self.guiplot.connect(self.guiplot, QtCore.SIGNAL("mousedown"), self.plotmousedown) self.guiim.mmode = "app" # This object is itself a widget we need to set up self.hbl = QtGui.QHBoxLayout(self) self.hbl.setMargin(0) self.hbl.setSpacing(6) self.hbl.setObjectName("hbl") # plot list and plot mode combobox self.vbl2 = QtGui.QVBoxLayout() self.setlist = QtGui.QListWidget(self) self.setlist.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) self.vbl2.addWidget(self.setlist) self.splotmode = QtGui.QComboBox(self) self.splotmode.addItem("Bgsub & fit") self.splotmode.addItem("Ptcl & BG power") self.splotmode.addItem("SNR") self.splotmode.addItem("Smoothed SNR") self.splotmode.addItem("Integrated SNR") self.splotmode.addItem("Total CTF") self.vbl2.addWidget(self.splotmode) self.hbl.addLayout(self.vbl2) # ValSliders for CTF parameters self.vbl = QtGui.QVBoxLayout() self.vbl.setMargin(0) self.vbl.setSpacing(6) self.vbl.setObjectName("vbl") self.hbl.addLayout(self.vbl) #self.samp = ValSlider(self,(0,5.0),"Amp:",0) #self.vbl.addWidget(self.samp) self.sdefocus = ValSlider(self, (0, 5), "Defocus:", 0, 90) self.vbl.addWidget(self.sdefocus) self.sbfactor = ValSlider(self, (0, 1600), "B factor:", 0, 90) self.vbl.addWidget(self.sbfactor) self.sampcont = ValSlider(self, (0, 100), "% AC", 0, 90) self.vbl.addWidget(self.sampcont) # self.sapix=ValSlider(self,(.2,10),"A/Pix:",2,90) # self.vbl.addWidget(self.sapix) self.svoltage = ValSlider(self, (0, 500), "Voltage (kV):", 0, 90) self.vbl.addWidget(self.svoltage) self.scs = ValSlider(self, (0, 5), "Cs (mm):", 0, 90) self.vbl.addWidget(self.scs) self.hbl_buttons = QtGui.QHBoxLayout() self.saveparms = QtGui.QPushButton("Save parms") self.recallparms = QtGui.QPushButton("Recall") self.output = QtGui.QPushButton("Output") self.hbl_buttons.addWidget(self.saveparms) self.hbl_buttons.addWidget(self.recallparms) self.hbl_buttons2 = QtGui.QHBoxLayout() self.hbl_buttons2.addWidget(self.output) self.vbl.addLayout(self.hbl_buttons) self.vbl.addLayout(self.hbl_buttons2) QtCore.QObject.connect(self.sdefocus, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sbfactor, QtCore.SIGNAL("valueChanged"), self.newCTF) # QtCore.QObject.connect(self.sapix, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sampcont, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.svoltage, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.scs, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.setlist, QtCore.SIGNAL("currentRowChanged(int)"), self.newSet) QtCore.QObject.connect(self.splotmode, QtCore.SIGNAL("currentIndexChanged(int)"), self.newPlotMode) QtCore.QObject.connect(self.saveparms, QtCore.SIGNAL("clicked(bool)"), self.on_save_params) QtCore.QObject.connect(self.recallparms, QtCore.SIGNAL("clicked(bool)"), self.on_recall_params) QtCore.QObject.connect(self.output, QtCore.SIGNAL("clicked(bool)"), self.on_output) self.update_data() self.update_data() self.resize( 460, 380 ) # figured these values out by printing the width and height in resize event self.setWindowTitle("CTF")
def menu_add_plotwin(self): if self.viewer == None: return self.viewer.append(EMPlot2DWidget()) self.viewer[-1].show() self.needupdate = 1
def __init__(self,images,voltage=None,apix=None,cs=None,ac=10.0,box=512,usefoldername=False,constbfactor=-1,fitastig=False): """Implements the CTF fitting dialog using various EMImage and EMPlot2D widgets 'data' is a list of (filename,ctf,im_1d,bg_1d,quality) 'parms' is [box size,ctf,box coord,set of excluded boxnums,quality,oversampling] """ try: from emimage2d import EMImage2DWidget except: print "Cannot import EMAN image GUI objects (EMImage2DWidget)" sys.exit(1) try: from emplot2d import EMPlot2DWidget except: print "Cannot import EMAN plot GUI objects (is matplotlib installed?)" sys.exit(1) QtGui.QWidget.__init__(self,None) self.setWindowIcon(QtGui.QIcon(get_image_directory() + "ctf.png")) self.fitastig=fitastig self.nodir=not usefoldername self.data=None self.curset=0 self.calcmode=1 self.f2dmode=0 self.f2danmode=0 self.plotmode=0 self.curfilename = None self.ringrad=1 self.xpos1=(10,0) self.xpos2=(0,10) # self.db = db_open_dict('bdb:mgquality') self.defaultvoltage=voltage self.defaultapix=apix self.defaultcs=cs self.defaultac=ac self.constbfactor=constbfactor # Per image parameters to keep track of # for each image [box size,ctf,box coord,set of excluded boxnums,quality,oversampling] self.parms=[] # db_fparms=db_open_dict("bdb:e2ctf.frameparms",True) # This little block of code deals with Z stacks of images and multiple image files, # rewriting the name(s) with an enumeration including ;number or ,number newimages=[] for i in images: n=EMUtil.get_image_count(i) if n!=1: for j in xrange(n): newimages.append(i+",%d"%j) else: h=EMData(i,0,True) # read header n=h["nz"] if n!=1: for j in xrange(n): newimages.append(i+";%d"%j) else : newimages.append(i) images=newimages # Now we try to restore old image information for i in images: try: pd=js_open_dict(info_name(i,nodir=self.nodir)) parms=pd["ctf_frame"] parms[4]=pd["quality"] if box>=64 and parms[0]!=box: parms[0]=box parms[3]=set() # if parms==None : raise Exception except: ctf = EMAN2Ctf() ctf.from_dict({'defocus':0.0,'dfdiff':0.0,'dfang':0.0,'bfactor':200.0,'ampcont':self.defaultac,'voltage':200.0,'cs':4.1,'apix':1.0,'dsbg':-1}) if self.defaultvoltage!=None : ctf.voltage=self.defaultvoltage if self.defaultcs!=None : ctf.cs=self.defaultcs if self.defaultapix!=None : ctf.apix=self.defaultapix parms=[int(box),ctf,(256,256),set(),5,1] print "Initialize new parms for: ",base_name(i) if self.constbfactor>0 : parms[1].bfactor=self.constbfactor if parms[0]<64 : parms[0]=512 parms[3]=set() self.parms.append(parms) self.wimage=EMImage2DWidget() self.wimage.setWindowTitle("e2evalimage - Micrograph") self.wfft=EMImage2DWidget() self.wfft.setWindowTitle("e2evalimage - 2D FFT") self.wplot=EMPlot2DWidget() self.wplot.setWindowTitle("e2evalimage - Plot") self.wimage.connect(self.wimage,QtCore.SIGNAL("mousedown"),self.imgmousedown) self.wimage.connect(self.wimage,QtCore.SIGNAL("mousedrag"),self.imgmousedrag) self.wimage.connect(self.wimage,QtCore.SIGNAL("mouseup") ,self.imgmouseup) self.wfft.connect(self.wfft,QtCore.SIGNAL("mousedown"),self.fftmousedown) self.wfft.connect(self.wfft,QtCore.SIGNAL("mousedrag"),self.fftmousedrag) self.wfft.connect(self.wfft,QtCore.SIGNAL("mouseup") ,self.fftmouseup) self.wplot.connect(self.wplot,QtCore.SIGNAL("mousedown"),self.plotmousedown) self.wimage.mmode="app" self.wfft.mmode="app" # This object is itself a widget we need to set up self.gbl = QtGui.QGridLayout(self) self.gbl.setMargin(8) self.gbl.setSpacing(6) # plot list and plot mode combobox self.setlist=e2ctf.MyListWidget(self) self.setlist.setSizePolicy(QtGui.QSizePolicy.Preferred,QtGui.QSizePolicy.Expanding) for i in images: self.setlist.addItem(i) self.gbl.addWidget(self.setlist,0,0,10,2) self.lcalcmode=QtGui.QLabel("Region:",self) self.gbl.addWidget(self.lcalcmode,10,0) self.scalcmode=QtGui.QComboBox(self) self.scalcmode.addItem("Single Region") self.scalcmode.addItem("Tiled Boxes") self.scalcmode.setCurrentIndex(1) self.gbl.addWidget(self.scalcmode,10,1) self.lcalcmode=QtGui.QLabel("2D FFT:",self) self.gbl.addWidget(self.lcalcmode,11,0) self.s2dmode=QtGui.QComboBox(self) self.s2dmode.addItem("Power Spectrum") self.s2dmode.addItem("Bg Subtracted") self.s2dmode.addItem("Background") self.gbl.addWidget(self.s2dmode,11,1) self.lcalcmode=QtGui.QLabel("Annotate:",self) self.gbl.addWidget(self.lcalcmode,12,0) self.s2danmode=QtGui.QComboBox(self) self.s2danmode.addItem("Ctf Zeroes") self.s2danmode.addItem("Resolution Ring") self.s2danmode.addItem("2-D Xtal") self.s2danmode.addItem("None") self.gbl.addWidget(self.s2danmode,12,1) self.lcalcmode=QtGui.QLabel("Plot:",self) self.gbl.addWidget(self.lcalcmode,13,0) self.splotmode=QtGui.QComboBox(self) self.splotmode.addItem("Bgsub and Fit") self.splotmode.addItem("Fg and Bg") self.splotmode.addItem("Bgsub, 45 deg slices") self.splotmode.addItem("Fg, 45 deg slices") self.splotmode.addItem("SSNR (NOT BY PTCL !)") self.gbl.addWidget(self.splotmode,13,1) # ValSliders for CTF parameters #self.samp = ValSlider(self,(0,5.0),"Amp:",0) #self.vbl.addWidget(self.samp) self.sdefocus=ValSlider(self,(0,5),"Defocus:",0.0,90) self.gbl.addWidget(self.sdefocus,0,2,1,3) self.sbfactor=ValSlider(self,(0,1600),"B factor:",200.0,90) self.gbl.addWidget(self.sbfactor,1,2,1,3) self.sdfdiff=ValSlider(self,(0,1),"DF Diff:",0,90) self.gbl.addWidget(self.sdfdiff,2,2,1,3) self.sdfang=ValSlider(self,(0,180),"Df Angle:",0,90) self.gbl.addWidget(self.sdfang,3,2,1,3) self.sampcont=ValSlider(self,(0,100),"% AC",10.0,90) if self.defaultac!=None : self.sampcont.setValue(self.defaultac) self.gbl.addWidget(self.sampcont,4,2,1,3) self.sang45=ValSlider(self,(-22.5,22.5),"45 mode ang",0.0,90) self.gbl.addWidget(self.sang45,5,2,1,3) self.squality=ValSlider(self,(0,9),"Quality (0-9):",0,90) self.squality.setIntonly(True) self.gbl.addWidget(self.squality,6,2,1,3) self.brefit=QtGui.QPushButton("Refit") self.gbl.addWidget(self.brefit,7,2) self.cbgadj=CheckBox(None,"CTF BG Adj",1) self.gbl.addWidget(self.cbgadj,7,3) # self.sapix=ValSlider(self,(.2,10),"A/Pix:",2,90) # self.vbl.addWidget(self.sapix) self.sapix=ValBox(self,(0,500),"A/pix:",1.0,90) if self.defaultapix!=None : self.sapix.setValue(self.defaultapix) self.gbl.addWidget(self.sapix,10,2) self.svoltage=ValBox(self,(0,500),"Voltage (kV):",200,90) if self.defaultvoltage!=None : self.svoltage.setValue(self.defaultvoltage) self.gbl.addWidget(self.svoltage,11,2) self.scs=ValBox(self,(0,5),"Cs (mm):",4.1,90) if self.defaultcs!=None : self.scs.setValue(self.defaultcs) self.gbl.addWidget(self.scs,12,2) self.sboxsize=ValBox(self,(128,1024),"Box Size:",512,90) self.sboxsize.intonly=True self.gbl.addWidget(self.sboxsize,13,2) # self.soversamp=ValBox(self,(0,500),"Oversample:",1,90) # self.soversamp.intonly=True # self.gbl.addWidget(self.soversamp,14,2) # disable oversampling for now, not properly integrated with save/recall mechanism, and not clear if it's really useful # this is just a spacer self.gbl.setColumnStretch(3,2) self.bbox=QtGui.QGroupBox("Project") self.gbl.addWidget(self.bbox,10,4,4,1) self.bvbl=QtGui.QVBoxLayout() self.bbox.setLayout(self.bvbl) self.bimport=QtGui.QPushButton("Import") self.bvbl.addWidget(self.bimport) self.cinvert=CheckBox(None,"Invert") self.bvbl.addWidget(self.cinvert) self.cxray=CheckBox(None,"X-ray Pixels") self.bvbl.addWidget(self.cxray) QtCore.QObject.connect(self.bimport, QtCore.SIGNAL("clicked(bool)"),self.doImport) QtCore.QObject.connect(self.brefit, QtCore.SIGNAL("clicked(bool)"),self.doRefit) QtCore.QObject.connect(self.cbgadj, QtCore.SIGNAL("valueChanged"),self.bgAdj) QtCore.QObject.connect(self.sdefocus, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sbfactor, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sdfdiff, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sdfang, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sapix, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sampcont, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.svoltage, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.scs, QtCore.SIGNAL("valueChanged"), self.newCTF) QtCore.QObject.connect(self.sboxsize, QtCore.SIGNAL("valueChanged"), self.newBox) # QtCore.QObject.connect(self.soversamp, QtCore.SIGNAL("valueChanged"), self.newBox) QtCore.QObject.connect(self.sang45, QtCore.SIGNAL("valueChanged"), self.recalc_real) QtCore.QObject.connect(self.squality,QtCore.SIGNAL("valueChanged"),self.newQualityFactor) QtCore.QObject.connect(self.setlist,QtCore.SIGNAL("currentRowChanged(int)"),self.newSet) QtCore.QObject.connect(self.setlist,QtCore.SIGNAL("keypress"),self.listkey) QtCore.QObject.connect(self.scalcmode,QtCore.SIGNAL("currentIndexChanged(int)"),self.newCalcMode) QtCore.QObject.connect(self.s2dmode,QtCore.SIGNAL("currentIndexChanged(int)"),self.new2DMode) QtCore.QObject.connect(self.s2danmode,QtCore.SIGNAL("currentIndexChanged(int)"),self.new2DAnMode) QtCore.QObject.connect(self.splotmode,QtCore.SIGNAL("currentIndexChanged(int)"),self.newPlotMode) #QtCore.QObject.connect(self.saveparms,QtCore.SIGNAL("clicked(bool)"),self.on_save_params) #QtCore.QObject.connect(self.recallparms,QtCore.SIGNAL("clicked(bool)"),self.on_recall_params) #QtCore.QObject.connect(self.refit,QtCore.SIGNAL("clicked(bool)"),self.on_refit) #QtCore.QObject.connect(self.output,QtCore.SIGNAL("clicked(bool)"),self.on_output) self.resize(720,380) # figured these values out by printing the width and height in resize event ### This section is responsible for background updates self.busy=False self.needupdate=True self.needredisp=False self.procthread=None self.errors=None # used to communicate errors back from the reprocessing thread self.timer=QTimer() QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.timeOut) self.timer.start(100) self.setWindowTitle("e2evalimage - Control Panel") self.wimage.show() self.wfft.show() self.wplot.show() E2loadappwin("e2evalimage","main",self) E2loadappwin("e2evalimage","image",self.wimage.qt_parent) E2loadappwin("e2evalimage","fft",self.wfft.qt_parent) E2loadappwin("e2evalimage","plot",self.wplot.qt_parent)
def __new__(cls, data=None, old=None, app=None, force_2d=False, force_plot=False, filename="", replace=True): """This will create a new EMImage* object depending on the type of 'data'. If old= is provided, and of the appropriate type, it will be used rather than creating a new instance. """ if isinstance(data, EMData) and data.get_size() == 0: raise RuntimeError( "Can not display an EMData object that has no pixels") from EMAN2 import remove_directories_from_name if force_plot and force_2d: # ok this sucks but it suffices for the time being print( "Error, the force_plot and force_2d options are mutually exclusive" ) return None if force_plot or (isinstance(data, EMData) and data.get_zsize() == 1 and data.get_ysize() == 1): from emplot2d import EMPlot2DWidget if old: if isinstance(old, EMPlot2DWidget): old.set_data(data, remove_directories_from_name(filename), replace) return old widget = EMPlot2DWidget(application=app) widget.set_data(data, remove_directories_from_name(filename), replace) return widget elif force_2d or (isinstance(data, EMData) and data.get_zsize() == 1): from emimage2d import EMImage2DWidget if old: if isinstance(old, EMImage2DWidget): old.set_data(data, filename) return old widget = EMImage2DWidget(application=app) widget.set_data(data, filename) return widget elif isinstance(data, EMData): if isinstance(old, EMScene3D): widget = old else: widget = EMScene3D() data = EMDataItem3D(data, transform=Transform()) #data.setSelectedItem(True) isosurface = EMIsosurface(data, transform=Transform()) widget.insertNewNode(os.path.basename(filename), data, parentnode=widget) widget.insertNewNode("Iso", isosurface, parentnode=data) return widget elif isinstance(data, list) and isinstance(data[0], EMData): from emimagemx import EMImageMXWidget if old: if isinstance(old, EMImageMXWidget): old.set_data(data, filename) return old widget = EMImageMXWidget(application=app) widget.set_data(data, filename) return widget elif isinstance(data, list): from emplot3d import EMPlot3DWidgetNew if (isinstance(data[0], list) or isinstance(data[0], tuple)) and len(data) > 2: if old: if isinstance(old, EMPlot3DWidgetNew): old.set_data(data, remove_directories_from_name(filename), replace) return old widget = EMPlot3DWidgetNew() widget.set_data(data, remove_directories_from_name(filename), replace) return widget else: from emplot2d import EMPlot2DWidget if old: if isinstance(old, EMPlot2DWidget): old.set_data(data, remove_directories_from_name(filename), replace) return old widget = EMPlot2DWidget(application=app) widget.set_data(data, remove_directories_from_name(filename), replace) return widget else: raise Exception( "data must be a single EMData object or a list of EMData objects" )
def __new__(cls, filename, application, force_plot=False, force_2d=False, old=None): file_type = Util.get_filename_ext(filename) em_file_type = EMUtil.get_image_ext_type(file_type) if not file_exists(filename): return None if force_plot and force_2d: # ok this sucks but it suffices for the time being print( "Error, the force_plot and force_2d options are mutually exclusive" ) return None if force_plot: from emplot2d import EMPlot2DWidget if isinstance(old, EMPlot2DWidget): widget = old else: widget = EMPlot2DWidget(application=application) widget.set_data_from_file(filename) return widget if em_file_type != IMAGE_UNKNOWN or filename[:4] == "bdb:": n = EMUtil.get_image_count(filename) nx, ny, nz = gimme_image_dimensions3D(filename) if n > 1 and nz == 1: if force_2d: a = EMData() data = a.read_images(filename) else: data = None # This is like a flag - the ImageMXWidget only needs the file name elif nz == 1: data = [EMData(filename, 0)] else: data = EMData() data.read_image( filename, 0, not force_2d ) # This should be 3-D. We read the header-only here data = [data] if data != None and len(data) == 1: data = data[0] if force_2d or isinstance(data, EMData) and data.get_zsize() == 1: if isinstance(data, list) or data.get_ysize() != 1: from emimage2d import EMImage2DWidget if isinstance(old, EMImage2DWidget): widget = old else: widget = EMImage2DWidget(application=application) else: from emplot2d import EMPlot2DWidget if isinstance(old, EMPlot2DWidget): widget = old else: widget = EMPlot2DWidget(application=application) widget.set_data_from_file(filename) return widget elif isinstance(data, EMData): if isinstance(old, EMScene3D): widget = old else: widget = EMScene3D() # print n,data for ii in xrange(n): data = EMData(filename, ii) datai = EMDataItem3D(data, transform=Transform()) widget.insertNewNode(os.path.basename(filename), datai, parentnode=widget) isosurface = EMIsosurface(datai, transform=Transform()) widget.insertNewNode("Iso", isosurface, parentnode=datai) return widget elif data == None or isinstance(data, list): from emimagemx import EMImageMXWidget if isinstance(old, EMImageMXWidget): widget = old else: widget = EMImageMXWidget(application=application) data = filename else: print(filename) raise # weirdness, this should never happen widget.set_data(data, filename) return widget else: from emplot2d import EMPlot2DWidget if isinstance(old, EMPlot2DWidget): widget = old else: widget = EMPlot2DWidget(application=application) widget.set_data_from_file(filename) return widget
def __init__(self, app): self.app = app QtGui.QWidget.__init__(self, None) self.synthplot = EMPlot2DWidget(self.app) self.synthplot.show() # overall layout self.vbl1 = QtGui.QVBoxLayout() self.setLayout(self.vbl1) # First row contains general purpose controls self.hbl1 = QtGui.QHBoxLayout() self.vbl1.addLayout(self.hbl1) self.vcell = ValBox(self, (0, 128.0), "Cell:", 64) self.hbl1.addWidget(self.vcell) self.vncells = ValBox(self, (0, 128.0), "n Cells:", 1) self.hbl1.addWidget(self.vncells) self.voversamp = ValBox(self, (0, 128.0), "Oversample:", 1) self.hbl1.addWidget(self.voversamp) self.targfn = None self.vnsin = ValBox(self, (1, 64), "# Sin:", 16) self.vnsin.intonly = 1 self.hbl1.addWidget(self.vnsin) self.cbshowall = QtGui.QCheckBox("Show All") self.hbl1.addWidget(self.cbshowall) self.cbshifted = QtGui.QCheckBox("Shifted") self.hbl1.addWidget(self.cbshifted) self.cbtargfn = QtGui.QComboBox(self) self.cbtargfn.addItem("None") self.cbtargfn.addItem("triangle") self.cbtargfn.addItem("square") self.cbtargfn.addItem("square imp") self.cbtargfn.addItem("delta") self.cbtargfn.addItem("noise") self.cbtargfn.addItem("saw") self.cbtargfn.addItem("sin") self.cbtargfn.addItem("modsin") self.cbtargfn.addItem("modsin2") self.cbtargfn.addItem("modsin3") self.cbtargfn.addItem("sin low") self.cbtargfn.addItem("doubledelta") self.cbtargfn.addItem("sin bad f") self.cbtargfn.addItem("sin bad f2") self.hbl1.addWidget(self.cbtargfn) # Widget containing valsliders self.wapsliders = QtGui.QWidget(self) # self.wapsliders.setMinimumSize(800,640) self.gblap = QtGui.QGridLayout() self.gblap.setSizeConstraint(QtGui.QLayout.SetMinAndMaxSize) self.gblap.setColumnMinimumWidth(0, 250) self.gblap.setColumnMinimumWidth(1, 250) self.wapsliders.setLayout(self.gblap) # ScrollArea providing view on slider container widget self.wapsarea = QtGui.QScrollArea(self) self.wapsarea.setWidgetResizable(True) self.wapsarea.setWidget(self.wapsliders) self.vbl1.addWidget(self.wapsarea) QtCore.QObject.connect(self.vcell, QtCore.SIGNAL("valueChanged"), self.recompute) QtCore.QObject.connect(self.vncells, QtCore.SIGNAL("valueChanged"), self.recompute) QtCore.QObject.connect(self.voversamp, QtCore.SIGNAL("valueChanged"), self.recompute) QtCore.QObject.connect(self.vnsin, QtCore.SIGNAL("valueChanged"), self.nsinchange) QtCore.QObject.connect(self.cbshowall, QtCore.SIGNAL("stateChanged(int)"), self.recompute) QtCore.QObject.connect(self.cbshifted, QtCore.SIGNAL("stateChanged(int)"), self.recompute) QtCore.QObject.connect(self.cbtargfn, QtCore.SIGNAL("activated(int)"), self.newtargfn) self.wamp = [] self.wpha = [] self.curves = [] self.xvals = [] for i in range(65): self.wamp.append(ValSlider(self, (0.0, 1.0), "%2d:" % i, 0.0)) self.gblap.addWidget(self.wamp[-1], i, 0) QtCore.QObject.connect(self.wamp[-1], QtCore.SIGNAL("valueChanged"), self.recompute) self.wpha.append(ValSlider(self, (-180.0, 180.0), "%2d:" % i, 0.0)) self.gblap.addWidget(self.wpha[-1], i, 1) QtCore.QObject.connect(self.wpha[-1], QtCore.SIGNAL("valueChanged"), self.recompute) self.curves.append(EMData(64, 1)) if self.cbshowall.isChecked(): self.synthplot self.total = EMData(64, 1) self.nsinchange()
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_()