當前位置: 首頁>>代碼示例>>Python>>正文


Python EMAN.readImages方法代碼示例

本文整理匯總了Python中EMAN.readImages方法的典型用法代碼示例。如果您正苦於以下問題:Python EMAN.readImages方法的具體用法?Python EMAN.readImages怎麽用?Python EMAN.readImages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在EMAN的用法示例。


在下文中一共展示了EMAN.readImages方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: alignParticlesInLST

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
def alignParticlesInLST(lstfile,outstack):
        import EMAN
        ### create a stack of particles aligned according to an LST file
        images=EMAN.readImages(lstfile,-1,-1,0)
        for i in images:
                i.edgeNormalize()
                i.rotateAndTranslate()
                if i.isFlipped():
                        i.hFlip()
                i.writeImage(outstack,-1)
開發者ID:,項目名稱:,代碼行數:12,代碼來源:

示例2: alignParticlesInLST

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
def alignParticlesInLST(lstfile,outstack):
        import EMAN
        ### create a stack of particles aligned according to an LST file
        apDisplay.printMsg("aligning particles in '%s', saving to stack: %s"%(lstfile,outstack))        
        images=EMAN.readImages(lstfile,-1,-1,0)
        for i in images:
                i.edgeNormalize()
                i.rotateAndTranslate()
                if i.isFlipped():
                        i.hFlip()
                i.writeImage(outstack,-1)
開發者ID:kraftp,項目名稱:Leginon-Feature-Detection-Modification,代碼行數:13,代碼來源:apEMAN.py

示例3: main

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
def main():
	if len(sys.argv) != 3:
		print "Usage::  %s <input particles file name> <output particles file name>"%(sys.argv[0])
		sys.exit(-1)
	input = sys.argv[1]
	output = sys.argv[2]
	
	stack=EMAN.readImages(input,-1,-1)
	i = 0
	for image in stack:
		print "Working on image %s"%(i)
		new_image = speckle_filter(image)
		new_image.writeImage(output,i)
		i=i+1
開發者ID:triciatricia,項目名稱:SIMPLE,代碼行數:16,代碼來源:speckle_filter.py

示例4: makeClassAverages

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
def makeClassAverages(lst, outputstack,e,mask):
        import EMAN
        #align images in class
        print "creating class average from",lst,"to",outputstack
        images=EMAN.readImages(lst,-1,-1,0)
        for image in images:
                image.rotateAndTranslate()
                if image.isFlipped():
                        image.hFlip()

        #make class average
        avg=EMAN.EMData()
        avg.makeMedian(images)

        #write class average
        avg.setRAlign(e)
        avg.setNImg(len(images))
        avg.applyMask(mask,0)
        avg.writeImage(outputstack,-1)
開發者ID:kraftp,項目名稱:Leginon-Feature-Detection-Modification,代碼行數:21,代碼來源:apEMAN.py

示例5: makeClassAverages

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
def makeClassAverages(lst, outputstack, classdata, params):
    # align images in class
    images = EMAN.readImages(lst, -1, -1, 0)
    for image in images:
        image.rotateAndTranslate()
        if image.isFlipped():
            image.hFlip()

    # make class average
    avg = EMAN.EMData()
    avg.makeMedian(images)

    # write class average
    e = EMAN.Euler()
    alt = classdata["euler1"] * math.pi / 180
    az = classdata["euler2"] * math.pi / 180
    phi = 0.0
    e.setAngle(alt, az, phi)
    avg.setRAlign(e)
    avg.setNImg(len(images))
    avg.applyMask(params["mask"], 0)
    avg.writeImage(outputstack, -1)
開發者ID:kraftp,項目名稱:Leginon-Feature-Detection-Modification,代碼行數:24,代碼來源:makegoodaverages.py

示例6: makeClassAverages

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
        def makeClassAverages(self, classlist, outputstack, classdata, maskrad):
                #align images in class
                #print classlist
                images = EMAN.readImages(classlist, -1, -1, 0)
                for image in images:
                        image.rotateAndTranslate()
                        if image.isFlipped():
                                image.hFlip()

                #make class average
                avg = EMAN.EMData()
                avg.makeMedian(images)

                #write class average
                e = EMAN.Euler()
                alt = classdata['euler1']*math.pi/180
                az  = classdata['euler2']*math.pi/180
                phi = 0.0 #classdata['euler3']*math.pi/180
                e.setAngle(alt, az, phi)
                avg.setRAlign(e)
                avg.setNImg(len(images))
                avg.applyMask(maskrad, 0)

                avg.writeImage(outputstack,-1)
