alnfile
A Python package for reading AreTomo alignment files into pandas DataFrames, with utilities for converting to IMOD transformation matrices.
Installation
pip install alnfile
Quick start
Basic usage
The main function is alnfile.read() which accepts a file path and an optional alignment type:
import alnfile
# Read either global or local alignments (default global)
global_df = alnfile.read("path/to/your/file.aln")
print(global_df.head())
# Columns: sec, rot, gmag, tx, ty, smean, sfit, scale, base, tilt
# Local alignments
local_df = alnfile.read("file.aln", alignment_type="local")
print(local_df.head())
# Columns: sec_idx, patch_idx, center_x, center_y, shift_x, shift_y, is_reliable
IMOD Transformation Matrices
Convert alignment data to IMOD-compatible transformation matrices:
import alnfile
# Read alignment data
df = alnfile.read("path/to/your/file.aln")
# Convert DataFrame to transformation matrices (IMOD .xf format)
xf_matrices = alnfile.df_to_xf(df) # Returns (n_tilts, 2, 3) array
# Each matrix is [[A11, A12, DX], [A21, A22, DY]]
# Use yx convention (swap rows) if needed for specific applications
xf_matrices_yx = alnfile.df_to_xf(df, yx=True) # Returns (n_tilts, 2, 3) array
# Each matrix is [[A22, A21, DY], [A12, A11, DX]]
Data Structure
Global Alignment DataFrame
| Column | Type | Description |
|---|---|---|
| sec | int | Zero-indexed position in the final aligned stack (excludes dark frames) |
| rot | float | Rotation angle of the tilt axis relative to Y-axis (degrees) |
| gmag | float | Global magnification adjustment factor |
| tx | float | X shift (pixels) |
| ty | float | Y shift (pixels) |
| smean | float | Statistical metric (implementation-specific, see AreTomo docs) |
| sfit | float | Statistical metric (implementation-specific, see AreTomo docs) |
| scale | float | Scaling parameter for this tilt |
| base | float | Implementation-specific parameter (see AreTomo docs) |
| tilt | float | Nominal tilt angle (degrees) |
Local Alignment DataFrame
| Column | Type | Description |
|---|---|---|
| sec_idx | int | Tilt position in final tilt series stack, zero-indexed (post dark frame removal) |
| patch_idx | int | Sequential patch identifier within this tilt image (zero-indexed) |
| center_x | float | Expected x position of patch center relative to image center (pixels) |
| center_y | float | Expected y position of patch center relative to image center (pixels) |
| shift_x | float | Measured x deviation from expected patch position (pixels) |
| shift_y | float | Measured y deviation from expected patch position (pixels) |
| is_reliable | float | Confidence flag for patch alignment quality (1.0=reliable, 0.0=unreliable) |
Rows will have None values for columns not applicable to their type.
Attribution
This implementation has been adapted from a similar reader in cryoet-alignment repository by Utz H. Ermel (@uermel).
Metadata
Release files for alnfile 0.1.1
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 | |
|---|---|---|---|---|
| alnfile-0.1.1.tar.gz | 28.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| alnfile-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.2 kB
Release files / alnfile-0.1.1.tar.gz
| Download URL | alnfile-0.1.1.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
446b51d909f07514f49e33e274456b8c0991a8926b863902329000f8176611fe
|
|
BLAKE2b-256 checksum How to use checksums |
09fa20227683447c56563380473879672175790f380a41bd239404acad5bda31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Oct 22, 2025.
Transparency logRelease files / alnfile-0.1.1-py3-none-any.whl
| Download URL | alnfile-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c5858676a1df93c446318a6ba5c31e2e750e9a46a232b64e67b29a78251a2833
|
|
BLAKE2b-256 checksum How to use checksums |
c93fb1b312494849250a9ac646dffabebc2ae7f1ba63187d033e23e20362c08c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Oct 22, 2025.
Transparency logSecurity for alnfile 0.1.1
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for alnfile-0.1.1.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 Oct 22, 2025.
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.