Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

torch-ctf-estimation

Contrast transfer function estimation for cryo-EM images in PyTorch.

Overview

torch-ctf-estimation fits defocus, astigmatism, and (optionally) sample thickness from a micrograph power spectrum.

  • 1D defocus on the mean spectrum, then 2D defocus / astigmatism on patches
  • Spatial defocus as a spline grid or a linear tilt model
  • 1D thickness grid search against a thickness-modulated CTF, with optional joint defocus+thickness refinement (1D scalar or 2D field)
  • Laser phase plate (LPP) CTF support via torch-ctf

This package is the algorithm: estimate_ctf (defocus only) and estimate_ctf_and_thickness (defocus + thickness) are self-contained compositions of the lower-level primitives, usable directly from notebooks, tests, or another program. Downstream tools can chain these primitives differently and add optics / metrics file I/O.

Installation

This package is part of the TeamTomo monorepo. See the main repository README for development setup instructions.

Usage

import torch
from torch_ctf_estimation import estimate_ctf
from torch_ctf_estimation.models import CTFFittingParams, OpticalParams

image = torch.randn(1024, 1024)
optical = OpticalParams(
    pixel_spacing_angstroms=1.0,
    voltage_kev=300.0,
    spherical_aberration_mm=2.7,
    amplitude_contrast_fraction=0.07,
)
fitting = CTFFittingParams(
    defocus_grid_resolution=(1, 3, 3),
    frequency_fit_range_angstroms=(30.0, 5.0),
    defocus_range_microns=(0.5, 5.0),
    patch_sidelength=128,
)
mean_ps, result1d, result2d = estimate_ctf(image, optical, fitting)

To also estimate sample thickness, use estimate_ctf_and_thickness with a ThicknessParams:

from torch_ctf_estimation import estimate_ctf_and_thickness
from torch_ctf_estimation.models import ThicknessParams

thickness = ThicknessParams(refine_dim="2d")
result = estimate_ctf_and_thickness(image, optical, fitting, thickness)
result.result2d, result.thickness1d, result.thickness_joint

Download files

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

Source Distribution

torch_ctf_estimation-0.6.0rc2.tar.gz (74.0 kB view details)

Uploaded Source

Built Distribution

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

torch_ctf_estimation-0.6.0rc2-py3-none-any.whl (89.7 kB view details)

Uploaded Python 3

File details

Details for the file torch_ctf_estimation-0.6.0rc2.tar.gz.

File metadata

  • Download URL: torch_ctf_estimation-0.6.0rc2.tar.gz
  • Upload date:
  • Size: 74.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for torch_ctf_estimation-0.6.0rc2.tar.gz
Algorithm Hash digest
SHA256 9aa0f6c56f4ea02701c84fd31aa77ae90749331806998dd5e3aa1752597d6d29
MD5 e6c11067852851e9168a3b428f3b6cef
BLAKE2b-256 d3ddd52fba2b9799b3fa16c53b17f686df64b9a169ad41f7d398107442d236ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_ctf_estimation-0.6.0rc2.tar.gz:

Publisher: deploy.yml on teamtomo/teamtomo

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_ctf_estimation-0.6.0rc2-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_ctf_estimation-0.6.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 4b5c92bdc878816245e59d8a1dd7c64de176d1c1a26cc1501a2443a49357c258
MD5 7e6d4dbc9c0b500e58a4f0a7a574f81b
BLAKE2b-256 3b76f2fe2a877ad5510ac1afd948014fead8872c2617abb95f44bb01369bc998

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_ctf_estimation-0.6.0rc2-py3-none-any.whl:

Publisher: deploy.yml on teamtomo/teamtomo

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

Release history Release notifications | RSS feed

0.6.0

2 files

This release

0.6.0rc2 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page