開發者ID:kraftp,項目名稱:Leginon-Feature-Detection-Modification,代碼行數:26,代碼來源:satAverage.py

示例7: len

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
#!/usr/bin/env python
import EMAN
import sys
from sys import argv
import os
import math

RD = 180.0 / math.pi

if len(argv) < 3:
    print "fsctest.py <refs> <ref #> <ptcl file> <ptcl #>"
    sys.exit(1)

refs = EMAN.readImages(argv[1], -1, -1)
ptcl = EMAN.EMData()
ptcl.readImage(argv[3], int(argv[4]))
ptcl.edgeNormalize()
ptclf = ptcl.copy(0, 0)
ptclf.vFlip()


for i in refs:
    i.normalize()

ali = ptcl.RTFAlign(refs[int(argv[2])], ptclf, 1)
ali.refineAlign(i)
fsc = (1.0 + ali.fscmp(refs[int(argv[2])], None)) * 500.0
print fsc
開發者ID:,項目名稱:,代碼行數:30,代碼來源:

示例8: parseInput

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
if __name__== '__main__':
	# write command & time to emanlog if exists:
	if os.path.exists('refine.log'):
		cmd = string.join(sys.argv,' ')
		apEMAN.writeEMANTime('refine.log',cmd)
	#Parse inputs
	args=sys.argv[1:]
	params=createDefaults()
	parseInput(args,params)
	
	if params['coranmask'] is None:
		params['coranmask'] = params['mask']
		
	#Determine box size
	tmpimg=EMAN.readImages('start.hed',1,1)
	params['boxsize']=tmpimg[0].xSize()

	#Set up for coran
	params['corandir']=params['corandir']+str(params['iter'])
	if os.path.exists(params['corandir']):
		print "WARNING!!! %s exists and is being overwritten" % params['corandir']
		shutil.rmtree(params['corandir'])
		os.mkdir(params['corandir'])
	else:
		os.mkdir(params['corandir'])
	classfile='cls.'+str(params['iter'])+'.tar'
	shutil.copy(classfile,os.path.join(params['corandir'],classfile))
	shutil.copy('proj.hed',os.path.join(params['corandir'],'proj.hed'))
	shutil.copy('proj.img',os.path.join(params['corandir'],'proj.img'))
	os.chdir(params['corandir'])
開發者ID:leschzinerlab,項目名稱:myami-3.2-freeHand,代碼行數:32,代碼來源:coran_for_cls.py

