Esempio n. 1
0
	def getParticleParamsData(self):
		tiltparamsq = appiondata.ApTiltAlignParamsData()
		tiltparamsq['output_type'] = self.params['outtype']
		if self.params['pickrunids'] is not None:
			self.params['pickrunidlist'] = self.params['pickrunids'].split(",")
			tiltparamsq['oldselectionrun'] = apParticle.getSelectionRunDataFromID(self.params['pickrunidlist'][0])
		return tiltparamsq
	def start(self):
		sessionname = self.params['sessionname']
		runname = self.params['runname']
		preset = self.params['preset']

		sessionq = leginondata.SessionData(name=sessionname)
		presetq=leginondata.PresetData(name=preset)
		imgquery = leginondata.AcquisitionImageData()
		imgquery['preset']  = presetq
		imgquery['session'] = sessionq
		imgtree = imgquery.query(readimages=False)
		partq = appiondata.ApContourData()
		sessiond = sessionq.query()
		selectionid = apParticle.getSelectionIdFromName(runname, sessionname)
		if not selectionid:
			apDisplay.printWarning('No Object Tracing Run found in database, Skipping.......')
			return
		selectionrundata = apParticle.getSelectionRunDataFromID(selectionid)


		file = open('contourpickerData-' + sessionname + '.txt','w')
		file.write('session_id ' + runname + '\n')
		file.write('usr_id ' + os.getlogin() + '\n')
		file.write('experiment_name ' + sessionname + '\n')
		file.write('experiment_description ' + sessiond[0]['comment'].strip() + '\n')
		file.write('nimages ' + str(len(imgtree)) + '\n')

		for imgdata in imgtree:
			file.write('START_IMAGE' + '\n')
			partq['image'] = imgdata
			partq['selectionrun'] = selectionrundata
			partd = partq.query()
			if len(partd)>0:
				file.write('image_refID ' + str(partd[0]['image'].dbid) + '\n') 
			file.write('image_name ' + imgdata['filename'] + '\n') 
			if len(partd)>0:
				file.write('time_roi ' + str(partd[0].timestamp) + '\n') 
			#file.write('time_roi ' + partd[0]['DEF_timestamp'] + '\n') 
			file.write('dfac = 1\n')
			maxversion = 0
			numparticles = 0
			for part in partd:
				if int(part['version'])>maxversion:
					maxversion = int(part['version'])
			for part in partd:
				if int(part['version'])==maxversion:
					numparticles+=1
			file.write('version_id ' + str(maxversion) + '\n')
			file.write('ncontours ' + str(numparticles) + '\n')
			pointq = appiondata.ApContourPointData()
			for part in partd:
				if int(part['version'])==maxversion:
			#		file.write('contour_number ' + )
					file.write('method_used ' + part['method'] + ' ')
					pointq['contour'] = part
					pointd = pointq.query()
					for point in pointd:
						file.write(str(point['x']) + ',' + str(point['y']) + ';')
					file.write('\n')
			file.write('END_IMAGE' + '\n')
Esempio n. 3
0
	def getParticleParamsData(self):
		manparamsq=appiondata.ApManualParamsData()
		manparamsq['trace'] = self.trace
		if self.params['helicalstep'] is not None:
			manparamsq['helicalstep'] = self.params['helicalstep']
		manparamsq['diam'] = self.params['diam']
		if self.params['pickrunid'] is not None:
			manparamsq['oldselectionrun'] = apParticle.getSelectionRunDataFromID(self.params['pickrunid'])
		return manparamsq
