def getStackParticleEulersForIteration(self, stackPart):
		"""
		find the eulers assigned to a stack particle
		during a refinement.  This function will first
		find the particle id for the given stack particle,
		then find its position in the reference stack, and
		will get the eulers for that particle in the recon
		
		assumes recon with FREALIGN
		"""

		# get stack particle id
		stackPartId = stackPart.dbid
		partId = stackPart['particle'].dbid

		# find particle in reference stack
		refStackId = apStack.getStackIdFromIterationId(self.params['reconiterid'], msg=False)
		refStackPart = apStack.getStackParticleFromParticleId(partId, refStackId)

		if not refStackPart:
			apDisplay.printWarning('No classification for stack particle %d in reconstruction iteration id: %d' % (refStackId, self.params['reconiterid']))
			self.noClassification += 1
			if self.noClassification > (float(params['last'])*0.10):
				apDisplay.printError('More than 10% of the particles have no classification, use a different reference reconstruction')
			eulerDict = {
				'psi': 0.0,
				'theta': 0.0, 
				'phi': 0.0, 
				'shiftx': 0.0,
				'shifty': 0.0,
				}
			return eulerDict

		refIterData = appiondata.ApRefineIterData.direct_query(self.params['reconiterid'])
		if refStackPart.dbid != stackPartId:
			self.mismatch += 1
		refinePartQuery = appiondata.ApRefineParticleData()
		refinePartQuery['particle'] = refStackPart
		refinePartQuery['refineIter'] = refIterData
		refinePartDatas = refinePartQuery.query()
		refinePartData = refinePartDatas[0]
		emanEulerDict = {
			'alt': refinePartData['euler1'],
			'az': refinePartData['euler2'], 
			'phi': refinePartData['euler3'], 
			'shiftx': refinePartData['shiftx'],
			'shifty': refinePartData['shifty'],
			'mirror': refinePartData['mirror'],
		}
	
		eulerDict = apFrealign.convertAppionEmanEulersToFrealign(emanEulerDict, self.symmetryName)
		eulerDict['shiftx'] = emanEulerDict['shiftx']*self.params['bin']
		eulerDict['shifty'] = emanEulerDict['shifty']*self.params['bin']
		if refinePartData['mirror'] is True:
			eulerDict['shiftx'] *= -1
		return eulerDict
예제 #2
0
def getStackParticleEulersForIteration(params, pnum):
    """
        find the eulers assigned to a stack particle
        during a refinement.  This function will first
        find the particle id for the given stack particle,
        then find its position in the reference stack, and
        will get the eulers for that particle in the recon
        """

    # get stack particle id
    stackp = apStack.getStackParticle(params['stackid'], pnum)
    particleid = stackp['particle'].dbid

    # find particle in reference stack
    refstackid = apStack.getStackIdFromIterationId(params['reconiterid'],
                                                   msg=False)
    refstackp = apStack.getStackParticleFromParticleId(particleid,
                                                       refstackid,
                                                       nodie=True)
    if not refstackp:
        apDisplay.printWarning(
            'No classification for stack particle %d in reconstruction iteration id: %d'
            % (pnum, params['reconiterid']))
        params['noClassification'] += 1
        if params['noClassification'] > (float(params['last']) * 0.10):
            apDisplay.printError(
                'More than 10% of the particles have no classification, use a different reference reconstruction'
            )
        pclass = {}
        pclass['eulers'] = {}
        pclass['eulers']['euler1'] = 0.0
        pclass['eulers']['euler2'] = 0.0
        pclass['inplane_rotation'] = 0.0
        pclass['mirror'] = False
        pclass['shiftx'] = 0.0
        pclass['shifty'] = 0.0
    else:
        pclassq = appiondata.ApRefineParticleData()
        pclassq['particle'] = refstackp
        pclassq['refineIter'] = appiondata.ApRefineIterData.direct_query(
            params['reconiterid'])
        pclass = pclassq.query()
        pclass = pclass[0]

    params['eman_orient'] = {}
    params['eman_orient']['alt'] = pclass['euler1']
    params['eman_orient']['az'] = pclass['euler2']
    params['eman_orient']['phi'] = pclass['euler3']

    params['eman_orient']['mirror'] = pclass['mirror']
    params['eman_orient']['shiftx'] = pclass['shiftx']
    params['eman_orient']['shifty'] = pclass['shifty']

    return params
