tomo.objects module¶
- class tomo.objects.AverageSubTomogram(**kwargs)[source]¶
Bases:
SubTomogram
Represents a Average SubTomogram. It is a SubTomogram but it is useful to differentiate outputs.
- class tomo.objects.CTFTomo(**kwargs)[source]¶
Bases:
CTFModel
Represents a generic CTF model for a tilt-image.
- 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.
- 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.
- class tomo.objects.CTFTomoSeries(**kwargs)[source]¶
Bases:
EMSet
Represents a set of CTF models belonging to the same tilt-series.
- 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
- 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
- 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.
- class tomo.objects.ClassSubTomogram(**kwargs)[source]¶
Bases:
SetOfSubTomograms
Represent a Class that groups SubTomogram objects. The representative of the class is an AverageSubTomogram.
- REP_TYPE¶
alias of
AverageSubTomogram
- class tomo.objects.Coordinate3D(**kwargs)[source]¶
Bases:
EMObject
This class holds the (x,y,z) position and other information associated with a coordinate
- 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.
- 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
- 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.
- 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
- class tomo.objects.Ellipsoid(**kwargs)[source]¶
Bases:
EMObject
This class represent an ellipsoid. This is an instance class of description attribute of object MeshPoint
- class tomo.objects.LandmarkModel(tsId=None, fileName=None, modelName=None, **kwargs)[source]¶
Bases:
EMObject
Represents the set of landmarks belonging to an specific tilt-series.
- 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
- class tomo.objects.MeshPoint(**kwargs)[source]¶
Bases:
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.
- class tomo.objects.SetOfAverageSubTomograms(**kwargs)[source]¶
Bases:
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:
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.
- getSetOfTiltSeries(pointer=False)[source]¶
Return the tilt-series associated with this CTF model series.
- class tomo.objects.SetOfClassesSubTomograms(**kwargs)[source]¶
Bases:
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:
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.
- getPrecedents()[source]¶
Returns the SetOfTomograms or Tilt Series associated with this SetOfCoordinates
- 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.
- class tomo.objects.SetOfLandmarkModels(**kwargs)[source]¶
Bases:
EMSet
Represents a class that groups a set of landmark models.
- ITEM_TYPE¶
alias of
LandmarkModel
- completeLandmarkModel(lm)[source]¶
This method completes a landmark model object setting in execution time the tilt-series associated to it, since it is not possible to save pointers in the item classes of the set.
IMPORTANT: this method must be implement every time it is necesary to retrive information from the tilt-series associated to the landmark models that compose the set.
- getLandmarkModelFromTsId(tsId)[source]¶
This method return the landmark model belonging to the set that has a coincident input tsId.
- Parameters
tsId – tilt-series ID to search the landmark model into the set.
- class tomo.objects.SetOfMeshes(**kwargs)[source]¶
Bases:
SetOfCoordinates3D
Store a series of meshes.
- class tomo.objects.SetOfSubTomograms(**kwargs)[source]¶
Bases:
SetOfVolumes
- ITEM_TYPE¶
alias of
SubTomogram
- REP_TYPE¶
alias of
SubTomogram
- copyInfo(other)[source]¶
Copy basic information (sampling rate and ctf) from other set of images to current one
- getTomogram(subtomo)[source]¶
returns and caches the tomogram related with a subtomogram. If the subtomograms were imported and not associated to any tomogram returns None.
- iterSubtomos(volume=None, orderBy='id')[source]¶
Iterates over the sutomograms, enriching them with the related tomogram if apply so coordinate getters and setters will work If volume=None, the iteration is performed over the whole set of subtomograms.
IMPORTANT NOTE: During the storing process in the database, Coordinates3D will lose their pointer to the 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 subtomograms, anytime you want to properly use its coordinate3D attached object.
Example:
>>> for subtomo in subtomos.iterItems() >>> print(subtomo.getCoordinate3D().getX(SCIPION)) >>> Error: Tomogram associated to Coordinate3D is NoneType (pointer lost) >>> for subtomo in subtomos.iterSubtomos() >>> print(subtomo.getCoordinate3D().getX(SCIPION)) >>> 330 retrieved correctly
- class tomo.objects.SetOfTiltSeries(**kwargs)[source]¶
Bases:
SetOfTiltSeriesBase
- ITEM_TYPE¶
alias of
TiltSeries
- class tomo.objects.SetOfTiltSeriesBase(**kwargs)[source]¶
Bases:
SetOfImages
- EXPOSE_ITEMS = True¶
- USE_CREATE_COPY_FOR_SUBSET = True¶
Base class for SetOfTiltImages and SetOfTiltImagesM.
- copyInfo(other)[source]¶
Copy information (sampling rate and ctf) from other set of images to current one
- 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
- class tomo.objects.SetOfTiltSeriesCoordinates(**kwargs)[source]¶
Bases:
EMSet
Encapsulate the logic of a set of tilt series coordinates. Each coordinate has a (x,y,z) position in scipion’s convention. Scipion’s convention is the center of a theoretical volume when applying the tilt series transformation matrix: X0 –> half x dimension Y0 –> half y dimension Z0 –> half z of a theoretical volume?
- ITEM_TYPE¶
alias of
TiltSeriesCoordinate
- class tomo.objects.SetOfTiltSeriesM(**kwargs)[source]¶
Bases:
SetOfTiltSeriesBase
- ITEM_TYPE¶
alias of
TiltSeriesM
- class tomo.objects.SetOfTomoMasks(*args, **kwargs)[source]¶
Bases:
SetOfTomograms
- EXPOSE_ITEMS = True¶
- class tomo.objects.SetOfTomograms(*args, **kwargs)[source]¶
Bases:
SetOfVolumes
- EXPOSE_ITEMS = True¶
- class tomo.objects.SubTomogram(**kwargs)[source]¶
Bases:
Volume
- 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.
- class tomo.objects.TiltImage(location=None, **kwargs)[source]¶
Bases:
Image
,TiltImageBase
Tilt image
- 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.
- class tomo.objects.TiltImageM(location=None, **kwargs)[source]¶
Bases:
Movie
,TiltImageBase
Tilt movie.
- class tomo.objects.TiltSeries(**kwargs)[source]¶
Bases:
TiltSeriesBase
- class tomo.objects.TiltSeriesBase(**kwargs)[source]¶
Bases:
SetOfImages
- clone(ignoreAttrs=('_mapperPath', '_size'))[source]¶
Override the clone defined in Object to avoid copying _mapperPath property
- 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.
- getTsId()[source]¶
Get unique TiltSerie ID, usually retrieved from the file pattern provided by the user at the import time.
- class tomo.objects.TiltSeriesCoordinate(**kwargs)[source]¶
Bases:
EMObject
This class holds the (x,y,z) positions, in angstroms, and other information associated with a coordinate related to a tilt series
- getPosition(sampling_rate=1)[source]¶
Returns the position a TiltSeriesCoordinate in a tuple at a specific sampling rate (optional)
- setPosition(x, y, z, sampling_rate)[source]¶
Set the position of the coordinate :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 flat sampling_rate: sampling rate in which x,y,z are measured. Default 1 = Å
- 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.
- class tomo.objects.TiltSeriesM(**kwargs)[source]¶
Bases:
TiltSeriesBase
- ITEM_TYPE¶
alias of
TiltImageM
- class tomo.objects.TomoAcquisition(angleMin=None, angleMax=None, step=None, angleAxis1=None, angleAxis2=None, accumDose=None, tiltAxisAngle=None, **kwargs)[source]¶
Bases:
Acquisition
- class tomo.objects.TomoMask(**kwargs)[source]¶
Bases:
Tomogram
Object used to represent segmented tomograms
- class tomo.objects.Tomogram(**kwargs)[source]¶
Bases:
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.
- tomo.objects.convertMatrix(M, convention=None, direction=None)[source]¶
- Parameters:
M –> Transformation matrix
- convention –> One of the valid conventions to convert M. It can be:
None : Return the matrix stored in the metadata (Scipion convention).
relion (str) : Relion matrix convention
eman (str) : Eman matrix convention
- direction –> Determine how to perform the conversion (not considered if convention is None):
‘get’ (str) : Convert the matrix stored in metadata (Scipion definition) to the given ‘convention’
‘set’ (str) : Convert the matrix from the given ‘convention’ to Scipion definition
Scipion transformation matrix definition is described in detailed below:
- Notation:
r –> A 3D position vector
f’(r) –> Moved map
f(r) –> Reference
M –> Matrix to be stored by Scipion
@ –> Matrix product
Definition:
f’(r) = f(M@r)
Example:
If r = (0,0,0,1) = o (origin vector) and M is a translation only transformation matrix of the form:
M = [[1,0,0,0],[0,1,0,0],[0,0,0,1],[-dx,-dy,-dz,1]]
Being dx, dy, and dz a infinitesimally small displacement, then our transformation verifies that:
f’(o) = f(M@o) = [-dx,-dy,-dz,1]
We include conversions to the following matrix conventions:
Eman: Same as Scipion convention
- Relion:
- Notation:
X’ –> inverse of a matrix
T –> translation matrix
R —> rotation matrix
M –> Scipion transformation matrix
N –> Relion transformation matrix
@ –> Matrix multiplication
- Conversion Scipion –> Relion
M = R@T’ => T = M’@R * N = T@R = M’@R@R *
- Conversion Relion –> Scipion
N = M’@R@R => M’ = N@R’@R’ => * M = R@R@N’ *