Esempio n. 4
0
	def getParticlePicks(self, imgdata):
		if not self.params['pickrunid']:
			if not self.params['pickrunname']:
				return []
			self.params['pickrunid'] = apParticle.getSelectionRun(imgdata, self.params['pickrunname'])
		if not self.params['pickrunname']:
			rundata = apParticle.getSelectionRunDataFromID(self.params['pickrunid'])
			self.params['pickrunname'] = rundata['name']
		particles = apParticle.getParticles(imgdata, self.params['pickrunid'])
		targets = self.particlesToTargets(particles)
		return targets
    def preLoopFunctions(self):
        self.is_dd_frame = False
        self.is_dd_stack = False
        self.is_dd = False
        self.checkIsDD()
        self.batchboxertimes = []
        self.ctftimes = []
        self.mergestacktimes = []
        self.meanreadtimes = []
        self.insertdbtimes = []
        self.noimages = False
        self.totalpart = 0
        self.selectiondata = None
        # Different class needed depending on if ddstack is specified or available
        if self.is_dd:
            from appionlib import apDDprocess
        if self.is_dd_frame:
            apDisplay.printMsg('DD Frame Processing')
            self.dd = apDDprocess.initializeDDFrameprocess(
                self.params['sessionname'])
            self.dd.setUseGS(self.params['useGS'])
        if self.is_dd_stack:
            apDisplay.printMsg('DD Stack Processing')
            self.dd = apDDprocess.DDStackProcessing()

        if len(self.imgtree) == 0:
            apDisplay.printWarning("No images were found to process")
            self.noimages = True
            # Still need to set attributes if waiting for more images
            if not self.params['wait']:
                return
        if self.params['selectionid'] is not None:
            self.selectiondata = apParticle.getSelectionRunDataFromID(
                self.params['selectionid'])
            if self.params['particlelabel'] == 'fromtrace':
                if (not self.selectiondata['manparams']
                        or not self.selectiondata['manparams']['trace']):
                    apDisplay.printError(
                        "Can not use traced object center to extract boxed area without tracing"
                    )
                else:
                    self.params['particlelabel'] = '_trace'
        self.checkPixelSize()
        self.existingParticleNumber = 0
        self.setStartingParticleNumber()
        apDisplay.printMsg("Starting at particle number: " +
                           str(self.particleNumber))

        if self.params[
                'partlimit'] is not None and self.particleNumber > self.params[
                    'partlimit']:
            apDisplay.printError(
                "Number of particles in existing stack already exceeds limit!")
        self.logpeaks = 2
	def preLoopFunctions(self):
		self.is_dd_frame = False
		self.is_dd_stack = False
		self.is_dd = False
		self.checkIsDD()
		self.batchboxertimes = []
		self.ctftimes = []
		self.mergestacktimes = []
		self.meanreadtimes = []
		self.insertdbtimes = []
		self.noimages = False
		self.totalpart = 0
		self.selectiondata = None
		# Different class needed depending on if ddstack is specified or available
		if self.is_dd:
			from appionlib import apDDprocess
		if self.is_dd_frame:
			apDisplay.printMsg('DD Frame Processing')
			self.dd = apDDprocess.initializeDDFrameprocess(self.params['sessionname'])
			self.dd.setUseGS(self.params['useGS'])
		if self.is_dd_stack:
			apDisplay.printMsg('DD Stack Processing')
			self.dd = apDDprocess.DDStackProcessing()

		if len(self.imgtree) == 0:
			apDisplay.printWarning("No images were found to process")
			self.noimages = True
			# Still need to set attributes if waiting for more images
			if not self.params['wait']:
				return
		if self.params['selectionid'] is not None:
			self.selectiondata = apParticle.getSelectionRunDataFromID(self.params['selectionid'])
			if self.params['particlelabel'] == 'fromtrace':
				if (not self.selectiondata['manparams'] or not self.selectiondata['manparams']['trace']):
					apDisplay.printError("Can not use traced object center to extract boxed area without tracing")
				else:
					self.params['particlelabel'] = '_trace'
		self.checkPixelSize()
		self.existingParticleNumber=0
		self.setStartingParticleNumber()
		apDisplay.printMsg("Starting at particle number: "+str(self.particleNumber))

		if self.params['partlimit'] is not None and self.particleNumber > self.params['partlimit']:
			apDisplay.printError("Number of particles in existing stack already exceeds limit!")
		self.logpeaks = 2
Esempio n. 7
0
    def start(self):
        sessionname = self.params['sessionname']
        runname = self.params['runname']
        preset = self.params['preset']

        sessionq = leginondata.SessionData(name=sessionname)
        presetq = leginondata.PresetData(name=preset)
        imgquery = leginondata.AcquisitionImageData()
        imgquery['preset'] = presetq
        imgquery['session'] = sessionq
        imgtree = imgquery.query(readimages=False)
        partq = appiondata.ApContourData()
        sessiond = sessionq.query()
        selectionid = apParticle.getSelectionIdFromName(runname, sessionname)
        if not selectionid:
            apDisplay.printWarning(
                'No Object Tracing Run found in database, Skipping.......')
            return
        selectionrundata = apParticle.getSelectionRunDataFromID(selectionid)

        file = open('contourpickerData-' + sessionname + '.txt', 'w')
        file.write('session_id ' + runname + '\n')
        file.write('usr_id ' + os.getlogin() + '\n')
        file.write('experiment_name ' + sessionname + '\n')
        file.write('experiment_description ' + sessiond[0]['comment'].strip() +
                   '\n')
        file.write('nimages ' + str(len(imgtree)) + '\n')

        for imgdata in imgtree:
            file.write('START_IMAGE' + '\n')
            partq['image'] = imgdata
            partq['selectionrun'] = selectionrundata
            partd = partq.query()
            if len(partd) > 0:
                file.write('image_refID ' + str(partd[0]['image'].dbid) + '\n')
            file.write('image_name ' + imgdata['filename'] + '\n')
            if len(partd) > 0:
                file.write('time_roi ' + str(partd[0].timestamp) + '\n')
            #file.write('time_roi ' + partd[0]['DEF_timestamp'] + '\n')
            file.write('dfac = 1\n')
            maxversion = 0
            numparticles = 0
            for part in partd:
                if int(part['version']) > maxversion:
                    maxversion = int(part['version'])
            for part in partd:
                if int(part['version']) == maxversion:
                    numparticles += 1
            file.write('version_id ' + str(maxversion) + '\n')
            file.write('ncontours ' + str(numparticles) + '\n')
            pointq = appiondata.ApContourPointData()
            for part in partd:
                if int(part['version']) == maxversion:
                    #		file.write('contour_number ' + )
                    file.write('method_used ' + part['method'] + ' ')
                    pointq['contour'] = part
                    pointd = pointq.query()
                    for point in pointd:
                        file.write(
                            str(point['x']) + ',' + str(point['y']) + ';')
                    file.write('\n')
            file.write('END_IMAGE' + '\n')