本文整理汇总了Python中xmipp.MetaData类的典型用法代码示例。如果您正苦于以下问题:Python MetaData类的具体用法?Python MetaData怎么用?Python MetaData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MetaData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: launchProjSubPlots
def launchProjSubPlots(self, selectedPlots):
''' Launch some plots for a Projection Matching protocol run '''
import numpy as np
_log = self.Log
xplotter=None
self._plot_count = 0
def doPlot(plotName):
return plotName in selectedPlots
file_name_tmp = join(self.CtfGroupDirectoryName, self.CtfGroupRootName) +'Info.xmd'
file_name = join(self.PrevRun.WorkingDir, file_name_tmp)
if exists(file_name):
auxMD = MetaData("[email protected]"+file_name)
self.NumberOfCtfGroups = auxMD.getValue(MDL_COUNT,auxMD.firstObject())
else:
self.NumberOfCtfGroups = 1
if doPlot('DisplayReference'):
for indexCtf in range(1, self.NumberOfCtfGroups+1):
file_name = self.getFilename('SubtractedStack', ctf=indexCtf)+'ref'
if exists(file_name):
try:
runShowJ(file_name)
except Exception, e:
showError("Error launching java app", str(e), self.master)
开发者ID:josegutab,项目名称:scipion,代码行数:30,代码来源:protocol_subtraction.py
示例2: summary
def summary(self):
message=ProtInitVolumeBase.summary(self)
message.append("RANSAC iterations: %d"%self.NRansac)
for n in range(self.NumVolumes):
fnBase='volumeProposed%05d'%n
fnRoot=self.workingDirPath(fnBase+".xmd")
if os.path.isfile(fnRoot):
md=MetaData(fnRoot)
if (md.size()< 5) :
message.append("Num of inliers for %s too small and equal to %d"%(fnRoot,md.size()))
message.append("Decrease the value of Inlier Threshold parameter and run again")
fnBase="ransac00000.xmd"
fnRoot=self.workingDirPath("tmp/"+fnBase)
if os.path.isfile(fnRoot):
md=MetaData(fnRoot)
if (md.size()< 5) :
message.append("Num of random samples too small and equal to %d"%(md.size()))
message.append("If the option Dimensionality reduction is on, increase the number of grids per dimension")
message.append("If the option Dimensionality reduction is off, increase the number of random samples")
if self.UseSA:
message.append("Simulated annealing used")
return message
开发者ID:josegutab,项目名称:scipion,代码行数:29,代码来源:protocol_initvolume_ransac.py
示例3: __init__
def __init__(self, scriptname, project):
XmippProtocol.__init__(self, protDict.ml2d.name, scriptname, project)
self.Import = 'from protocol_ml2d import *'
self.acquisionInfo = self.findAcquisitionInfo(self.ImgMd)
if not self.acquisionInfo is None:
md = MetaData(self.acquisionInfo)
self.SamplingRate = md.getValue(MDL_SAMPLINGRATE, md.firstObject())
开发者ID:josegutab,项目名称:scipion,代码行数:7,代码来源:protocol_ml2d.py
示例4: summary
def summary(self):
_, _, _, _, size = MetaDataInfo(self.ImgMd)
lines = ["Input images: [%s] (<%u>)" % (self.ImgMd, size)]
if self.DoMlf:
if self.DoCorrectAmplitudes:
suffix = "with CTF correction "
else:
suffix = "ignoring CTF effects "
lines.append("Using a ML in <Fourier-space> " + suffix)
if self.DoGenerateReferences:
lines.append("Number of references: <%d>" % self.NumberOfReferences)
else:
lines.append("Reference image(s): [%s]" % self.RefMd)
#logs = self.getFilename('iter_logs')
lastIter = lastIteration(self)
if lastIter > 0:#exists(logs):
logs = self.getFilename('iter_logs', iter=lastIter)
md = MetaData(logs)
id = md.lastObject()
#iteration = md.getValue(MDL_ITER, id)
lines.append("Last iteration: <%d>" % lastIter)
LL = md.getValue(MDL_LL, id)
lines.append("LogLikelihood: %f" % LL)
mdRefs = self.getFilename('iter_refs', iter=lastIter)
lines.append("Last classes: [%s]" % mdRefs)
return lines
开发者ID:josegutab,项目名称:scipion,代码行数:31,代码来源:protocol_ml2d.py
示例5: createOutput
def createOutput(self):
import glob
levelFiles = glob.glob(self._getExtraPath("results_classes_level*.xmd"))
if levelFiles:
levelFiles.sort()
lastLevelFile = levelFiles[-1]
setOfClasses = self._createSetOfClassesVol()
setOfClasses.setImages(self.inputVolumes.get())
readSetOfClassesVol(setOfClasses, lastLevelFile)
self._defineOutputs(outputClasses=setOfClasses)
self._defineSourceRelation(self.inputVolumes, self.outputClasses)
if self.generateAligned.get():
setOfVolumes = self._createSetOfVolumes()
fnAligned = self._getExtraPath("results_aligned.xmd")
self.runJob(
"xmipp_metadata_selfile_create",
"-p %s -o %s -s" % (self._getExtraPath("results_aligned.stk"), fnAligned),
)
md = MetaData(fnAligned)
md.addItemId()
md.write(fnAligned)
readSetOfVolumes(fnAligned, setOfVolumes)
volumeList = self.inputVolumes.get()
setOfVolumes.setSamplingRate(volumeList.getSamplingRate())
self._defineOutputs(alignedVolumes=setOfVolumes)
self._defineTransformRelation(self.inputVolumes, self.alignedVolumes)
开发者ID:denisfortun,项目名称:scipion,代码行数:27,代码来源:protocol_cltomo.py
示例6: validate
def validate(self):
errors = []
N1=getMdSize(self.Operand1)
Operation=self.Operation
checkDimensions=False
if Operation=='column' or Operation=='slice' or Operation=='row':
if not self.Operand2.isdigit():
errors.append('You should give a number for the column, slice or row')
elif Operation=='dot product':
if self.Operand2.isdigit():
errors.append('Second operand cannot be a number')
else:
checkDimensions=True
elif Operation=='plus' or Operation=='minus' or Operation=='multiply' or Operation=='divide' or Operation=='minimum' or \
Operation=='maximum':
if not self.Operand2.isdigit():
checkDimensions=True
if checkDimensions:
md1=MetaData(self.Operand1)
md2=MetaData(self.Operand2)
x1, y1, z1, _, _ = MetaDataInfo(md1)
x2, y2, z2, _, _ = MetaDataInfo(md2)
if x1!=x2 or y1!=y2 or z1!=z2:
errors.append("Image/Volume sizes in the two operands are not the same")
if md2.size()>1:
if md2.size()!=md1.size():
errors.append("The number of images/volumes in the two operands are not the same")
return errors
开发者ID:josegutab,项目名称:scipion,代码行数:28,代码来源:protocol_image_operate.py
示例7: getBestVolumes
def getBestVolumes(log,WorkingDir,NRansac,NumVolumes,UseAll):
volumes = []
inliers = []
for n in range(NRansac):
fnAngles = os.path.join(WorkingDir,"tmp/angles_ransac%05d"%n+".xmd")
md=MetaData("[email protected]"+fnAngles)
numInliers=md.getValue(MDL_WEIGHT,md.firstObject())
volumes.append(fnAngles)
inliers.append(numInliers)
index = sorted(range(inliers.__len__()), key=lambda k: inliers[k])
fnBestAngles = ''
threshold=getCCThreshold(WorkingDir)
i=NRansac-1
indx = 0
while i>=0 and indx<NumVolumes:
fnBestAngles = volumes[index[i]]
fnBestAnglesOut=os.path.join(WorkingDir,"volumeProposed%05d"%indx+".xmd")
copyFile(log,fnBestAngles,fnBestAnglesOut)
print("Best volume "+str(indx)+" = "+fnBestAngles)
if not UseAll:
runJob(log,"xmipp_metadata_utilities","-i %s -o %s --query select \"maxCC>%f \" --mode append" %(fnBestAnglesOut,fnBestAnglesOut,threshold))
if getMdSize(fnBestAnglesOut) > 0:
indx += 1
else:
indx += 1
i -= 1
# Remove unnecessary files
for n in range(NRansac):
fnAngles = os.path.join(WorkingDir,"tmp/angles_ransac%05d"%n+".xmd")
deleteFile(log, fnAngles)
开发者ID:josegutab,项目名称:scipion,代码行数:34,代码来源:protocol_initvolume_ransac.py
示例8: wizardBrowseCTF2
def wizardBrowseCTF2(gui, var):
error = None
vList = ['LowResolCutoff', 'HighResolCutoff']
freqs = gui.getVarlistValue(vList)
importRunName = gui.getVarValue('ImportRun')
prot = gui.project.getProtocolFromRunName(importRunName)
path = prot.WorkingDir
if path and exists(path):
mdPath = prot.getFilename('micrographs')
if exists(mdPath):
from xmipp import MetaData, MDL_MICROGRAPH
md = MetaData(mdPath)
if md.size():
image = md.getValue(MDL_MICROGRAPH, md.firstObject())
if image:
filterExt = "*" + splitext(image)[1]
value = gui.getVarValue('DownsampleFactor')
results = wizardHelperSetDownsampling(gui, var, path, filterExt, value, freqs, md)
if results:
gui.setVarlistValue(vList, results[1:])
else:
error = "Not micrograph found in metadata <%s>" % mdPath
#gui.setVarValue('LowResolCutoff', results[1])
#gui.setVarValue('HighResolCutoff', results[2])
else:
error = "Micrograph metadata <%s> is empty" % mdPath
else:
error = "Micrograph metadata <%s> doesn't exists" % mdPath
else:
error = "Import run <%s> doesn't exists" % str(path)
if error:
showWarning("Select Downsampling Wizard", error, gui.master)
return None
else:
return results
开发者ID:josegutab,项目名称:scipion,代码行数:35,代码来源:protlib_wizard.py
示例9: wizardDesignMask
def wizardDesignMask(gui, var):
selfile = gui.getVarValue('InSelFile')
##workingDir = getWorkingDirFromRunName(gui.getVarValue('RunName'))
from xmipp import MetaData, MDL_IMAGE
md = MetaData(selfile)
fnImg = md.getValue(MDL_IMAGE, md.firstObject())
#runShowJ(fnImg, extraParams="--mask_toolbar")
runMaskToolbar(fnImg)
开发者ID:josegutab,项目名称:scipion,代码行数:8,代码来源:protlib_wizard.py
示例10: mdFirstRow
def mdFirstRow(filename):
""" Create a MetaData but only read the first row.
This method should be used for validations of labels
or metadata size, but the full metadata is not needed.
"""
md = MetaData()
md.read(filename, 1)
return md
开发者ID:josegutab,项目名称:scipion,代码行数:9,代码来源:protlib_xmipp.py
示例11: extractDeformations
def extractDeformations(log, WorkingDir):
MD = MetaData(os.path.join(WorkingDir, "images.xmd"))
deformations = MD.getColumnValues(MDL_NMA)
fnDef = os.path.join(WorkingDir, "extra/deformations.txt")
fhDef = open(fnDef, "w")
for deformation in deformations:
for coef in deformation:
fhDef.write("%f " % coef)
fhDef.write("\n")
fhDef.close()
开发者ID:josegutab,项目名称:scipion,代码行数:10,代码来源:protocol_nma_alignment.py
示例12: runFineSearch
def runFineSearch(self, fnVol, dihedral, fnCoarse, fnFine, z0, zF, rot0, rotF, cylinderRadius, height):
md=MetaData(fnCoarse)
objId=md.firstObject()
rotInit=md.getValue(MDL_ANGLE_ROT,objId)
zInit=md.getValue(MDL_SHIFT_Z,objId)
args="-i %s --sym %s --localHelical %f %f -o %s -z %f %f 1 --rotHelical %f %f 1 "%(fnVol,self.getSymmetry(dihedral),
zInit,rotInit,fnFine,z0,zF,rot0,rotF)
if cylinderRadius>0:
args+=" --mask cylinder %d %d"%(-cylinderRadius,-height)
self.runJob('xmipp_volume_find_symmetry',args)
开发者ID:denisfortun,项目名称:scipion,代码行数:10,代码来源:xmipp3.py
示例13: _plotFSC
def _plotFSC(self, a, fnFSC):
md = MetaData(fnFSC)
resolution_inv = [md.getValue(MDL_RESOLUTION_FREQ, f) for f in md]
frc = [md.getValue(MDL_RESOLUTION_FRC, f) for f in md]
self.maxFrc = max(frc)
self.minInv = min(resolution_inv)
self.maxInv = max(resolution_inv)
a.plot(resolution_inv, frc)
a.xaxis.set_major_formatter(self._plotFormatter)
a.set_ylim([-0.1, 1.1])
开发者ID:azazellochg,项目名称:scipion,代码行数:10,代码来源:viewer_reconstruct_highres.py
示例14: runSymmetrize
def runSymmetrize(self, fnVol, dihedral, fnParams, fnOut, cylinderRadius, height):
md=MetaData(fnParams)
objId=md.firstObject()
rot0=md.getValue(MDL_ANGLE_ROT,objId)
z0=md.getValue(MDL_SHIFT_Z,objId)
args="-i %s --sym %s --helixParams %f %f -o %s"%(fnVol,self.getSymmetry(dihedral),z0,rot0,fnOut)
self.runJob('xmipp_transform_symmetrize',args)
if cylinderRadius>0:
args="-i %s --mask cylinder %d %d"%(fnOut,-cylinderRadius,-height)
self.runJob('xmipp_transform_mask',args)
开发者ID:denisfortun,项目名称:scipion,代码行数:10,代码来源:xmipp3.py
示例15: createMetaDataFromPattern
def createMetaDataFromPattern(pattern, isStack=False, label="image"):
''' Create a metadata from files matching pattern'''
import glob
files = glob.glob(pattern)
files.sort()
from xmipp import MetaData, FileName, getImageSize, MDL_ENABLED, str2Label
label = str2Label(label) #Check for label value
mD = MetaData()
inFile = FileName()
nSize = 1
for file in files:
fileAux=file
if isStack:
if file.endswith(".mrc"):
fileAux=file+":mrcs"
x, x, x, nSize = getImageSize(fileAux)
if nSize != 1:
counter = 1
for jj in range(nSize):
inFile.compose(counter, fileAux)
objId = mD.addObject()
mD.setValue(label, inFile, objId)
mD.setValue(MDL_ENABLED, 1, objId)
counter += 1
else:
objId = mD.addObject()
mD.setValue(label, fileAux, objId)
mD.setValue(MDL_ENABLED, 1, objId)
return mD
开发者ID:josegutab,项目名称:scipion,代码行数:32,代码来源:protlib_utils.py
示例16: symmetrize
def symmetrize(log,WorkingDir,InputVolume,OutputVolume,CylinderRadius,fnFine):
md=MetaData(fnFine)
id=md.firstObject()
rot0=md.getValue(MDL_ANGLE_ROT,id)
z0=md.getValue(MDL_SHIFT_Z,id)
args="-i %s --sym helical --helixParams %f %f -o %s"%(InputVolume,z0,rot0,OutputVolume)
runJob(log,'xmipp_transform_symmetrize',args)
if CylinderRadius>0:
[xdim,ydim,zdim,ndim]=getImageSize(InputVolume)
args="-i %s --mask cylinder %d %d"%(OutputVolume,int(-CylinderRadius),int(-xdim))
runJob(log,'xmipp_transform_mask',args)
开发者ID:josegutab,项目名称:scipion,代码行数:11,代码来源:protocol_helical_params.py
示例17: createSubset
def createSubset(log, inputFile, inputFileLabel, subsetFile, subsetFileLabel, outputFile):
mdInputFile = MetaData(inputFile)
mdSubsetFile = MetaData(subsetFile)
mdOutputFile = MetaData()
print inputFile, inputFileLabel, subsetFile, subsetFileLabel, outputFile
mdOutputFile.join2( mdInputFile
, mdSubsetFile
, str2Label(inputFileLabel)
, str2Label(subsetFileLabel)
, INNER_JOIN)
mdOutputFile.write(outputFile)
开发者ID:josegutab,项目名称:scipion,代码行数:11,代码来源:protocol_subset_particles.py
示例18: validate
def validate(self):
errors = []
inputExt=os.path.splitext(self.InputFile)[1]
if not inputExt in ['.mrc','.stk','.sel','.xmd','.hed','.img', '.ctfdat']:
errors.append("Input file must be stack or metadata (valid extensions are .mrc, .stk, .sel, .xmd, .hed, .img, .ctfdat")
else:
if inputExt in ['.sel', '.xmd', '.ctfdat']:
md = MetaData(self.InputFile)
if not md.containsLabel(MDL_IMAGE):
errors.append("Cannot find label for images in the input file")
return errors
开发者ID:josegutab,项目名称:scipion,代码行数:11,代码来源:protocol_import_particles.py
示例19: fineSearch
def fineSearch(log,WorkingDir,InputVolume,CylinderRadius,fnCoarse,Rot0, RotF, Z0, ZF,fnFine):
md=MetaData(fnCoarse)
id=md.firstObject()
rot0=md.getValue(MDL_ANGLE_ROT,id)
z0=md.getValue(MDL_SHIFT_Z,id)
args="-i %s --sym helical -z %f %f --rotHelical %f %f --localHelical %f %f -o %s"%(InputVolume,float(Z0),float(ZF),
float(Rot0),float(RotF),z0,rot0,fnFine)
if CylinderRadius>0:
[xdim,ydim,zdim,ndim]=getImageSize(InputVolume)
args+=" --mask cylinder %d %d"%(int(-CylinderRadius),int(-xdim))
runJob(log,'xmipp_volume_find_symmetry',args)
开发者ID:josegutab,项目名称:scipion,代码行数:11,代码来源:protocol_helical_params.py
示例20: visualize
def visualize(self):
from protlib_gui_figure import XmippArrayPlotter1D, XmippArrayPlotter2D, XmippArrayPlotter3D
components = self.DisplayRawDeformation.split()
dim = len(components)
if dim > 0:
modeList = []
modeNameList = []
# Get modes
MD = MetaData(self.Modesfile)
MD.removeDisabled()
for modeComponent in components:
mode = int(modeComponent)
if mode > MD.size():
from protlib_gui_ext import showWarning
showWarning("Warning", "You don't have so many modes", parent=self.master)
else:
mode -= 1
currentMode = 0
modeName = ""
for id in MD:
modeName = MD.getValue(MDL_NMA_MODEFILE, id)
currentMode += 1
if currentMode > mode:
break
modeNameList.append(modeName)
modeList.append(mode)
# Actually plot
if dim == 1:
XmippArrayPlotter1D(
self.extraPath("deformations.txt"),
modeList[0],
"Histogram for mode %s" % modeNameList[0],
"Deformation value",
"Number of images",
)
elif dim == 2:
XmippArrayPlotter2D(
self.extraPath("deformations.txt"), modeList[0], modeList[1], "", modeNameList[0], modeNameList[1]
)
elif dim == 3:
XmippArrayPlotter3D(
self.extraPath("deformations.txt"),
modeList[0],
modeList[1],
modeList[2],
"",
modeNameList[0],
modeNameList[1],
modeNameList[2],
)
开发者ID:josegutab,项目名称:scipion,代码行数:53,代码来源:protocol_nma_alignment.py
注:本文中的xmipp.MetaData类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论