vitrio, high-throughput cryo-EM image I/O for C++ and Python

High-throughput image I/O for Cryo-Electron Microscopy (cryo-EM and cryo-ET).

vitrio reads and writes the micrographs, movies, particle stacks, volumes and tomograms that electron microscopy works on. It is made for programs that go through a lot of them, such as particle extraction, single-particle processing pipelines or the training of neural networks. One interface covers MRC, TIFF, EER, DigitalMicrograph and ZARR files, and the pixels go straight into memory you already have: a NumPy array, a PyTorch or JAX tensor, or your own buffer in C++. It is a C++14 library with a Python package on top.

pip install vitrio
import vitrio as vio

micrograph = vio.read("micrograph.mrc")
particle = vio.read(vio.ImageLocation.from_string("12@particles.mrcs"))
tomogram = vio.read("tomogram.zarr")

Reference

Formats

MRC
.mrc, .mrcs, .map, .st, .rec, .ali, and these compressed with gzip, such as the .map.gz of a map in the EMDB. Images, volumes and stacks of either, read and written.
TIFF
.tif, .tiff. Classic and BigTIFF, with one page or many, read and written.
EER
.eer. The movies of an electron-counting detector, read as the events they hold or counted into as many fractions as you ask for.
DigitalMicrograph
.dm3, .dm4. Images and stacks of Gatan software, read.
ZARR
Versions 2 and 3, and OME-Zarr 0.4 and 0.5. Images, volumes and stacks, read, and written in version 3.

Feeding a model

vitrio.data reads a cryo-EM dataset for training in shuffled batches of NumPy arrays, PyTorch tensors or JAX arrays, with the next batches in flight on a thread pool and no worker processes. It takes the locations and the metadata of the particles of a RELION or cryoSPARC job as you parsed them, crops patches around picked centres, and keeps what a run goes back to in a scratch in RAM or on local storage.