Generalized python types and validators for cryoEM data.
Project description
cryotypes
cryotypes
defines 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 image
Each cryotype defines an experiment_id
attribute 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.
Image
An Image
is a dataclass holding a simple data array and some metadata.
Image fields
Field | Semantics |
---|---|
data |
image data (ZYX ordering) |
experiment_id |
identifier for micrograph/tilt-series |
pixel_spacing |
isotropic pixel/voxel spacing |
source |
the source file of this data |
stack |
whether the data represent a stack of 2D images |
PoseSet
A PoseSet
is 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 fields
Field | Semantics |
---|---|
position |
particle positions (x, y, z) in pixels |
shift |
particle shifts (x, y, z) in pixels |
orientation |
particle orientation |
experiment_id |
identifier for micrograph/tilt-series |
pixel_spacing |
isotropic pixel/voxel spacing for particle positions |
source |
the source file of this data |
Positions
Particle 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.
Shifts
Particle shifts are in image pixels and are additive to positions,
such that POSITION + SHIFT
is the position of the particle in the tomogram.
Orientations
Particle orientations are stored as
scipy.spatial.transform.Rotation
objects. 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!
ProjectionModel
A ProjectionModel
is a pandas DataFrame
with specific column
headings for the parameters of a projection model. Together, this information constitues a 'tilt-series alignment'.
Heading | Python name | Semantics |
---|---|---|
rotation_x |
ROTATION_X | specimen rotation around x-axis |
rotation_y |
ROTATION_Y | specimen rotation around y-axis |
rotation_z |
ROTATION_Z | specimen rotation around z-axis |
dx |
SHIFT_X | specimen shift in x-dimension of the camera plane |
dy |
SHIFT_Y | particle shift in y-dimension of the camera plane |
experiment_id |
EXPERIMENT_ID | identifier for micrograph/tilt-series |
pixel_spacing |
PIXEL_SPACING | isotropic pixel/voxel spacing for shifts |
source |
SOURCE | reference to the file from which data came |
In 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 by
rotation_x
, rotation_y
, rotation_z
followed by projection along the z-axis (beam direction)
then shifting the 2D image in the camera plane by dx
and dy
produces 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.
from cryotypes.projectionmodel import projection_model_to_projection_matrices
projection_matrices = projection_model_to_projection_matrices(
df=projection_model, # ProjectionModel dataframe
tilt_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.
Tomogram
A Tomogram
is an object that follows a specific
python Protocol
for 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cryotypes-0.2.0.tar.gz
.
File metadata
- Download URL: cryotypes-0.2.0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f793daa00d1ace96ac60dc38072b189aba1d737351b89de2ba5475c26f74a213 |
|
MD5 | 8ae1fa051082b21b33e14b72267d55d6 |
|
BLAKE2b-256 | 80e2ff4c9c9f165023ad8f3df18987cf3dfebaf1841baa46e9abd1af72a9f23b |
Provenance
File details
Details for the file cryotypes-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: cryotypes-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fc3896437e5f7c0a1a87bc7799df86d56df07e3b652d6a087d99a9445a104d8 |
|
MD5 | 3c145be86a2f246c279b115f8570ec8f |
|
BLAKE2b-256 | 3ced105d851629561f1d1b109d1d73bddc549caa00e90f1b836fb509cc82cb35 |