cryoet-alignment
Convert between different alignment formats used in cryo-ET.
Supported formats:
- IMOD
- AreTomo3
- Warp (global tilt-series alignment)
- RELION 5 (global tilt-series alignment, per-tilt CTF)
- cryoet-data-portal
- SerialEM
.mdoc(tilt angles, dose, acquisition order)
Installation
cryoet-alignment can be installed using pip:
pip install cryoet-alignment
Usage
Reading and writing alignment files
cryoet-alignment provides a simple API to read and write alignment files from different software packages.
IMOD
When processing tomography data using IMOD/etomo, files containing relevant alignment information are usually stored
following the naming convention basename.xf (in-plane parameters), basename.tlt (tilt angles),
basename.xtilt (x-rotation), basename.mrc (unaligned tilt series) and basename_full_rec.mrc (tomogram).
This layout is assumed when reading and writing IMOD alignment files as shown below. Any present tilt.com and
newst.com file in the same directory may also be read.
from cryoet_alignment import read
from cryoet_alignment import write
# Read IMOD alignment files using etomo basename
imod_alignment = read("/path/to/imod_dir/basename")
# Write IMOD file
write(imod_alignment, "/path/to/imod_dir/basename")
AreTomo3
When processing tomography data using AreTomo3, alignment information is stored in a single .aln file. This file can be
read and written as shown below.
from cryoet_alignment import read
from cryoet_alignment import write
# Read AreTomo3 alignment files
aretomo3_alignment = read("/path/to/alignment_file.aln")
# Write AreTomo3 file
write(aretomo3_alignment, "/path/to/alignment_file.aln")
AreTomo3's per-tilt CTF estimates (<name>_CTF.txt, one row per raw tilt including dark frames) can also be read and
written. Because the .txt extension is generic, the reader is never inferred — pass reader="aretomo3_ctf" explicitly.
from cryoet_alignment import read
from cryoet_alignment import write
# Read AreTomo3 CTF estimates
aretomo3_ctf = read("/path/to/name_CTF.txt", reader="aretomo3_ctf")
# Write AreTomo3 CTF file
write(aretomo3_ctf, "/path/to/name_CTF.txt")
AreTomo3's per-tilt angle file (<name>_TLT.txt: tilt angle, 1-based acquisition index and per-image dose, one row per
raw tilt including dark frames; AreTomo3 reads it in preference to <name>.rawtlt) is supported the same way. One- and
two-column files are accepted; pass reader="aretomo3_tlt" explicitly.
from cryoet_alignment import read, write
# Read AreTomo3 tilt file
aretomo3_tlt = read("/path/to/name_TLT.txt", reader="aretomo3_tlt")
aretomo3_tlt.tilts, aretomo3_tlt.acq_indices, aretomo3_tlt.doses
# Write AreTomo3 tilt file
write(aretomo3_tlt, "/path/to/name_TLT.txt")
Warp
Warp stores tilt-series metadata (including the global alignment: tilt angles, per-tilt tilt-axis rotation, and 2D
shifts in Å) in an XML file per tilt series. Only the global alignment is modeled; Warp's local warp grids have no
analog in the other formats and are ignored. Because the .xml extension is generic, the reader is never inferred —
pass reader="warp" explicitly. The tilt-image pixel size (Å/px) is needed to convert the Å shifts to pixels; if not
given, it is read from the XML's CTF PixelSize parameter.
from cryoet_alignment import read
from cryoet_alignment import write
# Read a Warp tilt-series XML
warp_alignment = read("/path/to/tilt_series.xml", reader="warp", pixel_size_a=1.7005)
# Write a Warp tilt-series XML
write(warp_alignment, "/path/to/tilt_series.xml")
Two ancillary Warp project files are supported as well: the .tomostar tilt-series descriptor (_wrpMovieName,
_wrpAngleTilt, _wrpAxisAngle, _wrpDose, extra columns preserved) and the .settings project file
(WarpTools create_settings; WarpSettings.create(...) fills the vendored default document exactly like
create_settings does). Both are inferred from their extensions.
from cryoet_alignment import read, write
from cryoet_alignment.io.warp import WarpSettings, WarpTomostar
tomostar = read("/path/to/tomostar/TS_01.tomostar")
tomostar.movie_names, [r.angle_tilt for r in tomostar.rows]
settings = WarpSettings.create(pixel_size_a=1.54, exposure_per_tilt=3.87, tomo_dims_px=(4096, 4096, 2000))
write(settings, "/path/to/warp_tiltseries.settings")
RELION 5
RELION 5 stores tilt-series metadata in a tomograms.star plus per-tomogram star files. Both on-disk layouts are read:
the RELION-5 layout (rlnTomoTiltSeriesStarFile references) and the relion-4/WarpTools layout (per-tomogram blocks
embedded in one file), including relion-4 projection matrices (rlnTomoProjX/Y/Z/W), which are decomposed into Euler
angles and shifts exactly like RELION does it. Only the global alignment is modeled. Writing emits the RELION-5
two-file layout (tomograms.star + tilt_series/<name>.star). Pass tomo_name when the file lists several tomograms,
and image_size_px when the per-tilt table carries matrices instead of Euler columns.
The per-tilt CTF columns of RELION's CTFFIND job (rlnDefocusU/V/Angle, rlnPhaseShift, rlnCtfMaxResolution,
rlnCtfFigureOfMerit) and rlnMicrographName are read into the optional entry fields defocus_u, defocus_v,
defocus_angle, phase_shift, ctf_max_resolution, ctf_figure_of_merit and micrograph_name, and written back
when every entry carries them.
from cryoet_alignment import read
from cryoet_alignment import write
# Read a RELION tomograms.star (one tomogram)
relion_alignment = read("/path/to/tomograms.star", tomo_name="TS_01")
relion_alignment.has_ctf, relion_alignment.entries[0].defocus_u
# Write the RELION-5 two-file layout
write(relion_alignment, "/path/to/out/tomograms.star")
SerialEM
SerialEM's tilt-series .mdoc (header, [T = ...] titles and one [ZValue = n] section per image) is read into a
SerialEMMdoc. Known keys (TiltAngle, ExposureDose, PriorRecordDose, DateTime, SubFramePath, ...) become typed
fields, all others are kept verbatim and written back unchanged. acquisition_order() derives the 0-based order from
DateTime (falling back to the ZValue order), and pre_exposure() the dose each image received before it was
acquired: PriorRecordDose, else the running sum of ExposureDose in acquisition order.
from cryoet_alignment import read
mdoc = read("/path/to/TS_01.mrc.mdoc") # .mdoc inference -> reader="serialem_mdoc"
mdoc.tilt_angles, mdoc.tilt_axis_angle, mdoc.acquisition_order(), mdoc.pre_exposure()
cryoet-data-portal
Alignment information from the cryoet-data-portal is stored in a JSON file with a schema described here. This file can be read and written as shown below.
from cryoet_alignment import read
from cryoet_alignment import write
# Read cryoet-data-portal alignment files
cryoet_data_portal_alignment = read("/path/to/alignment_file.json")
# Write cryoet-data-portal file
write(cryoet_data_portal_alignment, "/path/to/alignment_file.json")
Convert between different alignment formats
cryoet-alignment provides the ability to convert between different alignment formats. For any conversion, the
alignment object must be read first using the appropriate read function, and then converted to the cryoet-data-portal
format before converting and writing to the desired format.
IMOD to AreTomo3
from cryoet_alignment import read, write
from cryoet_alignment.io.cryoet_data_portal import Alignment
# Read IMOD alignment files using etomo basename
imod_alignment = read("/path/to/imod_dir/basename")
# Convert IMOD to AreTomo3
cdp_alignment = Alignment.from_imod(imod_alignment)
# Write AreTomo3 file
tilt_series_dim = (4096, 4096, 41)
write(cdp_alignment.to_aretomo(ts_size=tilt_series_dim), "/path/to/alignment_file.aln")
AreTomo3 to Warp
from cryoet_alignment import read, write
from cryoet_alignment.io.cryoet_data_portal import Alignment
# Read the AreTomo3 alignment and convert to the canonical format
cdp_alignment = Alignment.from_aretomo3(read("/path/to/alignment_file.aln"), vol_size=(4096, 4096, 2000))
# Convert to Warp and write the tilt-series XML
warp_alignment = cdp_alignment.to_warp(pixel_size_a=1.54, image_size_px=(4096, 4096))
write(warp_alignment, "/path/to/tilt_series.xml")
AreTomo3 to RELION
from cryoet_alignment import read, write
from cryoet_alignment.io.cryoet_data_portal import Alignment
# Read the AreTomo3 alignment and convert to the canonical format
cdp_alignment = Alignment.from_aretomo3(read("/path/to/alignment_file.aln"), vol_size=(4096, 4096, 2000))
# Convert to RELION and write tomograms.star + tilt_series/TS_01.star
relion_alignment = cdp_alignment.to_relion("TS_01", pixel_size_a=1.54)
write(relion_alignment, "/path/to/out/tomograms.star")
cryoet-data-portal to IMOD
It is also possible to convert directly from the cryoet-data-portal client to IMOD/AreTomo format. This is demonstrated below. This requires additional dependencies to be installed using the following command:
pip install cryoet-alignment[cdp]
To convert from the cryoet-data-portal to IMOD, the below code can be used. Briefly, given a tomogram ID, the snippet fetches the alignment information from the cryoet-data-portal, reads the tilt series metadata, and converts the alignment to IMOD format. The resulting alignment files are written to the specified directory with the portal's run name as the base name.
import cryoet_data_portal as cdp
import zarr
from cryoet_alignment.io.cryoet_data_portal import Alignment
from cryoet_alignment import write
# Target tomogram ID
# This is an example from dataset 10004 (https://cryoetdataportal.czscience.com/runs/333)
TOMO_ID = 771
# Get the tomogram from the cryoet-data-portal
client = cdp.Client()
tomogram = cdp.Tomogram.get_by_id(client, TOMO_ID)
# Read cryoet-data-portal alignment from S3
cdp_ali = Alignment.from_s3(tomogram.alignment.s3_alignment_metadata)
# Get the tilt series metadata
#tilt_series = tomogram.alignment.tiltseries < currently unavailable due to a bug in the data portal client
tilt_series = tomogram.run.tiltseries[0]
pixel_size = tilt_series.pixel_spacing
dim_z, dim_y, dim_x = zarr.open(tilt_series.s3_omezarr_dir)['0'].shape
# Convert to IMOD format
imod_ali = cdp_ali.to_imod(ts_size=(dim_x, dim_y, dim_z), ts_spacing=pixel_size)
write(imod_ali, f"/tmp/test/{tomogram.run.name}")
CETS (TomoBabel cryo-ET standard)
cryoet_alignment.io.cets implements the rigid interoperability profile cets-rigid/0.2 (see
docs/cets.md): the canonical Alignment above encodes to / decodes from CETS
ProjectionAlignment sequences with explicit centre-convention bookkeeping, plus entity builders, CTF unit
maps, point / oriented-particle / mask annotations bound to a tomogram (io/cets/annotations.py) with the
Warp, M and RELION 5 particle-star flavours (io/cets/particles_star.py) and the ZYZ Euler pair transcribed
from RELION/Warp (io/cets/euler.py), a companion manifest for what CETS cannot carry, and the value resolver
shared by the converter CLIs cets-aretomo3, cets-warpm and cets-cdp. It needs the CETS model package (git only):
pip install 'cets_data_model @ git+https://github.com/TomoBabel/cets-data-models.git@b415e952d309ac1ec0dee01a3a5db639cb08bba5'
Metadata
Release files for cryoet-alignment 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cryoet_alignment-0.3.0.tar.gz | 337.4 kB | With provenance | Details for cryoet_alignment-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cryoet_alignment-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for cryoet_alignment-0.3.0-py3-none-any.whl |
Total release size: 437.7 kB
Release files / cryoet_alignment-0.3.0.tar.gz
| Download URL | cryoet_alignment-0.3.0.tar.gz |
|---|---|
| Size | 337.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61c26e0f984312021b317b23546e320e92696bc79e8a24b3607e04329b5b2d46
|
|
BLAKE2b-256 checksum How to use checksums |
1c28827a5e5ebb8269cf7f9da89c42301f226050326be21e31bc93e58a67a04e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logRelease files / cryoet_alignment-0.3.0-py3-none-any.whl
| Download URL | cryoet_alignment-0.3.0-py3-none-any.whl |
|---|---|
| Size | 100.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4ee7898763ec942366e08d1dc976003581a7d6088076b69cb81080ef9f37f2b
|
|
BLAKE2b-256 checksum How to use checksums |
b877be149bcd2a48ff238c3c3d5e457684e6a4ce9ee002643e732000b3d2e197
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logSecurity for cryoet-alignment 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cryoet_alignment-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.