tomo.objects module

class tomo.objects.AverageSubTomogram(**kwargs)[source]

Bases: tomo.objects.SubTomogram

Represents a Average SubTomogram. It is a SubTomogram but it is useful to differentiate outputs.

class tomo.objects.CTFTomo(**kwargs)[source]

Bases: pwem.objects.data.CTFModel

Represents a generic CTF model for a tilt-image.

appendCutOnFreqList(value)[source]
appendDefocusAngleList(value)[source]
appendDefocusUList(value)[source]
appendDefocusVList(value)[source]
appendPhaseShiftList(value)[source]
completeInfoFromList()[source]

This method will set the _defocusU, _defocusV and _defocusAngle attributes from the provided CTF estimation information lists.

Based on the IMOD program ctfphaseflip: “The program will assign that defocus value to the midpoint of the range of views. For a view at a given tilt angle, it will find the defocus either by interpolating between two surrounding midpoint angles, if there are such angles, or by taking the nearest defocus value, if the angle is beyond the range of the available midpoint angles. ” - From IMOD documentation https://bio3d.colorado.edu/imod/doc/man/ctfphaseflip.html

This method will assign as the defocus value and angle the median of the estimation list.

copyInfo(other, copyId=False)[source]
getCutOnFreq()[source]
getCutOnFreqList()[source]
getDefocusAngleList()[source]
getDefocusUDeviation(mean)[source]
getDefocusUList()[source]
getDefocusVDeviation(mean)[source]
getDefocusVList()[source]
getIndex()[source]
getIsDefocusUDeviationInRange()[source]
getIsDefocusVDeviationInRange()[source]
getPhaseShiftList()[source]
getdefocusUDeviation()[source]
getdefocusVDeviation()[source]
hasAstigmatismInfoAsList()[source]

This method checks if the CTFTomo object contains astigmatism information in the form of a list.

hasCutOnFrequncyInfoAsList()[source]

This method checks if the CTFTomo object contains cut-on frequency information in the form of a list.

hasEstimationInfoAsList()[source]

This method checks if the CTFTomo object contains estimation information in the form of a list.

hasPhaseShiftInfoAsList()[source]

This method checks if the CTFTomo object contains phase shift information in the form of a list.

isDefocusUDeviationInRange(mean, percentage=20)[source]
isDefocusVDeviationInRange(mean, percentage=20)[source]
setCutOnFreq(value)[source]
setCutOnFreqList(cutOnFreqList)[source]
setDefocusAngleList(defList)[source]
setDefocusUList(defList)[source]
setDefocusVList(defList)[source]
setIndex(value)[source]
setIsDefocusUDeviationInRange(value)[source]
setIsDefocusVDeviationInRange(value)[source]
setPhaseShiftList(defList)[source]
class tomo.objects.CTFTomoSeries(**kwargs)[source]

Bases: pwem.objects.data.EMSet

Represents a set of CTF models belonging to the same tilt-series.

ITEM_TYPE

alias of CTFTomo

calculateDefocusUDeviation(defocusUTolerance=20)[source]
calculateDefocusVDeviation(defocusVTolerance=20)[source]
clone(ignoreAttrs=('_mapperPath', '_size'))[source]

Override the clone defined in Object to avoid copying _mapperPath property

getIMODDefocusFileFlag()[source]

Return the format file from which the CTF estimation information has been acquired. This parameter is useful for posterior information and format conversions between IMOD and Scipion. The flag value “is the sum of:

1 if the file has astigmatism values 2 if the astigmatism axis angle is in radians, not degrees 4 if the file has phase shifts 8 if the phase shifts are in radians, not degrees
16 if tilt angles need to be inverted to match what the
program expects (what Ctfplotter would produce) with the -invert option
32 if the file has cut-on frequencies attenuating the phase

at low frequencies”

from https://bio3d.colorado.edu/imod/doc/man/ctfphaseflip.html

