Skip to main content

Tilt-axis angle optimization for tilt series using common lines in PyTorch

Project description

torch-refine-tilt-axis-angle

License PyPI Python Version CI codecov

Tilt-axis angle optimization for tilt series using common lines.

Overview

torch-refine-tilt-axis-angle provides an implementation for finding the in plane rotation for a tilt-series that aligns the tilt axis with the y-axis. This is done by extracting lines from the 2D Fourier transform of the tilt-series images and minimizing the mean squared error between them, i.e. the common lines. It makes use of the pytorch LBFGS optimizer to find the minimum.

Installation

pip install torch-refine-tilt-axis-angle

Usage

import torch
from torch_refine_tilt_axis_angle import refine_tilt_axis_angle
from torch_grid_utils import circle

# Load or create your tilt series
# tilt_series shape: (batch, height, width) - batch is number of tilt images
# Example: tilt_series with shape (61, 512, 512) - 61 tilt images of 512x512 pixels
tilt_series = torch.randn(61, 512, 512)

# Specify an initial guess for the tilt axis angle (the default is 0.0)
# This can be the value from an MDOC file.
initial_tilt_axis_angle = 50.0

# Define a circular mask that removes some noise and help the optimization target.
alignment_mask = circle(236, (512, 512), smoothing_radius=20)

# Run tilt axis angle refinement.
new_tilt_axis_angle = refine_tilt_axis_angle(
    tilt_series=tilt_series,
    alignment_mask=alignment_mask,
    tilt_axis_angle=initial_tilt_axis_angle,
    # grid_points=1,  # optionally increase the spline grid points (default 1)
    # return_single_angle=False,  # optionally write out an angle for each image 
)

Use uv to run an example with simulated data and visualize the results.

uv run examples/simulate_tilt_axis_refinement.py

License

This package is distributed under the BSD 3-Clause License.

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

torch_refine_tilt_axis_angle-0.0.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

torch_refine_tilt_axis_angle-0.0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file torch_refine_tilt_axis_angle-0.0.1.tar.gz.

File metadata

File hashes

Hashes for torch_refine_tilt_axis_angle-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b044dab73906bc83fdf9b69060d6c1d9e0c227f6b6d2463cf57945a20cb3c4b3
MD5 479c49d435d175c3e96b7d0d064d19bf
BLAKE2b-256 0bbba9219ebe90337d69e879ce9d98311b459fb33f828566c89f35bcb00560fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_refine_tilt_axis_angle-0.0.1.tar.gz:

Publisher: ci.yml on teamtomo/torch-refine-tilt-axis-angle

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

File details

Details for the file torch_refine_tilt_axis_angle-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_refine_tilt_axis_angle-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e7914c1c8d2adf38981872ebfcfaf32f366c0ff181b69b32a004c1bfd715a64
MD5 d7cb86f2161f47411c8f96c5c24a3d68
BLAKE2b-256 e51fbe44a17bb244688baa9c67eac7ea3500235353a41b60283972b5599e9cc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_refine_tilt_axis_angle-0.0.1-py3-none-any.whl:

Publisher: ci.yml on teamtomo/torch-refine-tilt-axis-angle

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