Package: cryotypes
cryotypescryotypesdefines a set of super-simple, extensible data structures for the fundamental types of cryoEM data and their relevant metadata:PoseSet: a set of particle poses, compatible with 2D and 3D dataProjectionModel: a set of parameters for a projection model (tilt-series alignments)Tomogram: a 3D imageMicrograph: a 2D imageEach cryotype defines anexperiment_idattribute which is intended as a unique identifier for individual experiments. This can be used, for example, to match particles to the correct tilt series and tomogram.ImageAnImageis a dataclass holding a simple data array and some metadata.Image fieldsFieldSemanticsdataimage data (ZYX ordering)experiment_ididentifier for micrograph/tilt-seriespixel_spacingisotropic pixel/voxel spacingsourcethe source file of this datastackwhether the data represent a stack of 2D imagesPoseSetAPoseSetis a dataclass with a few fields describing positions, orientations and so on for a set of particles. It can be used for both 2D and 3D particle poses.PoseSet fieldsFieldSemanticspositionparticle positions (x, y, z) in pixelsshiftparticle shifts (x, y, z) in pixelsorientationparticle orientationexperiment_ididentifier for micrograph/tilt-seriespixel_spacingisotropic pixel/voxel spacing for particle positionssourcethe source file of this dataPositionsParticle positions are coordinates in 2D or 3D images (for 2D, z is simply set to 0).
The center of the first pixel is taken to be the origin(0, 0, 0)and the units of
particle positions are pixels.ShiftsParticle shifts are in image pixels and are additive to positions,
such thatPOSITION + SHIFTis the position of the particle in the tomogram.OrientationsParticle orientations are stored asscipy.spatial.transform.Rotationobjects. These transformations should rotate the basis vectors (ordered xyz) of a reference such
that they are correctly oriented in a tomogram.Note:this yields rotated basis vectored ordered xyz whilst dimensions in an image are normally zyx!ProjectionModelAProjectionModelis apandasDataFramewith specific column
headings for the parameters of a projection model. Together, this information constitues a 'tilt-series alignment'.HeadingPython nameSemanticsrotation_xROTATION_Xspecimen rotation around x-axisrotation_yROTATION_Yspecimen rotation around y-axisrotation_zROTATION_Zspecimen rotation around z-axisdxSHIFT_Xspecimen shift in x-dimension of the camera planedySHIFT_Yparticle shift in y-dimension of the camera planeexperiment_idEXPERIMENT_IDidentifier for micrograph/tilt-seriespixel_spacingPIXEL_SPACINGisotropic pixel/voxel spacing for shiftssourceSOURCEreference to the file from which data cameIn the microsope reference frame, the z-axis is the beam direction.
Extrinsic rotation of the tomogram around the x-axis, the y-axis, then the z-axis byrotation_x,rotation_y,rotation_zfollowed by projection along the z-axis (beam direction)
then shifting the 2D image in the camera plane bydxanddyproduces the experimental projection
image.A utility function is also provided for generating projection matrices from these data.
These projection matrices can be used to calculate a 2D position in a tilt-image from a 3D position
in the tomogram.fromcryotypes.projectionmodelimportprojection_model_to_projection_matricesprojection_matrices=projection_model_to_projection_matrices(df=projection_model,# ProjectionModel dataframetilt_image_center=(1919,1355),# tilt-image rotation center (xy)tomogram_dimensions=(3838,3710,2000)# dimensions of tomogram (xyz))Note:these projection matrices are only valid for positions in a tomogram of the dimensions
provided in this function and must be recalculated for different tomogram dimensions.TomogramATomogramis an object that follows a specificpythonProtocolfor tomogram data. The protocol specifies the following attributes:data: an array-like 3D image (numpy,dask, ...)experiment_id: experimental identifierpixel_spacing: isotropic pixel/voxel spacing