Пример #1
0
def testSurface():
        array = readMrc()
        if array.shape[0] < 2:
                array = randomSurface()
        print "Shape of array: ", array.shape

        tifs = time.time()
        surfareabyifs = surfaceAreaByIfs(array, test=True)
        print "Surface area by ifs = %.3f pixels"%(surfareabyifs)
        fifs = time.time()

        tints = time.time()
        surfareabyints = surfaceAreaByInts(array, test=True)
        print "Surface area by ints = %.3f pixels"%(surfareabyints)
        fints = time.time()

        import apDisplay
        size = float(array.shape[0]*array.shape[1]*array.shape[2])
        print ""
        print "*** Surface area by ifs = %.3f pixels"%(surfareabyifs)
        print apDisplay.timeString((fifs-tifs)), "total time"
        print apDisplay.timeString((fifs-tifs)/size), "per voxel"
        print ""
        print "*** Surface area by ints = %.3f pixels"%(surfareabyints)
        print apDisplay.timeString((fints-tints)), "total time"
        print apDisplay.timeString((fints-tints)/size), "per voxel"     
        print ""
Пример #2
0
    def run(self):
        t0 = time.time()
        imgarray = self.openFile()
        self.imgshape = imgarray.shape
        self.printImageInfo(imgarray)
        coordlist = self.setupCoordList()

        ctfdict = {}
        self.count = 0
        ### process image pieces
        print "processing %d image pieces" % (len(coordlist))
        keys = coordlist.keys()
        keys.sort()
        for key in keys:
            (xstr, ystr) = key.split('x')
            x = int(xstr)
            y = int(ystr)
            self.count += 1
            subarray = self.getSubImage(imgarray, x, y)
            #self.printImageInfo(subarray)
            imgfile = "splitimage-" + key + ".dwn.mrc"
            mrc.write(subarray, imgfile)
            ctfvalues = None
            reproc = 0
            edgeblur = 8
            while ctfvalues is None and reproc < 3:
                ctfvalues = self.processImage(imgfile, edgeblur)
                reproc += 1
                edgeblur += 2
            if ctfvalues is not None:
                sys.stderr.write("#")
            else:
                sys.stderr.write("!")
            ctfdict[key] = ctfvalues
            apFile.removeFilePattern(imgfile + "*", False)
        sys.stderr.write("\n")

        ### calculate ctf parameters
        self.fitPlaneToCtf(ctfdict)
        apDisplay.printMsg("Time: %s" %
                           (apDisplay.timeString(time.time() - t0)))
        def run(self):
                t0 = time.time()
                imgarray = self.openFile()
                self.imgshape = imgarray.shape
                self.printImageInfo(imgarray) 
                coordlist = self.setupCoordList()

                ctfdict = {}
                self.count = 0
                ### process image pieces
                print "processing %d image pieces"%(len(coordlist))
                keys = coordlist.keys()
                keys.sort()
                for key in keys:
                        (xstr,ystr) = key.split('x')
                        x = int(xstr)
                        y = int(ystr)
                        self.count += 1
                        subarray = self.getSubImage(imgarray, x, y)
                        #self.printImageInfo(subarray) 
                        imgfile = "splitimage-"+key+".dwn.mrc"
                        mrc.write(subarray, imgfile)
                        ctfvalues = None
                        reproc = 0
                        edgeblur = 8
                        while ctfvalues is None and reproc < 3:
                                ctfvalues = self.processImage(imgfile, edgeblur)
                                reproc += 1
                                edgeblur += 2
                        if ctfvalues is not None:
                                sys.stderr.write("#")
                        else:
                                sys.stderr.write("!")
                        ctfdict[key] = ctfvalues
                        apFile.removeFilePattern(imgfile+"*", False)
                sys.stderr.write("\n")

                ### calculate ctf parameters
                self.fitPlaneToCtf(ctfdict)
                apDisplay.printMsg("Time: %s"%(apDisplay.timeString(time.time()-t0)))