getIsDefocusUDeviationInRange()[source]
getIsDefocusVDeviationInRange()[source]
getNumberOfEstimationsInRange()[source]

Return the tilt-images range size used for estimation.

getTiltSeries()[source]

Return the tilt-series associated with this CTF model series.

getTsId()[source]

Get unique TiltSeries ID, usually retrieved from the file pattern provided by the user at the import time.

setIMODDefocusFileFlag(flag)[source]

Set the format file from which the CTF estimation information has been acquired. :param flag: Integer of the range size.

This parameter is useful for posterior information and format conversions between IMOD and Scipion. The flag value “is the sum of:

1 if the file has astigmatism values 2 if the astigmatism axis angle is in radians, not degrees 4 if the file has phase shifts 8 if the phase shifts are in radians, not degrees
16 if tilt angles need to be inverted to match what the
program expects (what Ctfplotter would produce) with the -invert option
32 if the file has cut-on frequencies attenuating the phase

at low frequencies”

from https://bio3d.colorado.edu/imod/doc/man/ctfphaseflip.html

setIsDefocusUDeviationInRange(value)[source]
setIsDefocusVDeviationInRange(value)[source]
setNumberOfEstimationsInRange(estimationRange)[source]

Set the tilt-images range size used for estimation. :param estimationRange: Integer of the range size.

setNumberOfEstimationsInRangeFromDefocusList()[source]

Set the tilt-images estimation range size used for estimation from the defocus info list size.

setTiltSeries(tiltSeries)[source]

Set the tilt-series from which this CTF model series were estimated. :param tiltSeries: Either a TiltSeries object or a pointer to it.

setTsId(value)[source]
class tomo.objects.ClassSubTomogram(**kwargs)[source]

Bases: tomo.objects.SetOfSubTomograms

Represent a Class that groups SubTomogram objects. The representative of the class is an AverageSubTomogram.

REP_TYPE

alias of AverageSubTomogram

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 SubTomograms to current one.

class tomo.objects.Coordinate3D(**kwargs)[source]

Bases: pwem.objects.data.EMObject

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

copyInfo(coord)[source]

Copy information from other coordinate.

euler2Matrix(r, p, y)[source]
eulerAngles()[source]
getBoxSize()[source]
getGroupId()[source]
getMatrix()[source]
getPosition(originFunction)[source]

Get the position a Coordinate3D refered to a given origin defined by originFunction. The input of the method is a funtion (originFunction) which moves the coordinate position refered to the bottom left corner to other origin (retrieved by originFunction) in the grid.

Parameters:

param function originFunction:
 Function to return a Vector to refer a coordinate to the bottom left corner from a given convention.

Example:

>>> origin = originFunction((Lx, Ly, Lz))
>>> (vx, vy, vz)  # Vector to refer (x,y,z) coordinate to an origin from the bottom left corner

Firstly, the Scipion origin vector stored in the Tomogram associated to the Coordinate3D will be applied to refer the current coordinate to the bottom left coordinate of the Tomogram.

getVolId()[source]
getVolName()[source]
getVolume()[source]

Return the micrograph object to which this coordinate is associated.

getVolumeOrigin(angstrom=False)[source]

Return the a vector that can be used to move the position of the Coordinate3D (referred to the center of the Tomogram or other origin specified by the user) to the bottom left corner of the Tomogram

getX(originFunction)[source]

See getPosition method for a full description of how “originFunction” works

getY(originFunction)[source]

See getPosition method for a full description of how “originFunction” works

getZ(originFunction)[source]

See getPosition method for a full description of how “originFunction” works

hasGroupId()[source]
hasTransform()[source]
invertY()[source]
scale(factor)[source]

Scale x, y and z coordinates by a given factor.

setBoxSize(boxSize)[source]
setGroupId(groupId)[source]
setMatrix(matrix)[source]
setPosition(x, y, z, originFunction)[source]

