def processImage(self, imgdata, filtarray): if abs(self.params['apix'] - self.params['templateapix']) > 0.01: #rescale templates, apix has changed apTemplate.getTemplates(self.params) ### RUN FindEM ### save filter image to .dwn.mrc imgpath = os.path.join(self.params['rundir'], imgdata['filename']+".dwn.mrc") apImage.arrayToMrc(filtarray, imgpath, msg=False) ### run FindEM looptdiff = time.time()-self.proct0 self.proct0 = time.time() proctdiff = time.time()-self.proct0 f = open("template_image_timing.dat", "a") datstr = "%d\t%.5f\t%.5f\n"%(self.stats['count'], proctdiff, looptdiff) f.write(datstr) f.close() ### run Template Correlation program cclist = self.runTemplateCorrelator(imgdata) ### find peaks in map peaktree = self.findPeaks(imgdata, cclist) return peaktree
def processImage(self, imgdata, filtarray): if abs(self.params['apix'] - self.params['templateapix']) > 0.01: #rescale templates, apix has changed apTemplate.getTemplates(self.params) ### RUN Signature ### save filter image to .dwn.mrc imgpath = os.path.join(self.params['rundir'], imgdata['filename'] + ".dwn.mrc") apImage.arrayToMrc(filtarray, imgpath, msg=False) ### run Signature looptdiff = time.time() - self.proct0 self.proct0 = time.time() plist = apSignature.runSignature(imgdata, self.params) proctdiff = time.time() - self.proct0 f = open("template_image_timing.dat", "a") datstr = "%d\t%.5f\t%.5f\n" % (self.stats['count'], proctdiff, looptdiff) f.write(datstr) f.close() # convert list of particles to peaktree peaktree = apSignature.partToPeakTree(plist, self.params['bin']) return peaktree
def processImage(self, imgdata, filtarray): if abs(self.params['apix'] - self.params['templateapix']) > 0.01: #rescale templates, apix has changed apTemplate.getTemplates(self.params) ### RUN FindEM ### save filter image to .dwn.mrc imgpath = os.path.join(self.params['rundir'], imgdata['filename'] + ".dwn.mrc") apImage.arrayToMrc(filtarray, imgpath, msg=False) ### run FindEM looptdiff = time.time() - self.proct0 self.proct0 = time.time() proctdiff = time.time() - self.proct0 f = open("template_image_timing.dat", "a") datstr = "%d\t%.5f\t%.5f\n" % (self.stats['count'], proctdiff, looptdiff) f.write(datstr) f.close() ### run Template Correlation program cclist = self.runTemplateCorrelator(imgdata) ### find peaks in map peaktree = self.findPeaks(imgdata, cclist) return peaktree
def preLoopFunctions(self): if len(self.imgtree) > 0: self.params['apix'] = apDatabase.getPixelSize(self.imgtree[0]) # CREATES TEMPLATES # SETS params['templatelist'] AND self.params['templateapix'] apTemplate.getTemplates(self.params) apDisplay.printColor("Template list: "+str(self.params['templatelist']), "cyan") self.checkPreviousTemplateRun()
def preLoopFunctions(self): if len(self.imgtree) > 0: self.params['apix'] = apDatabase.getPixelSize(self.imgtree[0]) # CREATES TEMPLATES # SETS params['templatelist'] AND self.params['templateapix'] apTemplate.getTemplates(self.params) apDisplay.printColor( "Template list: " + str(self.params['templatelist']), "cyan") self.checkPreviousTemplateRun()
def createTemplateStack(self): """ takes the spider file and creates an average template of all particles """ templatestack = os.path.join(self.params['rundir'], "templatestack00.spi") apFile.removeFile(templatestack, warn=True) ### hack to use standard filtering library templateparams = {} templateparams['apix'] = self.stack['apix'] templateparams['rundir'] = os.path.join(self.params['rundir'], "templates") templateparams['templateIds'] = self.templatelist templateparams['bin'] = self.params['bin'] templateparams['lowpass'] = self.params['lowpass'] templateparams['median'] = None templateparams['pixlimit'] = None print templateparams apParam.createDirectory(os.path.join(self.params['rundir'], "templates")) filelist = apTemplate.getTemplates(templateparams) for mrcfile in filelist: emancmd = ("proc2d templates/"+mrcfile+" "+templatestack +" clip="+str(self.boxsize)+","+str(self.boxsize) +" spider ") if self.params['inverttemplates'] is True: emancmd += " invert " apEMAN.executeEmanCmd(emancmd, showcmd=False) return templatestack
def createTemplateStack(self): """ convert spider template stack """ templatestack = os.path.join(self.params['rundir'], "templatestack.spi") apFile.removeFile(templatestack, warn=True) ### hack to use standard filtering library templateparams = {} templateparams['apix'] = self.stack['apix'] templateparams['rundir'] = os.path.join(self.params['rundir'], "templates") templateparams['templateIds'] = self.templatelist templateparams['bin'] = self.params['bin'] templateparams['lowpass'] = self.params['lowpass'] templateparams['median'] = None templateparams['pixlimit'] = None print 'Converting reference templates:\n', templateparams apParam.createDirectory( os.path.join(self.params['rundir'], "templates")) filelist = apTemplate.getTemplates(templateparams) localclip = self.clipsize / self.params['bin'] for mrcfile in filelist: emancmd = ("proc2d templates/" + mrcfile + " " + templatestack + " clip=" + str(localclip) + "," + str(localclip) + " edgenorm spiderswap ") if self.params['inverttemplates'] is True: emancmd += " invert " apEMAN.executeEmanCmd(emancmd, showcmd=False) return templatestack
def createOrientationReference(self): """ convert spider orientation reference """ orientref = os.path.join(self.params['rundir'], "orient.spi") apFile.removeFile(orientref, warn=True) #templatedata = apTemplate.getTemplateFromId(self.params['orientref']) #templatefile = os.path.join(templatedata['path']['path'], templatedata['templatename']) ### hack to use standard filtering library templateparams = {} templateparams['apix'] = self.stack['apix'] templateparams['rundir'] = os.path.join(self.params['rundir'], "templates") templateparams['templateIds'] = [self.params['orientref'],] templateparams['bin'] = self.params['bin'] templateparams['lowpass'] = self.params['lowpass'] templateparams['median'] = None templateparams['pixlimit'] = None print 'Converting orientation reference:\n', templateparams apParam.createDirectory(os.path.join(self.params['rundir'], "templates")) filelist = apTemplate.getTemplates(templateparams) mrcfile = filelist[0] localclip = self.clipsize/self.params['bin'] emancmd = ("proc2d templates/"+mrcfile+" "+orientref +" clip="+str(localclip)+","+str(localclip) +" edgenorm spiderswap-single ") if self.params['inverttemplates'] is True: emancmd += " invert " apEMAN.executeEmanCmd(emancmd, showcmd=False) return orientref
def createTemplateStack(self): """ convert spider template stack """ templatestack = os.path.join(self.params['rundir'], "templatestack.spi") apFile.removeFile(templatestack, warn=True) ### hack to use standard filtering library templateparams = {} templateparams['apix'] = self.stack['apix'] templateparams['rundir'] = os.path.join(self.params['rundir'], "templates") templateparams['templateIds'] = self.templatelist templateparams['bin'] = self.params['bin'] templateparams['lowpass'] = self.params['lowpass'] templateparams['median'] = None templateparams['pixlimit'] = None print 'Converting reference templates:\n', templateparams apParam.createDirectory(os.path.join(self.params['rundir'], "templates")) filelist = apTemplate.getTemplates(templateparams) localclip = self.clipsize/self.params['bin'] for mrcfile in filelist: emancmd = ("proc2d templates/"+mrcfile+" "+templatestack +" clip="+str(localclip)+","+str(localclip) +" edgenorm spiderswap ") if self.params['inverttemplates'] is True: emancmd += " invert " apEMAN.executeEmanCmd(emancmd, showcmd=False) return templatestack
def preLoopFunctions(self): if len(self.imgtree) > 0: self.params['apix'] = apDatabase.getPixelSize(self.imgtree[0]) # CREATES TEMPLATES # SETS params['templatelist'] AND self.params['templateapix'] apTemplate.getTemplates(self.params) apDisplay.printColor("Template list: "+str(self.params['templatelist']), "cyan") self.checkPreviousTemplateRun() # convert templates to single mrc stack for signature tstack="templatestack.mrc" twods=[] for t in self.params['templatelist']: twods.append(mrc.read(t)) imgar=numpy.array(twods) mrc.write(imgar, tstack) self.params['templatename']=tstack
def preLoopFunctions(self): if len(self.imgtree) > 0: self.params['apix'] = apDatabase.getPixelSize(self.imgtree[0]) # CREATES TEMPLATES # SETS params['templatelist'] AND self.params['templateapix'] apTemplate.getTemplates(self.params) apDisplay.printColor( "Template list: " + str(self.params['templatelist']), "cyan") self.checkPreviousTemplateRun() # convert templates to single mrc stack for signature tstack = "templatestack.mrc" twods = [] for t in self.params['templatelist']: twods.append(mrc.read(t)) imgar = numpy.array(twods) mrc.write(imgar, tstack) self.params['templatename'] = tstack
def processImage(self, imgdata, filtarray): if abs(self.params['apix'] - self.params['templateapix']) > 0.01: #rescale templates, apix has changed apTemplate.getTemplates(self.params) ### RUN Signature ### save filter image to .dwn.mrc imgpath = os.path.join(self.params['rundir'], imgdata['filename']+".dwn.mrc") apImage.arrayToMrc(filtarray, imgpath, msg=False) ### run Signature looptdiff = time.time()-self.proct0 self.proct0 = time.time() plist = apSignature.runSignature(imgdata, self.params) proctdiff = time.time()-self.proct0 f = open("template_image_timing.dat", "a") datstr = "%d\t%.5f\t%.5f\n"%(self.stats['count'], proctdiff, looptdiff) f.write(datstr) f.close() # convert list of particles to peaktree peaktree = apSignature.partToPeakTree(plist,self.params['bin']) return peaktree
def initializeTemplates(self): """ creates initial templates """ templatetime = time.time() templatedir = os.path.join(self.params['rundir'], "templates") apParam.createDirectory(templatedir) ### hack to use standard filtering library templateparams = {} templateparams['apix'] = self.stack['apix'] templateparams['rundir'] = templatedir templateparams['templateIds'] = self.templatelist templateparams['bin'] = self.params['bin'] templateparams['lowpass'] = self.params['lowpass'] templateparams['median'] = None templateparams['pixlimit'] = None filelist = apTemplate.getTemplates(templateparams) templateselfile = os.path.join(self.params['rundir'], "templates.sel") f = open(templateselfile, "w") for mrcfile in filelist: spifile = mrcfile[:-4] + ".xmp" emancmd = ("proc2d templates/" + mrcfile + " templates/" + spifile + " clip=" + str(self.clipsize) + "," + str(self.clipsize) + " spiderswap-single ") if self.params['inverttemplates'] is True: emancmd += " invert " apEMAN.executeEmanCmd(emancmd, showcmd=False) if not os.path.isfile("templates/" + spifile): apDisplay.printError("Template conversion failed") temppath = os.path.join(self.params['rundir'], "templates/" + spifile) f.write(temppath + " 1\n") f.close() templatetime = time.time() - templatetime apDisplay.printMsg("Template time: " + apDisplay.timeString(templatetime)) return templateselfile
def initializeTemplates(self): """ creates initial templates """ templatetime = time.time() templatedir = os.path.join(self.params['rundir'], "templates") apParam.createDirectory(templatedir) ### hack to use standard filtering library templateparams = {} templateparams['apix'] = self.stack['apix'] templateparams['rundir'] = templatedir templateparams['templateIds'] = self.templatelist templateparams['bin'] = self.params['bin'] templateparams['lowpass'] = self.params['lowpass'] templateparams['median'] = None templateparams['pixlimit'] = None filelist = apTemplate.getTemplates(templateparams) templateselfile = os.path.join(self.params['rundir'], "templates.sel") f = open(templateselfile, "w") for mrcfile in filelist: spifile = mrcfile[:-4]+".xmp" emancmd = ("proc2d templates/"+mrcfile+" templates/"+spifile +" clip="+str(self.clipsize)+","+str(self.clipsize) +" spiderswap-single ") if self.params['inverttemplates'] is True: emancmd += " invert " apEMAN.executeEmanCmd(emancmd, showcmd=False) if not os.path.isfile("templates/"+spifile): apDisplay.printError("Template conversion failed") temppath = os.path.join(self.params['rundir'], "templates/"+spifile) f.write(temppath+" 1\n") f.close() templatetime = time.time() - templatetime apDisplay.printMsg("Template time: "+apDisplay.timeString(templatetime)) return templateselfile
def createOrientationReference(self): """ convert spider orientation reference """ orientref = os.path.join(self.params['rundir'], "orient.spi") apFile.removeFile(orientref, warn=True) #templatedata = apTemplate.getTemplateFromId(self.params['orientref']) #templatefile = os.path.join(templatedata['path']['path'], templatedata['templatename']) ### hack to use standard filtering library templateparams = {} templateparams['apix'] = self.stack['apix'] templateparams['rundir'] = os.path.join(self.params['rundir'], "templates") templateparams['templateIds'] = [ self.params['orientref'], ] templateparams['bin'] = self.params['bin'] templateparams['lowpass'] = self.params['lowpass'] templateparams['median'] = None templateparams['pixlimit'] = None print 'Converting orientation reference:\n', templateparams apParam.createDirectory( os.path.join(self.params['rundir'], "templates")) filelist = apTemplate.getTemplates(templateparams) mrcfile = filelist[0] localclip = self.clipsize / self.params['bin'] emancmd = ("proc2d templates/" + mrcfile + " " + orientref + " clip=" + str(localclip) + "," + str(localclip) + " edgenorm spiderswap-single ") if self.params['inverttemplates'] is True: emancmd += " invert " apEMAN.executeEmanCmd(emancmd, showcmd=False) return orientref