Пример #1
0
def getAverageAzimuthFromSeries(imgtree):
    # this somewhat duplicates the getDefaultAzimuthFromLegionon but is slightly different

    predict1 = apDatabase.getPredictionDataForImage(imgtree[0])
    predict2 = apDatabase.getPredictionDataForImage(imgtree[-1])
    try:
        try:
            phi1 = predict1[0]['predicted position']['phi'] * 180 / math.pi
            phi2 = predict2[0]['predicted position']['phi'] * 180 / math.pi
        except:  #Tilt-series was uploaded
            phi1 = phi2 = imgtree[0]['scope']['stage position']['phi']
    except:  #Phi was not recorded
        apDisplay.printWarning(
            "Azimuth was not recorded. Setting azimuth to -90 degrees, relative to the x-axis."
        )
        phi1 = phi2 = 0

    ###Azimuth is determined from phi. In protomo tilt axis is measured from x where phi is from y
    ###Note there is a mirror between how Leginon reads images vs how protomo does
    azimuth = -(
        90 - ((phi1 + phi2) / 2)
    )  # Made negative because now images are y-flipped because Protomo
    apDisplay.printMsg(
        ("Azimuth is %f (relative to y-flipped images)" % azimuth))
    return azimuth
def getAverageAzimuthFromSeries(imgtree):
        # this somewhat duplicates the getDefaultAzimuthFromLegionon but is slightly different
        
        predict1=apDatabase.getPredictionDataForImage(imgtree[0])
        predict2=apDatabase.getPredictionDataForImage(imgtree[-1])
        phi1=predict1[0]['predicted position']['phi']*180/math.pi
        phi2=predict2[0]['predicted position']['phi']*180/math.pi
        
        ###Azimuth is determined from phi. In protomo tilt axis is measured from x where phi is from y
        ###Note there is a mirror between how Leginon reads images vs how protomo does
        azimuth=90-((phi1+phi2)/2)
        apDisplay.printMsg(("Azimuth is %f" % azimuth))
        return azimuth
def getAverageAzimuthFromSeries(imgtree):
    # this somewhat duplicates the getDefaultAzimuthFromLegionon but is slightly different

    predict1 = apDatabase.getPredictionDataForImage(imgtree[0])
    predict2 = apDatabase.getPredictionDataForImage(imgtree[-1])
    phi1 = predict1[0]['predicted position']['phi'] * 180 / math.pi
    phi2 = predict2[0]['predicted position']['phi'] * 180 / math.pi

    ###Azimuth is determined from phi. In protomo tilt axis is measured from x where phi is from y
    ###Note there is a mirror between how Leginon reads images vs how protomo does
    azimuth = 90 - ((phi1 + phi2) / 2)
    apDisplay.printMsg(("Azimuth is %f" % azimuth))
    return azimuth
Пример #4
0
def getAverageAzimuthFromSeries(imgtree):
    # this somewhat duplicates the getDefaultAzimuthFromLegionon but is slightly different

    predict1 = apDatabase.getPredictionDataForImage(imgtree[0])
    predict2 = apDatabase.getPredictionDataForImage(imgtree[-1])
    try:
        try:
            phi1 = predict1[0]["predicted position"]["phi"] * 180 / math.pi
            phi2 = predict2[0]["predicted position"]["phi"] * 180 / math.pi
        except:  # Tilt-series was uploaded
            phi1 = phi2 = imgtree[0]["scope"]["stage position"]["phi"]
    except:  # Phi was not recorded
        apDisplay.printWarning("Azimuth was not recorded. Setting azimuth to -90 degrees, relative to the x-axis.")
        phi1 = phi2 = 0

        ###Azimuth is determined from phi. In protomo tilt axis is measured from x where phi is from y
        ###Note there is a mirror between how Leginon reads images vs how protomo does
    azimuth = -(90 - ((phi1 + phi2) / 2))  # Made negative because now images are y-flipped because Protomo
    apDisplay.printMsg(("Azimuth is %f (relative to y-flipped images)" % azimuth))
    return azimuth
	zerotilts=[]
	
	for n in range(len(imgtree)):
		print "determining parameters for", imgtree[n]['filename']
		imdict={}
		imdictkey=n+1
		
		#assign parameters to ptdict
		tilt=imgtree[n]['scope']['stage position']['a']*180/math.pi
		imdict['tilt']=tilt
		origx=imgtree[n]['camera']['dimension']['x']/2
		origy=imgtree[n]['camera']['dimension']['y']/2
		imdict['rotation']=0
		
		#determine shifts for each image from correlation during data collection
		predictdata=apDatabase.getPredictionDataForImage(imgtree[n])
		neworigx=origx-predictdata[0]['correlation']['x']
		neworigy=origy+predictdata[0]['correlation']['y']
		imdict['x']=neworigx
		imdict['y']=neworigy
		
		#set up names
		imgpath=imgtree[n]['session']['image path']
		presetname=imgtree[n]['preset']['name']
		imgprefix=presetname+imgtree[n]['filename'].split(presetname)[-1]
		imgname=imgprefix+'.img'
		imdict['filename']=imgprefix
		
		#create symlinks to files
		if not os.path.exists(os.path.join(rawdir,imgname)):
			os.symlink(os.path.join(imgpath,imgtree[n]['filename']+'.mrc'),os.path.join(rawdir,imgname))
    zerotilts = []

    for n in range(len(imgtree)):
        print "determining parameters for", imgtree[n]['filename']
        imdict = {}
        imdictkey = n + 1

        #assign parameters to ptdict
        tilt = imgtree[n]['scope']['stage position']['a'] * 180 / math.pi
        imdict['tilt'] = tilt
        origx = imgtree[n]['camera']['dimension']['x'] / 2
        origy = imgtree[n]['camera']['dimension']['y'] / 2
        imdict['rotation'] = 0

        #determine shifts for each image from correlation during data collection
        predictdata = apDatabase.getPredictionDataForImage(imgtree[n])
        neworigx = origx - predictdata[0]['correlation']['x']
        neworigy = origy + predictdata[0]['correlation']['y']
        imdict['x'] = neworigx
        imdict['y'] = neworigy

        #set up names
        imgpath = imgtree[n]['session']['image path']
        presetname = imgtree[n]['preset']['name']
        imgprefix = presetname + imgtree[n]['filename'].split(presetname)[-1]
        imgname = imgprefix + '.img'
        imdict['filename'] = imgprefix

        #create symlinks to files
        if not os.path.exists(os.path.join(rawdir, imgname)):
            os.symlink(os.path.join(imgpath, imgtree[n]['filename'] + '.mrc'),