Пример #1
0
        def start(self):
                """
                this is the main component of the script
                where all the processing is done
                """

                imgarray = mrc.read(self.params['image'])
                if self.params['invert'] is True:
                        imgarray = -1.0*imgarray

                dogmaps = apDog.diffOfGaussParam(imgarray, self.params)
                rootname = os.path.splitext(self.params['image'])[0]
                pixdiam = self.params['diam']/self.params['apix']
                pixrad = pixdiam/2.0

                peaktreelist = []
                count = 0
                for dogmap in dogmaps:
                        count += 1

                        ### threshold maps and extract peaks
                        peaktree = apPeaks.findPeaksInMap(dogmap, thresh=self.params['thresh'],
                                pixdiam=pixdiam, count=count, olapmult=self.params["overlapmult"],
                                maxpeaks=self.params["maxpeaks"], maxsizemult=self.params["maxsizemult"],
                                msg=True, bin=1)

                        ### remove peaks from areas near the border of the image
                        peaktree = apPeaks.removeBorderPeaks(peaktree, pixdiam, 
                                dogmap.shape[0], dogmap.shape[1])

                        ### create a nice image of pick locations
                        mapfile = "%s-map%02d.jpg"%(rootname, count)
                        apPeaks.createPeakMapImage(peaktree, dogmap, imgname=mapfile, pixrad=pixrad)
                        imgfile = "%s-picks%02d.jpg"%(rootname, count)
                        apPeaks.subCreatePeakJpeg(imgarray, peaktree, pixrad, imgfile, bin=1)

                        peaktreelist.append(peaktree)

                ### merge list in a single set of particle picks
                imgdata = { 'filename': self.params['image'], }
                peaktree = apPeaks.mergePeakTrees(imgdata, peaktreelist, self.params, pikfile=False)

                ### throw away particles above maxthresh
                precount = len(peaktree)
                peaktree = apPeaks.maxThreshPeaks(peaktree, self.params['maxthresh'])
                postcount = len(peaktree)
                apDisplay.printMsg("Filtered %d particles above max threshold %.2f"
                        %(precount-postcount,self.params['maxthresh']))

                ### create final images with pick locations
                mapfile = "%s-finalmap.jpg"%(rootname)
                apPeaks.createPeakMapImage(peaktree, dogmap, imgname=mapfile, pixrad=pixrad)
                imgfile = "%s-finalpicks.jpg"%(rootname)
                apPeaks.subCreatePeakJpeg(imgarray, peaktree, pixrad, imgfile, bin=1)

                ### write output file
                self.writeTextFile(peaktree)
Пример #2
0
def findPeaks(imgdict, maplist, params, pikfile=True):
    #modeified from apPeaks.findPeaks to read peaks from box file per ccmap
    peaktreelist = []
    count = 0

    imgname = imgdict['filename']
    mapdir = os.path.join(params['rundir'], "maps")
    bin = int(params["bin"])
    diam = float(params["diam"])
    apix = float(params["apix"])
    olapmult = float(params["overlapmult"])
    maxthresh = params["maxthresh"]
    maxsizemult = float(params["maxsize"])
    msg = not params['background']
    tmpldbid = None

    for imgmap in maplist:
        count += 1

        if 'templateIds' in params:
            #template correlator
            tmpldbid = params['templateIds'][count - 1]

        peaktree = getPeaksFromBoxFile(imgmap)
        newpeaktree = []
        for peakdict in peaktree:
            peakdict = apPeaks.attachTemplateLabel(peakdict, count, tmpldbid,
                                                   diam)
            newpeaktree.append(peakdict)
        peaktree = newpeaktree
        #write pikfile
        if pikfile is True:
            apPeaks.peakTreeToPikFile(peaktree, imgname, count,
                                      params['rundir'])

        #append to complete list of peaks
        peaktreelist.append(peaktree)

    peaktree = apPeaks.mergePeakTrees(imgdict,
                                      peaktreelist,
                                      params,
                                      msg,
                                      pikfile=pikfile)

    #max threshold
    if maxthresh is not None:
        precount = len(peaktree)
        peaktree = apPeaks.maxThreshPeaks(peaktree, maxthresh)
        postcount = len(peaktree)
        #if precount != postcount:
        apDisplay.printMsg("Filtered %d particles above threshold %.2f" %
                           (precount - postcount, maxthresh))

    return peaktree
Пример #3
0
def findPeaks(imgdict, maplist, params,pikfile=True):
	#modeified from apPeaks.findPeaks to read peaks from box file per ccmap
	peaktreelist = []
	count = 0

	imgname = imgdict['filename']
	mapdir = os.path.join(params['rundir'], "maps")
	bin =       int(params["bin"])
	diam =      float(params["diam"])
	apix =      float(params["apix"])
	olapmult =  float(params["overlapmult"])
	maxthresh = params["maxthresh"]
	maxsizemult = float(params["maxsize"])
	msg =       not params['background']
	tmpldbid =  None

	for imgmap in maplist:
		count += 1

		if 'templateIds' in params:
			#template correlator
			tmpldbid =  params['templateIds'][count-1]

		peaktree = getPeaksFromBoxFile(imgmap)
		newpeaktree = []
		for peakdict in peaktree:
			peakdict = apPeaks.attachTemplateLabel(peakdict,count,tmpldbid,diam)
			newpeaktree.append(peakdict)
		peaktree = newpeaktree
		#write pikfile
		if pikfile is True:
			apPeaks.peakTreeToPikFile(peaktree, imgname, count, params['rundir'])

		#append to complete list of peaks
		peaktreelist.append(peaktree)

	peaktree = apPeaks.mergePeakTrees(imgdict, peaktreelist, params, msg, pikfile=pikfile)

	#max threshold
	if maxthresh is not None:
		precount = len(peaktree)
		peaktree = apPeaks.maxThreshPeaks(peaktree, maxthresh)
		postcount = len(peaktree)
		#if precount != postcount:
		apDisplay.printMsg("Filtered %d particles above threshold %.2f"%(precount-postcount,maxthresh))

	return peaktree