Skip to main content

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: torch_ctf_estimation-0.6.0.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.0.tar.gz
Algorithm Hash digest
SHA256 0406658309b479b47837b41b91cd3e0eaac0124e95e6eea53471f668f4b75b04
MD5 17a0d1521ae9017a301be7cb909f5746
BLAKE2b-256 ec72a34fe89d5c83fc7b765e2cbb4d022fad16a06ace2262b87daf304b2aed32

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for torch_ctf_estimation-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48a134c7d2d18a6d82ffe316d685bc53af33af16657c45078d8a8ae75cbaaa9d
MD5 b8c8e354a78b48bf0e83313e2ff6afe4
BLAKE2b-256 4866ab90beb8c5095f975b22526a43682c4d9423754a6d8f863f9e13fd0f31bf

See more details on using hashes here.

Provenance

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

This release

0.6.0 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