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.0rc1.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.0rc1-py3-none-any.whl (89.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: torch_ctf_estimation-0.6.0rc1.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.0rc1.tar.gz
Algorithm Hash digest
SHA256 7ab14ec4b5b1935856aded9736bda67f426ab1bb633ee23f4546cbc4e0c36949
MD5 034254c34aaee7a05549792ff7068b14
BLAKE2b-256 ceea8e39d010ad5350d8aced5096ff7003f41b98a9e38cc95930a40a8c899b8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_ctf_estimation-0.6.0rc1.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.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_ctf_estimation-0.6.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 a20d002deae5749a7dca329fabd40e38bb64b6570e668d4c7cc442e5439e0d07
MD5 947ccbf8c1a53509d5049eb38083c403
BLAKE2b-256 2605eba70a9c3c082b698da1d7dbd9708eefcd63726ebfe8069082148a877bf5

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_ctf_estimation-0.6.0rc1-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.0rc1 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