Set the position of the coordinate to be saved in the Coordinate3D object. The inputs of the method are the (x,y,z) position of the coordinate and a funtion (originFunction) which moves the current position to the bottom left corner of the Tomogram with dimensions Lx, Ly, Lz.

Parameters:

param int x:Position of the coordinate in the X axis
param int y:Position of the coordinate in the Y axis
param int z:Position of the coordinate in the Z axis
param function originFunction:
 Function to return a Vector to refer a coordinate to the bottom left corner from a given convention.

Example:

>>> origin = originFunction((Lx, Ly, Lz))
>>> (vx, vy, vz)  # Vector to refer (x,y,z) coordinate to the bottom left corner

In this way, it is possible to apply the Scipion origin vector stored in the Tomogram associated to the Coordinate3D which moves the positions referred to the bottom left corner of a grid to the center of gravity of the grid (or any other origin specified by the user).

IMPORTANT NOTE: For this method to work properly, it is needed to associate the Tomogram before doing a call to this method.

Example:

>>> coord = Coordinate3D()
>>> coord.setPosition(x, y, z, originFunction)
>>> Error: Tomogram is still NoneType
>>> coord.setVolume(Tomogram)
>>> coord.setPosition(x, y, z, originFunction)
>>> Exit: Everything runs normally

This requirement is only needed for “setPostion” method. The remaining attributes of the object can be set either before or after calling “setVolume” method.

setVolId(volId)[source]
setVolume(volume)[source]

Set the micrograph to which this coordinate belongs.

setX(x, originFunction)[source]

See setPosition method for a full description of how “originFunction” works

setY(y, originFunction)[source]

See setPosition method for a full description of how “originFunction” works

setZ(z, originFunction)[source]

See setPosition method for a full description of how “originFunction” works

shiftX(shiftX)[source]
shiftY(shiftY)[source]
shiftZ(shiftZ)[source]
class tomo.objects.Ellipsoid(**kwargs)[source]

Bases: pwem.objects.data.EMObject

This class represent an ellipsoid. This is an instance class of description attribute of object MeshPoint

getAlgebraicDesc()[source]
getCenter()[source]
getRadii()[source]
hasAlgebraicDesc()[source]
setAlgebraicDesc(algebraicDesc)[source]
setCenter(center)[source]
setRadii(radii)[source]
class tomo.objects.LandmarkModel(tsId=None, fileName=None, modelName=None, **kwargs)[source]

Bases: pwem.objects.data.EMObject

Represents the set of landmarks belonging to an specific tilt-series.

addLandmark(xCoor, yCoor, tiltIm, chainId, xResid, yResid)[source]
getFileName()[source]
getModelName()[source]
getTsId()[source]
retrieveInfoTable()[source]

This methods return a table containing the information of the lankmark model. One landmark pero line specifying in order: xCoor, YCoor, tiltIm, chainId, xResid, yResid

setFileName(fileName)[source]
setModelName(modelName)[source]
setTsId(tsId)[source]
class tomo.objects.MeshPoint(**kwargs)[source]

Bases: tomo.objects.Coordinate3D

Mesh object: it stores the coordinates of the points (specified by the user) needed to define the triangulation of a volume. A Mesh object can be consider as a point cloud in 3D containing the coordinates needed to divide a given region of space into planar triangles interconnected that will result in a closed surface.

getDescription()[source]
getVolumeName()[source]
hasDescription()[source]
setDescription(description)[source]
setVolumeName(volName)[source]
class tomo.objects.SetOfAverageSubTomograms(**kwargs)[source]

Bases: tomo.objects.SetOfSubTomograms

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

ITEM_TYPE

alias of AverageSubTomogram

REP_TYPE

alias of AverageSubTomogram

class tomo.objects.SetOfCTFTomoSeries(**kwargs)[source]

Bases: pwem.objects.data.EMSet

Represents a set of CTF model series belonging to the same set of tilt-series.

ITEM_TYPE

alias of CTFTomoSeries

USE_CREATE_COPY_FOR_SUBSET = True
copyInfo(other)[source]

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

getFirstItem()[source]

Return the first item in the Set.

getSetOfTiltSeries()[source]

Return the tilt-series associated with this CTF model series.

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]
setSetOfTiltSeries(setOfTiltSeries)[source]

Set the tilt-series from which this CTF model series were estimated. :param setOfTiltSeries: Either a TiltSeries object or a pointer to it.

class tomo.objects.SetOfClassesSubTomograms(**kwargs)[source]

Bases: pwem.objects.data.SetOfClasses

Store results from a subtomogram averaging method.

ITEM_TYPE

alias of ClassSubTomogram

REP_TYPE

alias of AverageSubTomogram

class tomo.objects.SetOfCoordinates3D(**kwargs)[source]

Bases: pwem.objects.data.EMSet

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

ITEM_TYPE

alias of Coordinate3D

copyInfo(other)[source]

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

getBoxSize()[source]

Return the box size of the particles.

getFiles()[source]

Get all filePaths

getFirstItem()[source]

Return the first item in the Set.

getPrecedents()[source]

Returns the SetOfTomograms or Tilt Series associated with this SetOfCoordinates

getSamplingRate()[source]

Return the sampling rate of the particles.

getSummary()[source]
iterCoordinates(volume=None, orderBy='id')[source]

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

IMPORTANT NOTE: During the storing process in the database, Coordinates3D will lose their pointer to ther associated Tomogram. This method overcomes this problem by retrieving and relinking the Tomogram as if nothing would ever happened.

It is recommended to use this method when working with Coordinates3D, being the common “iterItems” deprecated for this set.

Example:

>>> for coord in coordSet.iterItems()
>>>     print(coord.getVolName())
>>>     Error: Tomogram associated to Coordinate3D is NoneType (pointer lost)
>>> for coord in coordSet.iterCoordinates()
>>>     print(coord.getVolName())
>>>     '/path/to/Tomo.file' retrieved correctly
iterVolumeCoordinates(volume)[source]

Iterates over the set of coordinates belonging to that micrograph.

iterVolumes()[source]

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

setBoxSize(boxSize)[source]

Set the box size of the particles.

setPrecedents(precedents)[source]

Set the tomograms or Tilt Series associated with this set of coordinates. Params:

tomograms: Either a SetOfTomograms or Tilt Series object or a pointer to it.
setSamplingRate(sampling)[source]

Set the sampling rate of the particles.

class tomo.objects.SetOfLandmarkModels(**kwargs)[source]

Bases: pwem.objects.data.EMSet

Represents a class that groups a set of landmark models.

ITEM_TYPE

alias of LandmarkModel

class tomo.objects.SetOfMeshes(**kwargs)[source]

Bases: tomo.objects.SetOfCoordinates3D

Store a series of meshes.

ITEM_TYPE

alias of MeshPoint

getNumberOfMeshes()[source]
setNumberOfMeshes(n)[source]
class tomo.objects.SetOfSubTomograms(**kwargs)[source]

Bases: pwem.objects.data.SetOfVolumes

ITEM_TYPE

alias of SubTomogram

REP_TYPE

alias of SubTomogram

getCoordinates3D()[source]

Returns the SetOfCoordinates associated with this SetOfParticles

hasCoordinates3D()[source]
setCoordinates3D(coordinates)[source]

Set the SetOfCoordinates associates with this set of particles.

class tomo.objects.SetOfTiltSeries(**kwargs)[source]

Bases: tomo.objects.SetOfTiltSeriesBase

ITEM_TYPE

alias of TiltSeries

class tomo.objects.SetOfTiltSeriesBase(**kwargs)[source]

Bases: pwem.objects.data.SetOfImages

EXPOSE_ITEMS = True
USE_CREATE_COPY_FOR_SUBSET = True

Base class for SetOfTiltImages and SetOfTiltImagesM.

