pwem.objects.data module

This modules contains basic hierarchy for EM data objects like: Image, SetOfImage and others

class pwem.objects.data.Acquisition(**kwargs)[source]

Bases: EMObject

Acquisition information

copyInfo(other)[source]
getAmplitudeContrast()[source]
getDoseInitial()[source]
getDosePerFrame()[source]
getMagnification()[source]
getSphericalAberration()[source]
getVoltage()[source]
setAmplitudeContrast(value)[source]
setDoseInitial(value)[source]
setDosePerFrame(value)[source]
setMagnification(value)[source]
setSphericalAberration(value)[source]
setVoltage(value)[source]
class pwem.objects.data.Alphabet[source]

Bases: object

class with a dictionary of all valid alphabets

AMBIGOUS_DNA_ALPHABET = 2
AMBIGOUS_RNA_ALPHABET = 5
AMINOACIDS = 0
DUMMY_ALPHABET = 8
EXTENDED_DNA_ALPHABET = 4
EXTENDED_PROTEIN_ALPHABET = 1
NUCLEOTIDES = 1
NUCLEOTIDES_ALPHABET = 7
PROTEIN_ALPHABET = 0
SEQ_TYPE = ['aminoacids', 'nucleotides']
UNAMBIGOUS_DNA_ALPHABET = 3
UNAMBIGOUS_RNA_ALPHABET = 6
alphabets = {0: 'ACDEFGHIKLMNPQRSTVWY', 1: 'ACDEFGHIKLMNPQRSTVWYBJOUXZ', 2: 'GATCRYWSMKHBVDN', 3: 'GATC', 4: 'GATCBDSW', 5: 'GAUCRYWSMKHBVDN', 6: 'GAUC', 7: 'GAC', 8: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
alphabetsLabels = {0: 'Protein', 1: 'Extended Protein', 2: 'Ambigous DNA', 3: 'Unambigous DNA', 4: 'Extended DNA', 5: 'Ambigous RNA', 6: 'Unambigous RNA'}
class pwem.objects.data.AtomStruct(filename=None, pseudoatoms=False, **kwargs)[source]

Bases: EMFile

Represents an PDB file.

getOrigin(force=False)[source]
getPseudoAtoms()[source]
getVolume()[source]
hasOrigin()[source]
hasVolume()[source]
setOrigin(newOrigin)[source]
setPseudoAtoms(value)[source]
setVolume(volume)[source]
class pwem.objects.data.CTFModel(**kwargs)[source]

Bases: EMObject

Represents a generic CTF model.

DEFOCUS_RATIO_ERROR_VALUE = -1
DEFOCUS_V_MINIMUM_VALUE = 0.1
copyInfo(other)[source]
equalAttributes(other, ignore=[], verbose=False)[source]

Override default behaviour to compare two CTF objects, now ignoring the psdFile.

getDefocus()[source]

Returns defocusU, defocusV and defocusAngle.

getDefocusAngle()[source]
getDefocusRatio()[source]
getDefocusU()[source]
getDefocusV()[source]
getFitQuality()[source]
getMicrograph()[source]
getPhaseShift()[source]
getPsdFile()[source]
getResolution()[source]
hasPhaseShift()[source]
hasResolution()[source]
setDefocusAngle(value)[source]
setDefocusU(value)[source]
setDefocusV(value)[source]
setFitQuality(value)[source]
setMicrograph(mic)[source]
setPhaseShift(value)[source]
setPsdFile(value)[source]
setResolution(value)[source]
setStandardDefocus(defocusU, defocusV, defocusAngle)[source]

Set defocus values following emx conventions. See _standardize function.

setWrongDefocus()[source]

Set parameters if results parsing has failed. :param ctfModel: the model to be updated

standardize()[source]

Modify defocusU, defocusV and defocusAngle to conform the EMX standard: defocusU > defocusV, 0 <= defocusAngle < 180 and the defocusAnges is between x-axis and defocusU. Also determine the defocusRatio(defocusU/defocusV). For more details see: http://i2pc.cnb.csic.es/emx/LoadDictionaryFormat.htm?type=Convention#ctf

class pwem.objects.data.Class2D(**kwargs)[source]

Bases: SetOfParticles

Represent a Class that groups Particles objects. Usually the representative of the class is another Particle (some kind of average particle from the particles assigned to the class)

clone()[source]

Override the clone defined in Object to avoid copying _mapperPath property

close()[source]
copyInfo(other)[source]

Copy basic information (id and other properties) but not _mapperPath or _size from other set of micrographs to current one.

class pwem.objects.data.Class3D(**kwargs)[source]

Bases: SetOfParticles

Represent a Class that groups Particles objects. Usually the representative of the class is a Volume reconstructed from the particles assigned to the class.

REP_TYPE

alias of Volume

clone()[source]

Override the clone defined in Object to avoid copying _mapperPath property

close()[source]
copyInfo(other)[source]

Copy basic information (id and other properties) but not _mapperPath or _size from other set of micrographs to current one.

class pwem.objects.data.ClassVol(**kwargs)[source]

Bases: SetOfVolumes

Represent a Class that groups Volume objects. Usually the representative of the class is another Volume.

close()[source]
class pwem.objects.data.Coordinate(**kwargs)[source]

Bases: EMObject

This class holds the (x,y) position and other information associated with a coordinate

copyInfo(coord)[source]

Copy information from other coordinate.

getMicId()[source]
getMicName()[source]
getMicrograph()[source]

Return the micrograph object to which this coordinate is associated.

getPosition()[source]

Return the position of the coordinate as a (x, y) tuple. mode: select if the position is the center of the box or in the top left corner.

getX()[source]
getY()[source]
invertY()[source]
scale(factor)[source]

Scale both x and y coordinates by a given factor.

setMicId(micId)[source]
setMicName(micName)[source]
setMicrograph(micrograph)[source]

Set the micrograph to which this coordinate belongs.

setPosition(x, y)[source]
setX(x)[source]
setY(y)[source]
shiftX(shiftX)[source]
shiftY(shiftY)[source]
class pwem.objects.data.DefocusGroup(**kwargs)[source]

Bases: EMObject

Groups CTFs by defocus

addCTF(ctf)[source]

Add a new CTF to the group. Update values like min, max, avg and size.

containsCTF(ctf)[source]

Return True if a CTF is inside the group defocus range.

getDefocusAvg()[source]
getDefocusMax()[source]
getDefocusMin()[source]
getSize()[source]
class pwem.objects.data.EMFile(filename=None, **kwargs)[source]

Bases: EMObject

Class to link usually to text files.

getFileName()[source]

Use the _objValue attribute to store filename.

setFileName(filename)[source]

Use the _objValue attribute to store filename.

class pwem.objects.data.EMObject(value=None, **kwargs)[source]

Bases: Object

Base object for all EM classes

getFiles()[source]

Get all filePaths

class pwem.objects.data.EMSet(filename=None, prefix='', mapperClass=None, classesDict=None, **kwargs)[source]

Bases: Set, EMObject

clone()[source]

Override the clone defined in Object to avoid copying _mapperPath property

copyInfo(other)[source]

Define a dummy copyInfo function to be used for some generic operations on sets.

copyItems(otherSet, updateItemCallback=None, itemDataIterator=None, copyDisabled=False, doClone=True, itemSelectedCallback=None)[source]

Copy items from another set, allowing to update items information based on another source of data, paired with each item.

Params:

otherSet: input set from where the items will be copied. updateItemCallback: if not None, this will be called for each item

and each data row (if the itemDataIterator is not None). Apart from setting item values or new attributes, it is possible to set the special flag _appendItem to False, and then this item will not be added to the set.

itemDataIterator: if not None, it must be an iterator that have one

data item for each item in the set. Usually the data item is a data row, coming from a table stored in text files (e.g STAR)

copyDisabled: By default, disabled items are not copied from the other

set. If copyDisable=True, then the enabled property of the item will be ignored.

doClone: By default, the new item that will be inserted is a “clone”

of the input item. By using doClone=False, the same input item will be passed to the callback and added to the set. This will avoid the clone operation and the related overhead.

itemSelectedCallback: Optional, callback receiving an item and

returning true if it has to be copied

classmethod create(outputPath, prefix=None, suffix=None, ext=None, **kwargs)[source]

Create an empty set from the current Set class. Params:

outputPath: where the output file will be written. prefix: prefix of the created file, if None, it will be deduced

from the ClassName.

suffix: additional suffix that will be added to the prefix with a

“_” in between.

ext: extension of the output file, be default will use .sqlite

createCopy(outputPath, prefix=None, suffix=None, ext=None, copyInfo=False, copyItems=False, itemSelectedCallback=None)[source]

Make a copy of the current set to another location (e.g file). Params:

outputPath: where the output file will be written.

prefix: prefix of the created file, if None, it will be deduced

from the ClassName.

suffix: additional suffix that will be added to the prefix with a

“_” in between.

ext: extension of the output file, be default will use the same

extension of this set filename.

copyInfo: if True the copyInfo will be called after set creation.

copyItems: if True the copyItems function will be called.

itemSelectedCallback: Optional, callback receiving an item and returning

true if it has to be copied

getFiles()[source]

Get all filePaths

class pwem.objects.data.FSC(**kwargs)[source]

Bases: EMObject

Store a Fourier Shell Correlation

calculateResolution(threshold=0.143)[source]

Calculate the FSC resolution value

getData()[source]
loadFromMd(mdObj, labelX, labelY)[source]

Fill the x and y data of the FSC from a metadata. Params:

mdObj: either a metadata object of a filename labelX: label used for frequency labelY: label used for FSC values

setData(xData, yData)[source]
class pwem.objects.data.FramesRange(firstFrame=1, lastFrame=0, firstFrameIndex=1)[source]

Bases: CsvList

Store first and last frames in a movie. The last element will be the index in the stack of the first frame.

Frames numbering always refer to the initial movies imported into the project. Counting goes from 1 to the number of frames.

The underlying stack file could have all original frames or just a subset of them, so we need to keep which is the index of the first frame in the stack, again, the first image in a stack is 1

getFirstFrame()[source]
getFirstFrameIndex()[source]
getLastFrame()[source]
getRange()[source]

Return the frames range.

rangeStr()[source]
setFirstFrame(value)[source]
setFirstFrameIndex(value)[source]
setLastFrame(value)[source]
class pwem.objects.data.Image(location=None, **kwargs)[source]

Bases: EMObject

Represents an EM Image object

Params:

Parameters

location – Could be a valid location: (index, filename)

or filename

copyInfo(other)[source]

Copy basic information

copyLocation(other)[source]

Copy location index and filename from other image.

getAcquisition()[source]
getBaseName()[source]
getCTF()[source]

Return the CTF model

getDataType()[source]
getDim()[source]

Return image dimensions as tuple: (Xdim, Ydim, Zdim)

getDimensions()[source]

getDimensions is redundant here but not in setOfVolumes create it makes easier to create protocols for both images and sets of images

getFileName()[source]

Use the _objValue attribute to store filename.

getFiles()[source]

Get all filePaths

getFormat()[source]
getImage()[source]

Returns the actual image this objects represents

getIndex()[source]
getLocation()[source]

This function return the image index and filename. It will only differs from getFileName, when the image is contained in a stack and the index make sense.

getOrigin(force=False)[source]

shifts in A

getSamplingRate()[source]

Return image sampling rate. (A/pix)

getShiftsFromOrigin()[source]
getTransform() Transform[source]
getXDim()[source]
getYDim()[source]
hasAcquisition()[source]
hasCTF()[source]
hasOrigin()[source]
hasTransform()[source]
originResampled(originNotResampled, oldSampling)[source]
setAcquisition(acquisition)[source]
setCTF(newCTF)[source]
setFileName(filename)[source]

Use the _objValue attribute to store filename.

setIndex(index)[source]
setLocation(*args)[source]

Set the image location, see getLocation. Params:

First argument can be:
  1. a tuple with (index, filename)

  2. a index, this implies a second argument with filename

  3. a filename, this implies index=NO_INDEX

setMRCSamplingRate()[source]

Sets the sampling rate to the mrc file represented by this image

setOrigin(newOrigin=None)[source]

If None, default origin will be set. Note: shifts are in Angstroms

setSamplingRate(sampling)[source]
setShiftsInOrigin(x, y, z)[source]
setTransform(newTransform)[source]
class pwem.objects.data.ImageDim(x=None, y=None, z=None)[source]

Bases: CsvList

Just a wrapper to a CsvList to store image dimensions as X, Y and Z.

getX()[source]
getY()[source]
getZ()[source]
class pwem.objects.data.Mask(location=None, **kwargs)[source]

Bases: Particle

Represent a mask.

Params:

Parameters

location – Could be a valid location: (index, filename)

or filename

class pwem.objects.data.Matrix(**kwargs)[source]

Bases: Scalar

getMatrix()[source]

Return internal numpy matrix.

getObjValue()[source]

Return the internal value for storage. This is a good place to do some update of the internal value before been stored

setMatrix(matrix)[source]

Override internal numpy matrix.

setValue(i, j, value)[source]
class pwem.objects.data.Micrograph(location=None, **kwargs)[source]

Bases: Image

Represents an EM Micrograph object

Params:

Parameters

location – Could be a valid location: (index, filename)

or filename

copyInfo(other)[source]

Copy basic information

getMicName()[source]
setMicName(micName)[source]
class pwem.objects.data.Movie(location=None, **kwargs)[source]

Bases: Micrograph

Represent a set of frames of micrographs.

Params:

Parameters

location – Could be a valid location: (index, filename)

or filename

getAlignment()[source]
getDim()[source]

Return image dimensions as tuple: (Xdim, Ydim, Zdim) Consider compressed Movie files

getFramesRange()[source]
getNumberOfFrames()[source]

Return the number of frames of this movie

hasAlignment()[source]
isCompressed()[source]
setAlignment(alignment)[source]

Alignment are stored as a vector containing x and y coordinates. In this way 1 2 3 4 are the data related with 2 frames with shifts (1,2) and (3,4)

setFramesRange(value)[source]
class pwem.objects.data.MovieAlignment(first=-1, last=-1, **kwargs)[source]

Bases: EMObject

Store the alignment between the different Movie frames. Also store the first and last frames used for alignment.

getRange()[source]

Return the first and last frames used for alignment. The first frame in a movie stack is numbered 1 and the maximum value for the last one is N, where N is the total number of frames.

getRoi()[source]

Return the size used to align the movie

getShifts()[source]

Return the list of alignment between one frame to another, from first to last frame used.

setRoi(roiList)[source]
class pwem.objects.data.MovieParticle(**kwargs)[source]

Bases: Particle

Params:

Parameters

location – Could be a valid location: (index, filename)

or filename

getFrameId()[source]
getParticleId()[source]
setFrameId(frameId)[source]
setParticleId(partId)[source]
class pwem.objects.data.NormalMode(**kwargs)[source]

Bases: EMObject

Store normal mode information.

getCollectivity()[source]
getModeFile()[source]
getScore()[source]
setCollectivity(value)[source]
setModeFile(value)[source]
setScore(value)[source]
class pwem.objects.data.Particle(location=None, **kwargs)[source]

Bases: Image

Represents an EM Particle object

Params:

Parameters

location – Could be a valid location: (index, filename)

or filename

getClassId()[source]
getCoordinate()[source]
getMicId()[source]

Return the micrograph id if the coordinate is not None. or have set the _micId property.

hasClassId()[source]
hasCoordinate()[source]
hasMicId()[source]
scaleCoordinate(factor)[source]
setClassId(classId)[source]
setCoordinate(coordinate)[source]
setMicId(micId)[source]
class pwem.objects.data.PdbFile(filename=None, pseudoatoms=False, **kwargs)[source]

Bases: AtomStruct

class pwem.objects.data.Sequence(name=None, sequence=None, alphabet=None, isAminoacids=True, id=None, description=None, **kwargs)[source]

Bases: EMObject

Class containing a sequence of aminoacids/nucleotides Attribute names follow the biopython default ones

param: name: name of the sequence param: sequence: string with the sequence param: alphabet: integer with the alphabet to be used param: isAminoacids: boolean indicating if the sequence is an aminoacid sequence param: id: string with the sequence id param: description: string with the sequence description

appendToFile(seqFileName, doClean=True)[source]

Exports the sequence to the specified file. If it already exists, the sequence is appended to the ones in the file

exportToFile(seqFileName, doClean=True)[source]

Exports the sequence to the specified file

getAlphabet()[source]
getDescription()[source]
getId()[source]
getIsAminoacids()[source]
getSeqName()[source]
getSequence()[source]
importFromFile(seqFileName, isAmino=True)[source]

Fills the sequence attributes from the FIRST sequence found in the specified file

setDescription(description)[source]
setId(id)[source]
setSeqName(name)[source]
setSequence(sequence)[source]
class pwem.objects.data.SetOfAtomStructs(filename=None, prefix='', mapperClass=None, classesDict=None, **kwargs)[source]

Bases: EMSet

Set containing PDB items.

EXPOSE_ITEMS = True
ITEM_TYPE

alias of AtomStruct

getFiles()[source]

Get all filePaths

class pwem.objects.data.SetOfAverages(**kwargs)[source]

Bases: SetOfParticles

Represents a set of Averages. It is a SetOfParticles but it is useful to differentiate outputs.

class pwem.objects.data.SetOfCTF(**kwargs)[source]

Bases: EMSet

Contains a set of CTF models estimated for a set of images.

ITEM_TYPE

alias of CTFModel

getMicrographs()[source]

Return the SetOFImages used to create the SetOfClasses.

setMicrographs(micrographs)[source]

Set the micrographs from which this CTFs were estimated. Params:

micrographs: Either a SetOfMicrographs object or a pointer to it.

class pwem.objects.data.SetOfClasses(**kwargs)[source]

Bases: EMSet

Store results from a classification.

ITEM_TYPE = None
REP_TYPE = None
appendFromClasses(classesSet, filterClassFunc=None, updateClassCallback=None)[source]

Iterate over the classes and the elements inside each class and append classes and items that are enabled.

Parameters
  • classesSet – Set of classes to copy items from

  • filterClassFunc – Extra callback to exclude classes. Receives a class item, should return a boolean

classifyItems(updateItemCallback=None, updateClassCallback=None, itemDataIterator=None, classifyDisabled=False, iterParams=None, doClone=True, raiseOnNextFailure=True)[source]

Classify items from the self.getImages() and add the needed classes. This function iterates over each item in the images and call the updateItemCallback to register the information coming from the iterator in itemDataIterator. The callback function should set the classId of the image that will be used to classify it. It is also possible to pass a callback to update the class properties.

Parameters
  • updateItemCallback – callback to be invoked on each item’s loop (e.g.: 2d image in a 2d classification)

  • updateClassCallback – callback to be invoked when a item.getClassId() changes

  • itemDataIterator – an iterator (usually on metadata files, star, xmd,…) that will be called on each loop.

usually has that same lines as items and iteration is kept in sync :param classifyDisabled: classify disabled items. By default, they are skipped. :param iterParams: Parameters for self.getImages() to leave oot images/filter :param doClone: Make a clone of the item (defaults to true) :param raiseOnNextFailure: A boolean flag indicating whether to raise an exception if there is a failure while

attempting to retrieve the next element from itemDataIterator. If set to True(default), an exception will be raised; if set to False, the loop will be terminated in case of failure. Pass False when itemDataIterator is a subset of the inputSet. Important: Pass the right iterParams to make sure the iteration on the inputSet

matches the iteration of the itemDataIterator

copyInfo(other)[source]

Copy basic information from other set of classes to current one

getDimensions()[source]

Return first image dimensions as a tuple: (xdim, ydim, zdim)

getFiles()[source]

Get all filePaths

getFirstItem()[source]

Return the first item in the Set.

getImages()[source]

Return the SetOfImages used to create the SetOfClasses.

getImagesPointer()[source]

” Return the pointer to the SetOfImages used to create the SetOfClasses.

getSamplingRate()[source]
hasRepresentatives()[source]
iterClassItems(iterDisabled=False)[source]

Iterate over the images of a class. Params:

iterDisabled: If True, also include the disabled items.

iterItems(orderBy='id', direction='ASC')[source]
iterRepresentatives(orderBy='id', direction='ASC')[source]
setImages(images)[source]

Set the images (particles) 2d associated with this set of classes. Params:

images: An indirect pointer (with extended) to a set of images.

class pwem.objects.data.SetOfClasses2D(**kwargs)[source]

Bases: SetOfClasses

Store results from a 2D classification of Particles.

ITEM_TYPE

alias of Class2D

REP_TYPE

alias of Particle

writeStack(fnStack)[source]

Write an stack with the classes averages.

class pwem.objects.data.SetOfClasses3D(**kwargs)[source]

Bases: SetOfClasses

Store results from a 3D classification of Particles.

ITEM_TYPE

alias of Class3D

REP_TYPE

alias of Volume

class pwem.objects.data.SetOfClassesVol(**kwargs)[source]

Bases: SetOfClasses3D

Store results from a classification of Volumes.

ITEM_TYPE

alias of ClassVol

class pwem.objects.data.SetOfCoordinates(**kwargs)[source]

Bases: EMSet

Encapsulate the logic of a set of particles coordinates. Each coordinate has a (x,y) position and is related to a Micrograph The SetOfCoordinates can also have information about TiltPairs.

ITEM_TYPE

alias of Coordinate

copyInfo(other)[source]

Copy basic information (boxsize) from other set of coordinates to current one

getBoxSize()[source]

Return the box size of the particles.

getFiles()[source]

Get all filePaths

getMicrographs(asPointer=False)[source]

Returns the SetOfMicrographs associated with this SetOfCoordinates

initMicrographs()[source]

Initialize internal _micrographs to a dictionary if not done already

iterCoordinates(micrograph=None)[source]

Iterate over the coordinates associated with a micrograph. If micrograph=None, the iteration is performed over the whole set of coordinates.

iterMicrographCoordinates(micrograph)[source]

Iterates over the set of coordinates belonging to that micrograph.

iterMicrographs()[source]

Iterate over the micrographs set associated with this set of coordinates.

setBoxSize(boxSize)[source]

Set the box size of the particles.

setMicrographs(micrographs)[source]

Set the micrographs associated with this set of coordinates. Params:

micrographs: Either a SetOfMicrographs object or a pointer to it.

class pwem.objects.data.SetOfDefocusGroup(**kwargs)[source]

Bases: EMSet

Contains a set of DefocusGroup. if min/max/avg exists the corresponding flag must be set to true.

ITEM_TYPE

alias of DefocusGroup

getAvgSet()[source]
getMaxSet()[source]
getMinSet()[source]
setAvgSet(value)[source]
setMaxSet(value)[source]
setMinSet(value)[source]
class pwem.objects.data.SetOfDefocusGroups(inputSet, groupRange=1000, groupMinSize=1, **kwargs)[source]

Bases: object

Store a set of several defocus groups.

Create necessary defocus groups. Params:

inputSet: input particles or micrographs with CTF information. groupRange: maximum defocus range allowed in one group. groupMinSize: impose a minimum number of particles per group.

getDefocusAvg()[source]
getDefocusMax()[source]
getGroupByCTF(ctf)[source]

Get the CTF group for this ctf.

getGroupByName(groupName)[source]

Return the Group for a given Name. If not exists, return None.

getSize()[source]
class pwem.objects.data.SetOfFSCs(filename=None, prefix='', mapperClass=None, classesDict=None, **kwargs)[source]

Bases: EMSet

Represents a set of FSCs

ITEM_TYPE

alias of FSC

class pwem.objects.data.SetOfImages(**kwargs)[source]

Bases: EMSet

Represents a set of Images

ITEM_TYPE

alias of Image

append(image)[source]

Add a image to the set.

appendFromClasses(classesSet, filterClassFunc=None)[source]

Iterate over the classes and the element inside each class and append to the set all that are enabled.

appendFromImages(imagesSet, itemSelectedCallback=None)[source]

Iterate over the images and append every image that is enabled.

Parameters
  • imagesSet – Set to go copy items from

  • itemSelectedCallback – Optional, callback receiving an item and returning true if it has to be added

copyInfo(other)[source]

Copy basic information (sampling rate and ctf) from other set of images to current one

getAcquisition()[source]
getAlignment()[source]
getClassNameStr()[source]
getDim()[source]

Return the dimensions of the first image in the set.

getDimensions()[source]

Return first image dimensions as a tuple: (xdim, ydim, zdim)

getFiles()[source]

Get all filePaths

getSamplingRate()[source]
getXDim()[source]
hasAcquisition()[source]
hasAlignment()[source]
hasAlignment2D()[source]
hasAlignment3D()[source]
hasAlignmentProj()[source]
hasCTF()[source]

Return True if the SetOfImages has associated a CTF model

isAmplitudeCorrected()[source]
isOddX()[source]

Return True if the first item x dimension is odd.

isPhaseFlipped()[source]
iterItems(orderBy='id', direction='ASC', where='1', limit=None, iterate=True)[source]

Redefine iteration to set the acquisition to images.

readStack(fnStack, postprocessImage=None)[source]

Populate the set with the images in the stack

setAcquisition(acquisition)[source]
setAlignment(value)[source]
setAlignment2D()[source]
setAlignment3D()[source]
setAlignmentProj()[source]
setDim(newDim)[source]
setDownsample(downFactor)[source]

Update the values of samplingRate and scannedPixelSize after applying a downsampling factor of downFactor.

setHasCTF(value)[source]
setIsAmplitudeCorrected(value)[source]
setIsPhaseFlipped(value)[source]
setSamplingRate(samplingRate)[source]

Set the sampling rate and adjust the scannedPixelSize.

writeStack(fnStack, orderBy='id', direction='ASC', applyTransform=False)[source]
class pwem.objects.data.SetOfMicrographs(**kwargs)[source]

Bases: SetOfMicrographsBase

Represents a set of Micrographs

ITEM_TYPE

alias of Micrograph

class pwem.objects.data.SetOfMicrographsBase(**kwargs)[source]

Bases: SetOfImages

Create a base class for both Micrographs and Movies, but avoid to select Movies when Micrographs are required.

copyInfo(other)[source]

Copy basic information (voltage, spherical aberration and sampling rate) from other set of micrographs to current one.

getScannedPixelSize()[source]
setSamplingRate(samplingRate)[source]

Set the sampling rate and adjust the scannedPixelSize.

setScannedPixelSize(scannedPixelSize)[source]

Set scannedPixelSize and update samplingRate.

class pwem.objects.data.SetOfMovieParticles(**kwargs)[source]

Bases: SetOfParticles

This is just to distinguish the special case when the particles have been extracted from a set of movies.

ITEM_TYPE

alias of MovieParticle

class pwem.objects.data.SetOfMovies(**kwargs)[source]

Bases: SetOfMicrographsBase

Represents a set of Movies.

ITEM_TYPE

alias of Movie

copyInfo(other)[source]

Copy SoM specific information plus inherited

getDark()[source]
getFramesRange()[source]
getGain()[source]
setDark(dark)[source]
setFramesRange(value)[source]
setGain(gain)[source]
class pwem.objects.data.SetOfNormalModes(**kwargs)[source]

Bases: EMSet

Set containing NormalMode items.

ITEM_TYPE

alias of NormalMode

copyInfo(other)[source]

Define a dummy copyInfo function to be used for some generic operations on sets.

getPdb()[source]
setPdb(pdbFile)[source]
class pwem.objects.data.SetOfPDBs[source]

Bases: SetOfAtomStructs

Set containing PDB items.

class pwem.objects.data.SetOfParticles(**kwargs)[source]

Bases: SetOfImages

Represents a set of Particles. The purpose of this class is to separate the concepts of Micrographs and Particles, even if both are considered Images

ITEM_TYPE

alias of Particle

REP_TYPE

alias of Particle

copyInfo(other)[source]

Copy basic information (voltage, spherical aberration and sampling rate) from other set of micrographs to current one.

getClassNameStr()[source]
getCoordinates()[source]

Returns the SetOfCoordinates associated with this SetOfParticles

getIsSubparticles()[source]
hasCoordinates()[source]
setCoordinates(coordinates)[source]

Set the SetOfCoordinates associated with this set of particles.

setIsSubparticles(value)[source]
class pwem.objects.data.SetOfPrincipalComponents(**kwargs)[source]

Bases: SetOfNormalModes

Set of Principal Components is a SetOfNormalModes with a new name

class pwem.objects.data.SetOfSequences(**kwargs)[source]

Bases: EMSet

Set containing Sequence items.

ITEM_TYPE

alias of Sequence

exportToFile(seqFileName)[source]

Writes the sequences in the set in the specified file

importFromFile(seqFileName, isAmino=True, type=None)[source]

Appends elements to the set from sequences found in the specified file

class pwem.objects.data.SetOfVolumes(**kwargs)[source]

Bases: SetOfImages

Represents a set of Volumes

EXPOSE_ITEMS = True
ITEM_TYPE

alias of Volume

REP_TYPE

alias of Volume

class pwem.objects.data.Transform(matrix=None, **kwargs)[source]

Bases: EMObject

This class will contain a transformation matrix that can be applied to 2D/3D objects like images and volumes. It should contain information about euler angles, translation(or shift) and mirroring. Shifts are stored in pixels as treated in extract coordinates, or assign angles,…

ROT_X_90_CLOCKWISE = 'rotX90c'
ROT_X_90_COUNTERCLOCKWISE = 'rotX90cc'
ROT_Y_90_CLOCKWISE = 'rotY90c'
ROT_Y_90_COUNTERCLOCKWISE = 'rotY90cc'
ROT_Z_90_CLOCKWISE = 'rotZ90c'
ROT_Z_90_COUNTERCLOCKWISE = 'rotZ90cc'
composeTransform(matrix)[source]

Apply a transformation matrix to the current matrix

classmethod create(type)[source]
getMatrix()[source]
getMatrixAsList()[source]

Return the values of the Matrix as a list.

getRotationMatrix()[source]
getShifts()[source]
invert()[source]
scale(factor)[source]
scaleShifts(factor)[source]
setMatrix(matrix)[source]
setShifts(x, y, z)[source]
setShiftsTuple(shifts)[source]
class pwem.objects.data.Volume(location=None, **kwargs)[source]

Bases: Image

Represents an EM Volume object

Params:

Parameters

location – Could be a valid location: (index, filename)

or filename

fixMRCVolume(setSamplingRate=False)[source]

Fixes the header of the mrc file pointed by this object

Parameters

setSamplingRate – if true, it will set the header’s sampling rate of the MRC file it refers

getClassId()[source]
getDim()[source]

Return image dimensions as tuple: (Xdim, Ydim, Zdim)

getHalfMaps(asList=False)[source]
hasClassId()[source]
hasHalfMaps()[source]
setClassId(classId)[source]
setHalfMaps(listFileNames)[source]
class pwem.objects.data.VolumeMask(location=None, **kwargs)[source]

Bases: Volume

A 3D mask to be used with volumes.

Params:

Parameters

location – Could be a valid location: (index, filename)

or filename