Skip to main content

A Python package for reading AreTomo alignment files into pandas DataFrames.

Project description

alnfile

License PyPI Python Version CI codecov

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alnfile-0.1.0.tar.gz (28.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alnfile-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file alnfile-0.1.0.tar.gz.

File metadata

  • Download URL: alnfile-0.1.0.tar.gz
  • Upload date:
  • Size: 28.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for alnfile-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c1010b0cd496d4c3637e966a7eb0d92039697f0306a17724bb1e3693e2b76fb5
MD5 b2943e05dbd2818dae5308a1af5406fd
BLAKE2b-256 faefda6c378c6cbf1a3c5de47af67a3f9ac54c322db2590370b52269a0a670f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for alnfile-0.1.0.tar.gz:

Publisher: ci.yml on teamtomo/alnfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alnfile-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: alnfile-0.1.0-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

Hashes for alnfile-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cf2b7b693f2803591722b012e39ae5f76d76b1d1ab68fb0aadbf9f698350b03
MD5 c39f83bcc6ac0544ae714bc80b4b8b77
BLAKE2b-256 685e636a379d82735848e9c90dea83cdef7ffa1658e4c816fdcbb500cadaf94f

See more details on using hashes here.

Provenance

The following attestation bundles were made for alnfile-0.1.0-py3-none-any.whl:

Publisher: ci.yml on teamtomo/alnfile

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page