copyItems(inputTs, orderByTs='id', updateTsCallback=None, orderByTi='id', updateTiCallback=None)[source]

Copy items (TiltSeries and TiltImages) from the input Set. Params:

inputTs: input TiltSeries (or movies) from where to copy elements. orderByTs: optional orderBy value for iterating over TiltSeries updateTsCallback: optional callback after TiltSeries is created orderByTi: optional orderBy value for iterating over TiltImages updateTiCallback: optional callback after TiltImage is created
getFirstItem()[source]

Return the first item in the Set.

getScannedPixelSize()[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', iterate=True)[source]

Redefine iteration to set the acquisition to images.

updateDim()[source]

Update dimensions of this set base on the first element.

class tomo.objects.SetOfTiltSeriesM(**kwargs)[source]

Bases: tomo.objects.SetOfTiltSeriesBase

ITEM_TYPE

alias of TiltSeriesM

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 tomo.objects.SetOfTomoMasks(*args, **kwargs)[source]

Bases: tomo.objects.SetOfTomograms

EXPOSE_ITEMS = True
ITEM_TYPE

alias of TomoMask

class tomo.objects.SetOfTomograms(*args, **kwargs)[source]

Bases: pwem.objects.data.SetOfVolumes

EXPOSE_ITEMS = True
ITEM_TYPE

alias of Tomogram

updateDim()[source]

Update dimensions of this set base on the first element.

class tomo.objects.SubTomogram(**kwargs)[source]

Bases: pwem.objects.data.Volume

getAcquisition()[source]
getCoordinate3D()[source]

Since the object Coordinate3D needs a volume, use the information stored in the SubTomogram to reconstruct the corresponding Tomogram associated to its Coordinate3D

getVolId()[source]

Return the tomogram id if the coordinate is not None. or have set the _volId property.

getVolName()[source]

Return the tomogram filename if the coordinate is not None. or have set the _volName property.

getVolumeOrigin(angstrom=False)[source]

Return the a vector that can be used to move the position of the Coordinate3D associated to the SubTomogram (referred to the center of the Tomogram or other origin specified by the user) to the bottom left corner of the Tomogram

hasAcquisition()[source]
hasCoordinate3D()[source]
setAcquisition(acquisition)[source]
setCoordinate3D(coordinate)[source]
setVolId(volId)[source]
setVolName(volName)[source]
class tomo.objects.TiltImage(location=None, **kwargs)[source]

Bases: pwem.objects.data.Image, tomo.objects.TiltImageBase

Tilt image

copyInfo(other, copyId=False)[source]

Copy basic information

parseFileName(suffix='', extension=None)[source]

This method returns the filename of the Tilt-Image adding a specified suffix and changing its extension. :param suffix: String to be added at the end of the location path (before extension). :param extension: String containing the new extension of the filename. :return: String containing the parsed filename with the specified suffix and extension.

class tomo.objects.TiltImageBase(tsId=None, tiltAngle=None, acquisitionOrder=None, **kwargs)[source]

Bases: object

Base class for TiltImageM and TiltImage.

copyInfo(other, copyId=False)[source]
getAcquisitionOrder()[source]
getTiltAngle()[source]
getTsId()[source]

Get unique TiltSerie ID, usually retrieved from the file pattern provided by the user at the import time.

setAcquisitionOrder(value)[source]
setTiltAngle(value)[source]
setTsId(value)[source]
class tomo.objects.TiltImageM(location=None, **kwargs)[source]

Bases: pwem.objects.data.Movie, tomo.objects.TiltImageBase

Tilt movie.

copyInfo(other, copyId=False)[source]

Copy basic information

class tomo.objects.TiltSeries(**kwargs)[source]

Bases: tomo.objects.TiltSeriesBase

ITEM_TYPE

alias of TiltImage

applyTransform(outputFilePath)[source]
class tomo.objects.TiltSeriesBase(**kwargs)[source]

Bases: pwem.objects.data.SetOfImages

append(tiltImage)[source]

Add a image to the set.

clone(ignoreAttrs=('_mapperPath', '_size'))[source]

Override the clone defined in Object to avoid copying _mapperPath property

close()[source]
copyInfo(other, copyId=False)[source]

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

generateTltFile(tltFilePath, reverse=False)[source]

Generates an angle file in .tlt format in the specified location. If reverse is set to true the angles in file are sorted in the opposite order. :param tltFilePath: String containing the path where the file is created. :param reverse: Boolean indicating if the angle list must be reversed.

getOrigin(force=False)[source]

Method to get the origin associated to the TiltSeries. If there is no origin associated to the the object it may create a default one. :param force: Boolean indicating if the method must return a default origin in case the object has no one associated.

getScannedPixelSize()[source]
getShiftsFromOrigin()[source]

Method to return the origin shift from the Scipion Transform object.

getTsId()[source]

Get unique TiltSerie ID, usually retrieved from the file pattern provided by the user at the import time.

hasOrigin()[source]

Method indicating if the TiltSeries object has a defined origin.

setOrigin(newOrigin)[source]

Method to set the origin of the TiltSeries object. :param newOrigin: Scipion Transform object indicating the origin to be set to the TiltSeries.

setTsId(value)[source]
updateOriginWithResize(resizeFactor)[source]

Method to update the origin after resizing the TiltSeries.

class tomo.objects.TiltSeriesDict(inputSet=None, outputSet=None, newItemsCallback=None, doneItemsCallback=None)[source]

Bases: object

Helper class that to store TiltSeries and TiltImage but using dictionaries for quick access. This class also contains some logic related to the streaming: - Check for new input items that needs to be processed - Check for items already done that needs to be saved.

addTi(ti)[source]
addTs(ts, includeTi=False)[source]

Add a clone of the tiltseries.

allDone()[source]

Return True if input stream is closed and all task are done.

getTi(tsId, tiObjId)[source]
getTiDict(tsId)[source]
getTiList(tsId)[source]
getTs(tsId)[source]
hasTs(tsId)[source]
setFinished(*tsIdList)[source]

Notify that all TiltSeries in the list of ids are finished.

update()[source]
class tomo.objects.TiltSeriesM(**kwargs)[source]

Bases: tomo.objects.TiltSeriesBase

ITEM_TYPE

alias of TiltImageM

class tomo.objects.TomoAcquisition(angleMin=None, angleMax=None, step=None, angleAxis1=None, angleAxis2=None, **kwargs)[source]

Bases: pwem.objects.data.Acquisition

getAngleAxis1()[source]
getAngleAxis2()[source]
getAngleMax()[source]
getAngleMin()[source]
getStep()[source]
setAngleAxis1(value)[source]
setAngleAxis2(value)[source]
setAngleMax(value)[source]
setAngleMin(value)[source]
setStep(value)[source]
class tomo.objects.TomoMask(**kwargs)[source]

Bases: tomo.objects.Tomogram

Object used to represent segmented tomograms

getTomogram()[source]

Generate the reference tomogram object for the current tomoMask.

getVolName()[source]

Get the reference tomogram file for the current tomoMask.

setVolName(tomoName)[source]

Set the reference tomogram file for the current tomoMask.

class tomo.objects.Tomogram(**kwargs)[source]

Bases: pwem.objects.data.Volume

Class to hold the tomogram abstraction inside Scipion. The origin (self._origin) of the volume is set as the location of the first coordinate loaded from the binary file. The volume may be displaced by setting a different origin using the methods implemented in the inherited class data.Image in scipion-em plugin.

getAcquisition()[source]
getDim()[source]

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

getTsId()[source]

Get unique TiltSeries ID, usually retrieved from the file pattern provided by the user at the import time.

hasAcquisition()[source]
setAcquisition(acquisition)[source]
setTsId(value)[source]