示例9: createClassAverages

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
def createClassAverages(stack,projs,apmq,numprojs,boxsz,outclass="classes",rotated=False,shifted=False,dataext=".spi"):
	"""
	creates EMAN-style class average file "classes.hed" & "classes.img"
	and variance files "variances.hed" & "variances.img"
	from spider classification
	"""
	apFile.removeFile(outclass)
	outf=spyder.fileFilter(outclass)
	outvf="tmpvar"
	apmqlist = readDocFile(apmq)
	mySpi = spyder.SpiderSession(dataext=dataext, logo=False, log=False)

	# create file containing the number of particles matched to each projection
	mySpi.toSpiderQuiet(
		"VO MQ",
		"0.0",
		spyder.fileFilter(apmq),
		str(numprojs),
		"cls*****",
		"numinclass",
	)
	mySpi.close()
	os.remove("numinclass%s" % dataext)

	# create class average file
	mySpi = spyder.SpiderSession(dataext=dataext, logo=False, log=False)
	for i in range(0,numprojs):
		clsfile = readDocFile("cls%05d%s" % (i+1,dataext))
		if clsfile == []:
			apDisplay.printMsg("class %d has no particles" %(i+1))
			mySpi.toSpiderQuiet("BL","%[email protected]%d" % (outf,(i+1)),"(%d,%d)" % (boxsz,boxsz),"N","(0.0)",)
			mySpi.toSpiderQuiet("BL","%[email protected]%d" % (outvf,(i+1)),"(%d,%d)" % (boxsz,boxsz),"N","(0.0)",)
		else:
			mySpi.toSpiderQuiet("DE","[email protected]")
			mySpi.toSpiderQuiet("MS","[email protected]","%d,%d,1" % (boxsz,boxsz), str(len(clsfile)))
			for p in range(0,len(clsfile)):
				mySpi.toSpiderQuiet("DE","_1")
				# get the particle
				part = int(float(clsfile[p][2]))-1
				pimg = spyder.fileFilter(stack)+"@%d"%(part+1)
				
				rot=float(apmqlist[part][4])
				shx=float(apmqlist[part][5])
				shy=float(apmqlist[part][6])
				if shifted is True:
					shx=0
					shy=0
				if rotated is True:
					rot=0
				p_out="[email protected]%d" % (p+1)
				rotAndShiftImg(
					pimg,
					"_1",
					rot,
					shx,
					shy,
					inMySpi=mySpi
				)
				# mirror
				if int(float(apmqlist[part][2])) < 0:
					mirrorImg("_1",p_out,inMySpi=mySpi)
				else:
					mySpi.toSpiderQuiet("CP","_1",p_out)
			if len(clsfile) == 1:
				mySpi.toSpiderQuiet("CP","[email protected]","%[email protected]%d" % (outf,(i+1)))
				mySpi.toSpiderQuiet("BL","%[email protected]%d" % (outvf,(i+1)),"(%d,%d)" % (boxsz,boxsz),"N","(0.0)",)
			else:
				mySpi.toSpiderQuiet("AS R","[email protected]*****","1-%d" % len(clsfile), "A","%[email protected]%d" % (outf,(i+1)),"%[email protected]%d" % (outvf,i+1))
	mySpi.close()

	# convert the class averages to EMAN class averages
	# read classes & projections for EMAN classes output
	if os.path.exists('variances.hed'):
		os.remove('variances.hed')
	if os.path.exists('variances.img'):
		os.remove('variances.img')
	if os.path.exists('classes.hed'):
		os.remove('classes.hed')
	if os.path.exists('classes.img'):
		os.remove('classes.img')
	### I would prefer to use apImagicFile.readImagic, writeImagic
	variances = EMAN.readImages(outvf+dataext,-1,-1,0)
	averages = EMAN.readImages(outf+dataext,-1,-1,0)
	projections=EMAN.readImages(projs,-1,-1,0)
	for i in range (0,numprojs):
		# copy projection to class average file
		projections[i].writeImage('classes.hed')
		projections[i].writeImage('variances.hed')
		# get num of particles in class
		clsfile=readDocFile("cls%05d%s" % (i+1,dataext))
		averages[i].setNImg(len(clsfile))
		averages[i].writeImage('classes.hed',-1)
		variances[i].setNImg(len(clsfile))
		variances[i].writeImage('variances.hed',-1)
		os.remove("cls%05d%s" % (i+1,dataext))
	os.remove(outf+dataext)
	return
開發者ID:leschzinerlab,項目名稱:myami-3.2-freeHand,代碼行數:99,代碼來源:refine.py

示例10: int

# 需要導入模塊: import EMAN [as 別名]
# 或者: from EMAN import readImages [as 別名]
for i in argv[1:]:
    s = i.split("=")

    if s[0] == "classes":
        Ncls = int(s[1])
    elif s[0] == "average":
        averageout = s[1]
    elif s[0] == "clsfiles":
        clsfiles = 1
    elif s[0] == "listout":
        listout = s[1]
    elif s[0] == "nosingle":
        nosingle = 1
    elif s[0] == "stack":
        data = EMAN.readImages(s[1], -1, -1)
        stackname = s[1]
    elif s[0] == "list":
        fin = open(s[1], "r")
        fsp = fin.readlines()
        fin.close()
        for i in fsp:
            x = EMAN.EMData()
            x.readImage(i.strip())
            data.append(x)
    else:
        print "Unknown argument ", i
        exit(1)

if len(data) == 0:
    print "No data to classify. Please specify stack= or list=."
開發者ID:triciatricia,項目名稱:SIMPLE,代碼行數:32,代碼來源:classifykmeans.py


注:本文中的EMAN.readImages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。