xmipp3.convert.convert module¶
This module contains converter functions that will serve to: 1. Write from base classes to Xmipp specific files 2. Read from Xmipp files to base classes
-
xmipp3.convert.convert.
acquisitionToRow
(acquisition, ctfRow)[source]¶ Set labels values from acquisition to md row.
-
xmipp3.convert.convert.
alignmentToRow
(alignment, alignmentRow, alignType)[source]¶ - is2D == True-> matrix is 2D (2D images alignment)
- otherwise matrix is 3D (3D volume alignment or projection)
- invTransform == True -> for xmipp implies projection
- -> for xmipp implies alignment
-
xmipp3.convert.convert.
class2DToRow
(class2D, classRow)[source]¶ Set labels values from Class2D to md row.
-
xmipp3.convert.convert.
coordinateToRow
(coord, coordRow, copyId=True)[source]¶ Set labels values from Coordinate coord to md row.
-
xmipp3.convert.convert.
createClassesFromImages
(inputImages, inputMd, classesFn, ClassType, classLabel, classFnTemplate, alignType, iter, preprocessImageRow=None)[source]¶ From an intermediate X.xmd file produced by xmipp, create the set of classes in which those images are classified. Params:
inputImages: the SetOfImages that were initially classified by relion. inputMd: the filename metadata. classesFn: filename where to write the classes. ClassType: the output type of the classes set
(usually SetOfClass2D or 3D)classLabel: label that is the class reference. classFnTemplate: the template to get the classes averages filenames iter: the iteration number, just used in Class template
-
xmipp3.convert.convert.
createClassesFromImages2
(inputImages, inputMd, classesFn, ClassType, classLabel, alignType, getClassFn=None, preprocessImageRow=None)[source]¶ From an intermediate X.xmd file produced by xmipp, create the set of classes in which those images are classified. Params:
inputImages: the SetOfImages that were initially classified by relion. inputMd: the filename metadata. classesFn: filename where to write the classes. ClassType: the output type of the classes set ( usually SetOfClass2D or 3D ) classLabel: label that is the class reference. classFnTemplate: the template to get the classes averages filenames iter: the iteration number, just used in Class template
-
xmipp3.convert.convert.
createParamPhantomFile
(filename, dimX, partSetMd, phFlip=False, ctfCorr=False)[source]¶
-
xmipp3.convert.convert.
ctfModelToRow
(ctfModel, ctfRow)[source]¶ Set labels values from ctfModel to md row.
-
xmipp3.convert.convert.
defocusGroupSetToRow
(defocusGroup, defocusGroupRow)[source]¶ Set labels values from ctfModel to md row.
-
xmipp3.convert.convert.
fillClasses
(clsSet, updateClassCallback=None)[source]¶ Give an empty SetOfClasses (either 2D or 3D). Iterate over the input images and append to the corresponding class. It is important that each image has the classId properly set.
-
xmipp3.convert.convert.
fixVolumeFileName
(image)[source]¶ This method will add :mrc to .mrc volumes because for mrc format is not possible to distinguish between 3D volumes and 2D stacks.
-
xmipp3.convert.convert.
getMovieFileName
(movie)[source]¶ Add the :mrcs or :ems extensions to movie files to be recognized by Xmipp as proper stack files.
-
xmipp3.convert.convert.
getXmippAttribute
(obj, label, default=None)[source]¶ Sets an attribute of an object prefixing it with xmipp
-
xmipp3.convert.convert.
locationToXmipp
(index, filename)[source]¶ Convert an index and filename location to a string with @ as expected in Xmipp.
-
xmipp3.convert.convert.
matrixFromGeometry
(shifts, angles, inverseTransform)[source]¶ Create the transformation matrix from a given 2D shifts in X and Y…and the 3 euler angles.
-
xmipp3.convert.convert.
micrographToCTFParam
(mic, ctfparam)[source]¶ This function is used to convert a Micrograph object to the .ctfparam metadata needed by some Xmipp programs. If the micrograph already comes from xmipp, the ctfparam will be returned, if not, the new file.
-
xmipp3.convert.convert.
micrographToRow
(mic, micRow, **kwargs)[source]¶ Set labels values from Micrograph mic to md row.
-
xmipp3.convert.convert.
objectToRow
(obj, row, attrDict, extraLabels=[])[source]¶ This function will convert an EMObject into a Row. Params:
obj: the EMObject instance (input) row: the Row instance (output) -see emlib.metadata.utils.Row()- attrDict: dictionary with the map between obj attributes(keys) and
row MDLabels in Xmipp (values).- extraLabels: a list with extra labels that could be included
- as _xmipp_labelName
-
xmipp3.convert.convert.
particleToRow
(part, partRow, **kwargs)[source]¶ Set labels values from Particle to md row.
-
xmipp3.convert.convert.
readAnglesFromMicrographs
(micFile, anglesSet)[source]¶ Read the angles from a micrographs Metadata.
-
xmipp3.convert.convert.
readCTFModel
(filename, mic)[source]¶ Read from Xmipp .ctfparam and create a CTFModel object.
-
xmipp3.convert.convert.
readCoordinates
(mic, fileName, coordsSet, outputDir, readDiscarded=False, scale=1)[source]¶
-
xmipp3.convert.convert.
readPosCoordinates
(posFile, readDiscarded=False)[source]¶ Read the coordinates in .pos file and return corresponding metadata. There are two possible blocks with particles: particles: with manual/supervised particles particles_auto: with automatically picked particles. If posFile doesn’t exist, the metadata will be empty readDiscarded: read only the coordinates in the particles_auto DB
with the MDL_ENABLE set at -1 and a positive cost
-
xmipp3.convert.convert.
readSetOfClasses
(classesSet, filename, classesBlock='classes', **kwargs)[source]¶
-
xmipp3.convert.convert.
readSetOfClasses2D
(classes2DSet, filename, classesBlock='classes', **kwargs)[source]¶ Just a wrapper to readSetOfClasses.
-
xmipp3.convert.convert.
readSetOfClasses3D
(classes3DSet, filename, classesBlock='classes', **kwargs)[source]¶ Just a wrapper to readSetOfClasses.
-
xmipp3.convert.convert.
readSetOfClassesVol
(classesVolSet, filename, classesBlock='classes', **kwargs)[source]¶ read from Xmipp image metadata. fnImages: The metadata filename where the particles properties are. imgSet: the SetOfParticles that will be populated. hasCtf: is True if the ctf information exists.
-
xmipp3.convert.convert.
readSetOfCoordinates
(outputDir, micSet, coordSet, readDiscarded=False, scale=1)[source]¶ Read from Xmipp .pos files. Params:
- outputDir: the directory where the .pos files are.
- It is also expected a file named: config.xmd in this directory where the box size can be read.
- micSet: the SetOfMicrographs to associate the .pos, which
- name should be the same of the micrographs.
coordSet: the SetOfCoordinates that will be populated. readDiscarded: read only the coordinates with the MDL_ENABLE set at -1 scale: Factor to scale ONLY x,y coordinates, you are supposed to use an appropiate boxsize (you created the set)
-
xmipp3.convert.convert.
readSetOfImages
(filename, imgSet, rowToFunc, **kwargs)[source]¶ read from Xmipp image metadata. filename: The metadata filename where the image are. imgSet: the SetOfParticles that will be populated. rowToFunc: this function will be used to convert the row to Object
-
xmipp3.convert.convert.
rowToAcquisition
(acquisitionRow)[source]¶ Create an acquisition from a row of a metadata.
-
xmipp3.convert.convert.
rowToAlignment
(alignmentRow, alignType)[source]¶ - is2D == True-> matrix is 2D (2D images alignment)
- otherwise matrix is 3D (3D volume alignment or projection)
invTransform == True -> for xmipp implies projection
-
xmipp3.convert.convert.
rowToClass
(classRow, classItem)[source]¶ Method base to create a class2D, class3D or classVol from a row of a metadata
-
xmipp3.convert.convert.
rowToCoordinate
(coordRow)[source]¶ Create a Coordinate from a row of a metadata.
-
xmipp3.convert.convert.
rowToImage
(imgRow, imgLabel, imgClass, **kwargs)[source]¶ Create an Image from a row of a metadata.
-
xmipp3.convert.convert.
rowToMicrograph
(micRow, **kwargs)[source]¶ Create a Micrograph object from a row of Xmipp metadata.
-
xmipp3.convert.convert.
rowToObject
(row, obj, attrDict, extraLabels=[])[source]¶ This function will convert from a Row to an EMObject. Params:
row: the Row instance (input) -see emlib.metadata.utils.Row()- obj: the EMObject instance (output) attrDict: dictionary with the map between obj attributes(keys) and
row MDLabels in Xmipp (values).- extraLabels: a list with extra labels that could be included
- as _xmipp_labelName
-
xmipp3.convert.convert.
rowToVolume
(volRow, **kwargs)[source]¶ Create a Volume object from a row of Xmipp metadata.
-
xmipp3.convert.convert.
setOfImagesToMd
(imgSet, mdIn, imgToFunc, **kwargs)[source]¶ This function will fill Xmipp metadata from a SetOfMicrographs Params:
imgSet: the set of images to be converted to metadata mdIn: metadata to be filled rowFunc: this function can be used to setup the row before
adding to metadata.
-
xmipp3.convert.convert.
setPsdFiles
(ctfModel, ctfRow)[source]¶ Set the PSD files of CTF estimation related to this ctfModel. The values will be read from the ctfRow if present.
-
xmipp3.convert.convert.
setXmippAttribute
(obj, label, value)[source]¶ Sets an attribute of an object prefixing it with xmipp
-
xmipp3.convert.convert.
setXmippAttributes
(obj, objRow, *labels, **kwargs)[source]¶ Set the labels attribute(s) to obj from a objRow (those not basic ones). More than one label can be set and default can also be a list of same number of entries. The new attribute will be named _xmipp_LabelName and the datatype will be set correctly. If obj doesn’t contain a label and a default value is in kwargs, it’s set in its corresponding Scipion datatype.
-
xmipp3.convert.convert.
volumeToRow
(vol, volRow, **kwargs)[source]¶ Set labels values from Micrograph mic to md row.
-
xmipp3.convert.convert.
writeCTFModel
(ctfModel, ctfFile)[source]¶ Given a CTFModel object write as Xmipp ctfparam
-
xmipp3.convert.convert.
writeCoordsConfig
(configFn, boxSize, state)[source]¶ Write the config.xmd file needed for Xmipp picker. Params:
configFn: The filename were to store the configuration. boxSize: the box size in pixels for extraction. state: picker state
-
xmipp3.convert.convert.
writeMicCoordinates
(mic, coordList, outputFn, isManual=True, getPosFunc=None)[source]¶ Write the pos file as expected by Xmipp with the coordinates of a given micrograph. Params:
mic: input micrograph. coordList: list of (x, y) pairs of the mic coordinates. outputFn: output filename for the pos file . isManual: if the coordinates are ‘Manual’ or ‘Supervised’ getPosFunc: a function to get the positions from the coordinate,
it can be useful for scaling the coordinates if needed.
-
xmipp3.convert.convert.
writeSetOfCTFs
(ctfSet, mdCTF)[source]¶ Write a ctfSet on metadata format. Params:
ctfSet: the SetOfCTF that will be read. mdCTF: The file where metadata should be written.
-
xmipp3.convert.convert.
writeSetOfClasses2D
(classes2DSet, filename, classesBlock='classes', writeParticles=True)[source]¶ This function will write a SetOfClasses2D as Xmipp metadata. Params:
classes2DSet: the SetOfClasses2D instance. filename: the filename where to write the metadata.
-
xmipp3.convert.convert.
writeSetOfClassesVol
(classesVolSet, filename, classesBlock='classes')[source]¶ This function will write a SetOfClassesVol as Xmipp metadata. Params:
classesVolSet: the SetOfClassesVol instance. filename: the filename where to write the metadata.
-
xmipp3.convert.convert.
writeSetOfCoordinatesWithState
(posDir, coordSet, state, scale=1)[source]¶ Write a pos file on metadata format for each micrograph on the coordSet. Params:
posDir: the directory where the .pos files will be written. coordSet: the SetOfCoordinates that will be read.
-
xmipp3.convert.convert.
writeSetOfDefocusGroups
(defocusGroupSet, fnDefocusGroup)[source]¶ Write a defocuGroupSet on metadata format. Params:
defocusGroupSet: the SetOfDefocus that will be read. fnDefocusGroup: The file where defocusGroup should be written.
-
xmipp3.convert.convert.
writeSetOfImages
(imgSet, filename, imgToFunc, blockName='Images', **kwargs)[source]¶ This function will write a SetOfImages as a Xmipp metadata. Params:
imgSet: the set of images to be written (particles, micrographs or volumes) filename: the filename where to write the metadata. rowFunc: this function can be used to setup the row before
adding to metadata.
-
xmipp3.convert.convert.
writeSetOfMicrographs
(micSet, filename, blockName='Micrographs', **kwargs)[source]¶
-
xmipp3.convert.convert.
writeSetOfMicrographsPairs
(uSet, tSet, filename)[source]¶ This function will write a MicrographsTiltPair as Xmipp metadata. Params:
uSet: the untilted set of micrographs to be written tSet: the tilted set of micrographs to be written filename: the filename where to write the metadata.
-
xmipp3.convert.convert.
writeSetOfMovies
(moviesSet, filename, moviesBlock='movies')[source]¶ This function will write a SetOfMovies as Xmipp metadata. Params:
moviesSet: the SetOfMovies instance. filename: the filename where to write the metadata.
-
xmipp3.convert.convert.
writeSetOfParticles
(imgSet, filename, blockName='Particles', **kwargs)[source]¶
-
xmipp3.convert.convert.
xmippToLocation
(xmippFilename)[source]¶ Return a location (index, filename) given a Xmipp filename with the index@filename structure.