def getStackParticleEulersForIteration(params,pnum):
        """
        find the eulers assigned to a stack particle
        during a refinement.  This function will first
        find the particle id for the given stack particle,
        then find its position in the reference stack, and
        will get the eulers for that particle in the recon
        """

        # get stack particle id
        stackp = apStack.getStackParticle(params['stackid'],pnum)
        particleid = stackp['particle'].dbid

        # find particle in reference stack
        refstackid = apStack.getStackIdFromIterationId(params['reconiterid'],msg=False)
        refstackp = apStack.getStackParticleFromParticleId(particleid,refstackid, nodie=True)
        if not refstackp:
                apDisplay.printWarning('No classification for stack particle %d in reconstruction iteration id: %d' % (pnum, params['reconiterid']))
                params['noClassification']+=1
                if params['noClassification'] > (float(params['last'])*0.10):
                        apDisplay.printError('More than 10% of the particles have no classification, use a different reference reconstruction')
                pclass={}
                pclass['eulers']={}
                pclass['eulers']['euler1']=0.0
                pclass['eulers']['euler2']=0.0
                pclass['inplane_rotation']=0.0
                pclass['mirror']=False
                pclass['shiftx']=0.0
                pclass['shifty']=0.0
        else:
                pclassq = appiondata.ApRefineParticleData()
                pclassq['particle'] = refstackp
                pclassq['refineIter'] = appiondata.ApRefineIterData.direct_query(params['reconiterid'])
                pclass = pclassq.query()
                pclass=pclass[0]

        params['eman_orient']={}
        params['eman_orient']['alt']=pclass['euler1']
        params['eman_orient']['az']=pclass['euler2']
        params['eman_orient']['phi']=pclass['euler3']

        params['eman_orient']['mirror']=pclass['mirror']
        params['eman_orient']['shiftx']=pclass['shiftx']
        params['eman_orient']['shifty']=pclass['shifty']

        return params
    def setupParticleParams(self):
        if self.params["reconiterid"] is not None:
            ### use parameters from previous reconstruction
            self.iflag = 1
            self.oldreconstackid = apStack.getStackIdFromIterationId(self.params["reconiterid"])
        elif self.params["dang"] is not None:
            ### use slow projection matching search to determine initial Eulers
            self.iflag = 3

        """
                if self.params['inpar'] is not None and os.path.isfile(self.params['inpar']):
                        ### use specified parameter file
                        paramfile = self.params['inpar']
                        apDisplay.printMsg("Using parameter file: "+paramfile)          
                        return paramfile
                """

        paramfile = self.generateParticleParams()
        return paramfile
    def setupParticleParams(self):
        if self.params['reconiterid'] is not None:
            ### use parameters from previous reconstruction
            self.iflag = 1
            self.oldreconstackid = apStack.getStackIdFromIterationId(
                self.params['reconiterid'])
        elif self.params['dang'] is not None:
            ### use slow projection matching search to determine initial Eulers
            self.iflag = 3
        """
                if self.params['inpar'] is not None and os.path.isfile(self.params['inpar']):
                        ### use specified parameter file
                        paramfile = self.params['inpar']
                        apDisplay.printMsg("Using parameter file: "+paramfile)          
                        return paramfile
                """

        paramfile = self.generateParticleParams()
        return paramfile
예제 #6
0
    def getStackParticleEulersForIteration(self, stackPart):
        """
		find the eulers assigned to a stack particle
		during a refinement.  This function will first
		find the particle id for the given stack particle,
		then find its position in the reference stack, and
		will get the eulers for that particle in the recon
		
		assumes recon with FREALIGN
		"""

        # get stack particle id
        stackPartId = stackPart.dbid
        partId = stackPart['particle'].dbid

        # find particle in reference stack
        refStackId = apStack.getStackIdFromIterationId(
            self.params['reconiterid'], msg=False)
        refStackPart = apStack.getStackParticleFromParticleId(
            partId, refStackId)

        if not refStackPart:
            apDisplay.printWarning(
                'No classification for stack particle %d in reconstruction iteration id: %d'
                % (refStackId, self.params['reconiterid']))
            self.noClassification += 1
            if self.noClassification > (float(params['last']) * 0.10):
                apDisplay.printError(
                    'More than 10% of the particles have no classification, use a different reference reconstruction'
                )
            eulerDict = {
                'psi': 0.0,
                'theta': 0.0,
                'phi': 0.0,
                'shiftx': 0.0,
                'shifty': 0.0,
            }
            return eulerDict

        refIterData = appiondata.ApRefineIterData.direct_query(
            self.params['reconiterid'])
        if refStackPart.dbid != stackPartId:
            self.mismatch += 1
        refinePartQuery = appiondata.ApRefineParticleData()
        refinePartQuery['particle'] = refStackPart
        refinePartQuery['refineIter'] = refIterData
        refinePartDatas = refinePartQuery.query()
        refinePartData = refinePartDatas[0]
        emanEulerDict = {
            'alt': refinePartData['euler1'],
            'az': refinePartData['euler2'],
            'phi': refinePartData['euler3'],
            'shiftx': refinePartData['shiftx'],
            'shifty': refinePartData['shifty'],
            'mirror': refinePartData['mirror'],
        }

        eulerDict = apFrealign.convertAppionEmanEulersToFrealign(
            emanEulerDict, self.symmetryName)
        eulerDict['shiftx'] = emanEulerDict['shiftx'] * self.params['bin']
        eulerDict['shifty'] = emanEulerDict['shifty'] * self.params['bin']
        if refinePartData['mirror'] is True:
            eulerDict['shiftx'] *= -1
        return eulerDict