コード例 #1
0
	def showAssessedMask(self,imgfile,imgdata):
		self.filename = imgfile
		image = pyami.mrc.read(imgfile)
		sessiondata = self.params['sessionname']
		maskassessname = self.params['checkMask']
		mask,maskbin = apMask.makeInspectedMask(sessiondata,maskassessname,imgdata)
		overlay = apMask.overlayMask(image,mask)
		self.app.panel.setImage(overlay.astype(numpy.float32))
コード例 #2
0
    def processAndSaveAllImages(self):
        sys.stderr.write("Pre-processing images before picking\n")
        count = 0
        total = len(self.imgtree)
        # if we are masking based on a previous mask run, and only want to process images with rejected masks,
        # remove any images with accepted masks from the imgtree.
        newImageTree = []
        for imgdata in self.imgtree:
            count += 1

            # useAccecepted mask is true when the assess flag is used, and an
            # accepted mask is found in the indicated mask run that should be retained
            self.useAcceptedMask = False

            # check to see if this image
            # 1. Does not have a mask region
            # 2. Has only mask regions that have been rejected
            # If both are true, continue, otherwise we do not need to display this image.

            filename = imgdata['filename']
            maskAssessRunName = self.params['assessname']
            sessiondata = apDatabase.getSessionDataFromSessionName(
                self.params['sessionname'])

            maskimg, maskbin = apMask.makeInspectedMask(
                sessiondata, maskAssessRunName, imgdata)
            if maskimg is not None and maskimg.size:
                apDisplay.printMsg("Skipping image with accepted mask region.")
                maskimg = apMask.reshapeMask(imgdata['image'], maskimg)
                self.maskimg = maskimg
                self.image = imgdata['image']
                self.useAcceptedMask = True
                self.commitToDatabase(imgdata)
                continue

            imgpath = os.path.join(self.params['rundir'],
                                   imgdata['filename'] + '.dwn.mrc')
            if self.params['continue'] is True and os.path.isfile(imgpath):
                sys.stderr.write(".")
                #print "already processed: ",apDisplay.short(imgdata['filename'])
            else:
                if os.path.isfile(imgpath):
                    os.remove(imgpath)
                sys.stderr.write("#")
                apFindEM.processAndSaveImage(imgdata, params=self.params)

            newImageTree.append(imgdata)

            if count % 60 == 0:
                sys.stderr.write(" %d left\n" % (total - count))

        self.imgtree = newImageTree
コード例 #3
0
	def processAndSaveAllImages(self):
		sys.stderr.write("Pre-processing images before picking\n")
		count = 0
		total = len(self.imgtree)
		# if we are masking based on a previous mask run, and only want to process images with rejected masks,
		# remove any images with accepted masks from the imgtree.
		newImageTree = []
		for imgdata in self.imgtree:
			count += 1
				
	        # useAccecepted mask is true when the assess flag is used, and an 
	        # accepted mask is found in the indicated mask run that should be retained
			self.useAcceptedMask = False 
			
			# check to see if this image
			# 1. Does not have a mask region
			# 2. Has only mask regions that have been rejected
			# If both are true, continue, otherwise we do not need to display this image.
			
			filename = imgdata['filename']		
			maskAssessRunName = self.params['assessname']
			sessiondata = apDatabase.getSessionDataFromSessionName(self.params['sessionname'])
			
			maskimg,maskbin = apMask.makeInspectedMask( sessiondata, maskAssessRunName, imgdata )
			if maskimg is not None and maskimg.size:
				apDisplay.printMsg("Skipping image with accepted mask region.")
				maskimg = apMask.reshapeMask( imgdata['image'], maskimg )
				self.maskimg = maskimg
				self.image = imgdata['image']
				self.useAcceptedMask = True
				self.commitToDatabase(imgdata)
				continue
			
			imgpath = os.path.join(self.params['rundir'], imgdata['filename']+'.dwn.mrc')
			if self.params['continue'] is True and os.path.isfile(imgpath):
				sys.stderr.write(".")
				#print "already processed: ",apDisplay.short(imgdata['filename'])
			else:
				if os.path.isfile(imgpath):
					os.remove(imgpath)
				sys.stderr.write("#")
				apFindEM.processAndSaveImage(imgdata, params=self.params)

			newImageTree.append(imgdata)

			if count % 60 == 0:
				sys.stderr.write(" %d left\n" % (total-count))
				
		self.imgtree = newImageTree
コード例 #4
0
	def eliminateMaskedParticles(self, particles, imgdata):
		newparticles = []
		eliminated = 0
		sessiondata = apDatabase.getSessionDataFromSessionName(self.params['sessionname'])
		if self.params['defocpair']:
			imgdata = apDefocalPairs.getTransformedDefocPair(imgdata,2)
		maskimg,maskbin = apMask.makeInspectedMask(sessiondata,self.params['maskassess'],imgdata)
		if maskimg is not None:
			for prtl in particles:
				binnedcoord = (int(prtl['ycoord']/maskbin),int(prtl['xcoord']/maskbin))
				if maskimg[binnedcoord] != 0:
					eliminated += 1
				else:
					newparticles.append(prtl)
			apDisplay.printMsg("%i particle(s) eliminated due to masking"%eliminated)
		else:
			apDisplay.printMsg("no masking")
			newparticles = particles
		return newparticles
 def eliminateMaskedParticles(self, particles, imgdata):
     newparticles = []
     eliminated = 0
     sessiondata = apDatabase.getSessionDataFromSessionName(
         self.params['sessionname'])
     if self.params['defocpair']:
         imgdata = apDefocalPairs.getTransformedDefocPair(imgdata, 2)
     maskimg, maskbin = apMask.makeInspectedMask(sessiondata,
                                                 self.params['maskassess'],
                                                 imgdata)
     if maskimg is not None:
         for prtl in particles:
             binnedcoord = (int(prtl['ycoord'] / maskbin),
                            int(prtl['xcoord'] / maskbin))
             if maskimg[binnedcoord] != 0:
                 eliminated += 1
             else:
                 newparticles.append(prtl)
         apDisplay.printMsg("%i particle(s) eliminated due to masking" %
                            eliminated)
     else:
         apDisplay.printMsg("no masking")
         newparticles = particles
     return newparticles