def runManualPicker(self, imgdata):
        #reset targets
        self.targets = []

        #set the assessment status
        self.assessold = apDatabase.checkInspectDB(imgdata)
        self.assess = self.assessold
        self.app.setAssessStatus()
        # 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
        # This is checked in the preLoopFunctions().
        self.useAcceptedMask = False

        #open new file
        imgname = imgdata['filename'] + '.dwn.mrc'
        imgpath = os.path.join(self.params['rundir'], imgname)

        # Add this image to mask vertices file
        if not self.params['checkmask']:
            self.app.panel.openImageFile(imgpath)
        else:
            self.showAssessedMask(imgpath, imgdata)

        #set vital stats
        self.app.vitalstats.SetLabel(" image name: " + imgdata['filename'])
        #run the picker
        self.app.MainLoop()

        #targets are copied to self.targets by app
        #assessment is copied to self.assess by app
        self.app.panel.openImageFile(None)
	def runManualPicker(self, imgdata):
		#reset targets
		self.targets = []

		#set the assessment status
		self.assessold = apDatabase.checkInspectDB(imgdata)
		self.assess = self.assessold
		self.app.setAssessStatus()
        # 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
        # This is checked in the preLoopFunctions().
		self.useAcceptedMask = False 

		#open new file
		imgname = imgdata['filename']+'.dwn.mrc'
		imgpath = os.path.join(self.params['rundir'],imgname)
		
		# Add this image to mask vertices file
		if not self.params['checkmask']:
			self.app.panel.openImageFile(imgpath)
		else:
			self.showAssessedMask(imgpath,imgdata)


		#set vital stats
		self.app.vitalstats.SetLabel(
			" image name: "+imgdata['filename'])
		#run the picker
		self.app.MainLoop()

		#targets are copied to self.targets by app
		#assessment is copied to self.assess by app
		self.app.panel.openImageFile(None)
예제 #3
0
	def runManualPicker(self, imgdata):
		#reset targets
		self.targets = []

		#set the assessment status
		self.assessold = apDatabase.checkInspectDB(imgdata)
		self.assess = self.assessold
        # 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
        # This is checked in the preLoopFunctions().
		self.useAcceptedMask = False 

		#open new file
		imgname = imgdata['filename']+'.dwn.mrc'
		maskname = imgdata['filename']+'_mask.png'
		imagepath = os.path.join(self.params['rundir'],imgname)
		maskpath = os.path.join(self.params['rundir'],'masks',maskname)

		self.image = pyami.mrc.read(imagepath)

		if not os.path.isfile(maskpath):
			self.maskimg =  numpy.zeros(self.image.shape)
		#run the picker
		self.maskimg = apImage.PngToBinarryArray(maskpath)
예제 #4
0
	def runManualPicker(self, imgdata):
		#reset targets
		self.targets = {}
		for label in self.labels:
			self.app.panel.setTargets(label, [])
			self.targets[label] = []

		#set the assessment and viewer status
		self.assessold = apDatabase.checkInspectDB(imgdata)
		self.assess = self.assessold
		self.app.setAssessStatus()

		#open new file
		imgname = imgdata['filename']+'.dwn.mrc'
		imgpath = os.path.join(self.params['rundir'],imgname)
		if not self.params['checkMask']:
			self.app.panel.openImageFile(imgpath)
		else:
			self.showAssessedMask(imgpath,imgdata)

		targets = self.getParticlePicks(imgdata)
		if targets:
			for label in targets.keys():
				if label not in self.labels:
					self.labels.append(label)
					self.app.addLabelPicker(label)
			for label in self.labels:
				if label not in targets:
					targets[label] = []
				print "inserting ",len(targets[label]),"%s targets" % (label,)
				self.app.panel.setTargets(label, targets[label])
				self.app.panel.originaltargets[label] = targets[label]
		# labels may have changed, default selection is the first one
		if self.labels:
			self.app.panel.selectiontool.setTargeting(self.labels[0], True)

		#set vital stats
		self.app.vitalstats.SetLabel("Vital Stats: Image "+str(self.stats['count'])
			+" of "+str(self.stats['imagecount'])+", inserted "+str(self.stats['peaksum'])+" picks, "
			+" image name: "+imgdata['filename'])
		#run the picker
		self.app.MainLoop()

		#targets are copied to self.targets by app
		#assessment is copied to self.assess by app
		#parse and return the targets in peaktree form
		self.app.panel.openImageFile(None)
		peaktree=[]
		for label,targets in self.targets.items():
			for target in targets:	
				angle=None
				helixnum=None
				if isinstance(target, leginon.gui.wx.TargetPanelTools.StatsTarget):
					t = target.stats
					if t.has_key('angle'):
						angle = target.stats['angle']
					if t.has_key('helixnum'):
						helixnum = target.stats['helixnum']
				peaktree.append(self.XY2particle(target.x, target.y, angle, helixnum, label))

		# if any peak has an angle, then remove all peaks that do not have an angle
		#if peaktree:
		#	def hasangle(x):
		#		try:
		#			return 'angle' in x
		#		except:
		#			return False
		#	haveangles = map(hasangle, peaktree)
		#	anyangles = reduce(operator.or_, haveangles)
		#	if anyangles:	
		#		before = len(peaktree)	
		#		peaktree = filter(hasangle, peaktree)
		#		after = len(peaktree)
		#		diff = before - after
		#		apDisplay.printWarning("Removed %d particles with no angle"%(diff))

		return peaktree