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

Metadata

Release files for torch-ctf-estimation 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torch-ctf-estimation 0.6.0
File Size Uploaded Provenance Actions
torch_ctf_estimation-0.6.0.tar.gz 74.0 kB With provenance Details for torch_ctf_estimation-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torch-ctf-estimation 0.6.0
File Interpreter ABI Platform Actions
torch_ctf_estimation-0.6.0-py3-none-any.whl Python 3 none any Details for torch_ctf_estimation-0.6.0-py3-none-any.whl

Total release size: 163.7 kB

Release files / torch_ctf_estimation-0.6.0.tar.gz

Download URL torch_ctf_estimation-0.6.0.tar.gz
Size 74.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0406658309b479b47837b41b91cd3e0eaac0124e95e6eea53471f668f4b75b04
BLAKE2b-256 checksum
How to use checksums
ec72a34fe89d5c83fc7b765e2cbb4d022fad16a06ace2262b87daf304b2aed32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / torch_ctf_estimation-0.6.0-py3-none-any.whl

Download URL torch_ctf_estimation-0.6.0-py3-none-any.whl
Size 89.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48a134c7d2d18a6d82ffe316d685bc53af33af16657c45078d8a8ae75cbaaa9d
BLAKE2b-256 checksum
How to use checksums
4866ab90beb8c5095f975b22526a43682c4d9423754a6d8f863f9e13fd0f31bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Security for torch-ctf-estimation 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for torch_ctf_estimation-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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