def calcResolution(self, partlist, stackfile, apix): ### group particles by refnum reflistsdict = {} for partdict in partlist: refnum = partdict['template'] partnum = partdict['num'] if not refnum in reflistsdict: reflistsdict[refnum] = [] reflistsdict[refnum].append(partnum) ### get resolution self.resdict = {} boxsizetuple = apFile.getBoxSize(stackfile) boxsize = boxsizetuple[0] for refnum in reflistsdict.keys(): partlist = reflistsdict[refnum] esttime = 3e-6 * len(partlist) * boxsize**2 apDisplay.printMsg("Ref num %d; %d parts; est time %s" %(refnum, len(partlist), apDisplay.timeString(esttime))) frcdata = apFourier.spectralSNRStack(stackfile, apix, partlist, msg=False) frcfile = "frcplot-%03d.dat"%(refnum) apFourier.writeFrcPlot(frcfile, frcdata, apix, boxsize) res = apFourier.getResolution(frcdata, apix, boxsize) self.resdict[refnum] = res return
def getResolutionFromGenericFSCFile(fscfile, boxsize, apix, filtradius=3, criterion=0.5, msg=False): """ parses standard 2-column FSC file with 1) spatial frequency and 2) FRC, returns resolution """ if not os.path.isfile(fscfile): apDisplay.printError("fsc file does not exist") if msg is True: apDisplay.printMsg("box: %d, apix: %.3f, file: %s" % (boxsize, apix, fscfile)) f = open(fscfile, 'r') fscfileinfo = f.readlines() f.close() fscdata = numpy.zeros((int(boxsize) / 2), dtype=numpy.float32) for i, info in enumerate(fscfileinfo): # skip commented out lines if info[0] == "#": pass else: fscfileinfo = fscfileinfo[i:] break for j, info in enumerate(fscfileinfo): frc = float(info.split()[1]) fscdata[j] = frc res = apFourier.getResolution(fscdata, apix, boxsize, filtradius=filtradius, crit=criterion) return res
def getResolutionFromGenericFSCFile(fscfile, boxsize, apix, filtradius=3, criterion=0.5, msg=False): """ parses standard 2-column FSC file with 1) spatial frequency and 2) FRC, returns resolution """ if not os.path.isfile(fscfile): apDisplay.printError("fsc file does not exist") if msg is True: apDisplay.printMsg("box: %d, apix: %.3f, file: %s" % (boxsize, apix, fscfile)) f = open(fscfile, "r") fscfileinfo = f.readlines() f.close() fscdata = numpy.zeros((int(boxsize) / 2), dtype=numpy.float32) for i, info in enumerate(fscfileinfo): # skip commented out lines if info[0] == "#": pass else: fscfileinfo = fscfileinfo[i:] break for j, info in enumerate(fscfileinfo): frc = float(info.split()[1]) fscdata[j] = frc res = apFourier.getResolution(fscdata, apix, boxsize, filtradius=filtradius, crit=criterion) return res
def calcResolution(self, level): self.resdict = {} D=self.getClassificationAtLevel(level) for classref in D: stack=[] for partnum in D[classref]: stack.append(apImagicFile.readSingleParticleFromStack("alignedStack.hed",int(partnum)+1,msg=False)) apImagicFile.writeImagic(stack,"tmp.hed") frcdata = apFourier.spectralSNRStack("tmp.hed", self.apix) self.resdict[classref] = apFourier.getResolution(frcdata, self.apix, self.boxsize) apFile.removeStack("tmp.hed")
def calcResolution(self, level): self.resdict = {} D=self.getClassificationAtLevel(level) for classref in D: stack=[] for partnum in D[classref]: ### NOTE: RESOLUTION WILL NOT BE CALCULATED IF ALIGNED STACK IS NOT CREATED stack.append(apImagicFile.readSingleParticleFromStack(self.params['timestamp']+".hed",int(partnum),msg=False)) apImagicFile.writeImagic(stack,"tmp.hed") frcdata = apFourier.spectralSNRStack("tmp.hed", self.apix) self.resdict[classref] = apFourier.getResolution(frcdata, self.apix, self.boxsize) apFile.removeStack("tmp.hed")
def calcResolution(self, alignedStack): self.resdict = {} for classref, partlist in self.classD.iteritems(): if len(partlist) == 0: continue stack=[] for partnum in partlist: ### NOTE: RESOLUTION WILL NOT BE CALCULATED IF ALIGNED STACK IS NOT CREATED stack.append(apImagicFile.readSingleParticleFromStack(alignedStack,int(partnum),msg=False)) apImagicFile.writeImagic(stack,"tmp.hed") frcdata = apFourier.spectralSNRStack("tmp.hed", self.apix) self.resdict[classref] = apFourier.getResolution(frcdata, self.apix, self.boxsize) apFile.removeStack("tmp.hed")
def calcResolution(self, alignedStack): self.resdict = {} for classref, partlist in self.classD.iteritems(): if len(partlist) == 0: continue stack = [] for partnum in partlist: ### NOTE: RESOLUTION WILL NOT BE CALCULATED IF ALIGNED STACK IS NOT CREATED stack.append( apImagicFile.readSingleParticleFromStack(alignedStack, int(partnum), msg=False)) apImagicFile.writeImagic(stack, "tmp.hed") frcdata = apFourier.spectralSNRStack("tmp.hed", self.apix) self.resdict[classref] = apFourier.getResolution( frcdata, self.apix, self.boxsize) apFile.removeStack("tmp.hed")