A Python package for reading AreTomo alignment files into pandas DataFrames.
Project description
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).
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alnfile-0.1.1.tar.gz.
File metadata
- Download URL: alnfile-0.1.1.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
446b51d909f07514f49e33e274456b8c0991a8926b863902329000f8176611fe
|
|
| MD5 |
7dc3a9d5acf36c753911bdcab4c55ddc
|
|
| BLAKE2b-256 |
09fa20227683447c56563380473879672175790f380a41bd239404acad5bda31
|
Provenance
The following attestation bundles were made for alnfile-0.1.1.tar.gz:
Publisher:
ci.yml on teamtomo/alnfile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alnfile-0.1.1.tar.gz -
Subject digest:
446b51d909f07514f49e33e274456b8c0991a8926b863902329000f8176611fe - Sigstore transparency entry: 630297214
- Sigstore integration time:
-
Permalink:
teamtomo/alnfile@752a1c839116c791932d465b1b9beef1f28fed7c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/teamtomo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@752a1c839116c791932d465b1b9beef1f28fed7c -
Trigger Event:
push
-
Statement type:
File details
Details for the file alnfile-0.1.1-py3-none-any.whl.
File metadata
- Download URL: alnfile-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5858676a1df93c446318a6ba5c31e2e750e9a46a232b64e67b29a78251a2833
|
|
| MD5 |
633b9ee8c0fe71f8c9fb38c2f3a875b5
|
|
| BLAKE2b-256 |
c93fb1b312494849250a9ac646dffabebc2ae7f1ba63187d033e23e20362c08c
|
Provenance
The following attestation bundles were made for alnfile-0.1.1-py3-none-any.whl:
Publisher:
ci.yml on teamtomo/alnfile
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alnfile-0.1.1-py3-none-any.whl -
Subject digest:
c5858676a1df93c446318a6ba5c31e2e750e9a46a232b64e67b29a78251a2833 - Sigstore transparency entry: 630297222
- Sigstore integration time:
-
Permalink:
teamtomo/alnfile@752a1c839116c791932d465b1b9beef1f28fed7c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/teamtomo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@752a1c839116c791932d465b1b9beef1f28fed7c -
Trigger Event:
push
-
Statement type: