torch-ctf-estimation 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- torch_ctf_estimation-0.6.0/.gitignore +115 -0
- torch_ctf_estimation-0.6.0/LICENSE +29 -0
- torch_ctf_estimation-0.6.0/PKG-INFO +95 -0
- torch_ctf_estimation-0.6.0/README.md +60 -0
- torch_ctf_estimation-0.6.0/pyproject.toml +147 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/__init__.py +78 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf.py +663 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_1d/__init__.py +23 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_1d/equiphase_ctf_1d.py +505 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_1d/estimate_ctf_1d.py +358 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_1d/estimate_ctf_1d_utils.py +886 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_1d/estimate_gof_resolution_1d.py +361 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_1d/estimate_thickness_1d.py +170 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_1d/refine_defocus_and_thickness_1d.py +254 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/__init__.py +27 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/ctf_loss_2d.py +283 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/estimate_background_2d.py +62 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/estimate_ctf_2d.py +227 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/estimate_ctf_2d_utils.py +333 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/estimate_defocus_2d_grid.py +489 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/estimate_defocus_2d_linear.py +836 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/estimate_thickness_2d.py +303 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/phase_shift_2d.py +246 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/estimate_ctf_2d/refine_defocus_and_thickness_2d.py +332 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/metrics/__init__.py +11 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/metrics/fit_metrics.py +56 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/models/__init__.py +49 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/models/input_models.py +198 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/models/output_models.py +80 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/models/results_models.py +341 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/py.typed +0 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/__init__.py +1 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/data_io.py +223 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/defocus_field_from_1d.py +200 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/early_stopping.py +44 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/fitting_bounds.py +61 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/laser_axis_mask.py +110 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/normalize.py +33 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/patches.py +119 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/plotting.py +490 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/prepare_image.py +54 -0
- torch_ctf_estimation-0.6.0/src/torch_ctf_estimation/utils/tilt_corrected_ps.py +380 -0
- torch_ctf_estimation-0.6.0/tests/test_data_io.py +190 -0
- torch_ctf_estimation-0.6.0/tests/test_early_stopping.py +48 -0
- torch_ctf_estimation-0.6.0/tests/test_equiphase.py +176 -0
- torch_ctf_estimation-0.6.0/tests/test_estimate_ctf.py +510 -0
- torch_ctf_estimation-0.6.0/tests/test_estimate_ctf_and_thickness.py +136 -0
- torch_ctf_estimation-0.6.0/tests/test_fit_metrics.py +46 -0
- torch_ctf_estimation-0.6.0/tests/test_gof_resolution_1d.py +94 -0
- torch_ctf_estimation-0.6.0/tests/test_joint_refine.py +152 -0
- torch_ctf_estimation-0.6.0/tests/test_prepare_patches.py +65 -0
- torch_ctf_estimation-0.6.0/tests/test_thickness.py +208 -0
- torch_ctf_estimation-0.6.0/tests/test_tilt_corrected_ps.py +164 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
env/
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
|
|
28
|
+
.DS_Store
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
.hypothesis/
|
|
48
|
+
.pytest_cache/
|
|
49
|
+
|
|
50
|
+
# Files downloaded for unit tests
|
|
51
|
+
**/tests/tmp/
|
|
52
|
+
|
|
53
|
+
# Translations
|
|
54
|
+
*.mo
|
|
55
|
+
*.pot
|
|
56
|
+
|
|
57
|
+
# Django stuff:
|
|
58
|
+
*.log
|
|
59
|
+
local_settings.py
|
|
60
|
+
|
|
61
|
+
# Flask stuff:
|
|
62
|
+
instance/
|
|
63
|
+
.webassets-cache
|
|
64
|
+
|
|
65
|
+
# Scrapy stuff:
|
|
66
|
+
.scrapy
|
|
67
|
+
|
|
68
|
+
# Sphinx documentation
|
|
69
|
+
docs/_build/
|
|
70
|
+
|
|
71
|
+
# PyBuilder
|
|
72
|
+
target/
|
|
73
|
+
|
|
74
|
+
# Jupyter Notebook
|
|
75
|
+
.ipynb_checkpoints
|
|
76
|
+
|
|
77
|
+
# dotenv
|
|
78
|
+
.env
|
|
79
|
+
|
|
80
|
+
# virtualenv
|
|
81
|
+
.venv
|
|
82
|
+
venv/
|
|
83
|
+
ENV/
|
|
84
|
+
|
|
85
|
+
# Spyder project settings
|
|
86
|
+
.spyderproject
|
|
87
|
+
.spyproject
|
|
88
|
+
|
|
89
|
+
# Rope project settings
|
|
90
|
+
.ropeproject
|
|
91
|
+
|
|
92
|
+
# mkdocs documentation
|
|
93
|
+
/site
|
|
94
|
+
|
|
95
|
+
# mypy
|
|
96
|
+
.mypy_cache/
|
|
97
|
+
|
|
98
|
+
# ruff
|
|
99
|
+
.ruff_cache/
|
|
100
|
+
|
|
101
|
+
# IDEs
|
|
102
|
+
.idea/
|
|
103
|
+
.vscode/
|
|
104
|
+
|
|
105
|
+
# Mojo extension compile cache (experimental torch-fourier-slice kernels)
|
|
106
|
+
__mojocache__/
|
|
107
|
+
*.mojopkg
|
|
108
|
+
# experimental demo outputs
|
|
109
|
+
packages/primitives/torch-fourier-slice/examples/*.npz
|
|
110
|
+
packages/primitives/torch-fourier-slice/examples/*.png
|
|
111
|
+
packages/primitives/torch-fourier-slice/examples/*.gif
|
|
112
|
+
# Personal local notes (not for commit)
|
|
113
|
+
notes/*.local.md
|
|
114
|
+
|
|
115
|
+
lightning_logs/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2026, TeamTomo
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: torch-ctf-estimation
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Contrast transfer function estimation for cryo-EM images in PyTorch
|
|
5
|
+
Project-URL: homepage, https://github.com/teamtomo/teamtomo
|
|
6
|
+
Project-URL: repository, https://github.com/teamtomo/teamtomo
|
|
7
|
+
Author-email: Alister Burt <alisterburt@gmail.com>, Josh Dickerson <jdickerson@berkeley.edu>
|
|
8
|
+
License: BSD-3-Clause
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Requires-Dist: einops
|
|
20
|
+
Requires-Dist: numpy
|
|
21
|
+
Requires-Dist: pydantic<3,>=2.0
|
|
22
|
+
Requires-Dist: scipy
|
|
23
|
+
Requires-Dist: teamtomo-basemodel
|
|
24
|
+
Requires-Dist: torch
|
|
25
|
+
Requires-Dist: torch-ctf
|
|
26
|
+
Requires-Dist: torch-cubic-spline-grids
|
|
27
|
+
Requires-Dist: torch-fourier-filter
|
|
28
|
+
Requires-Dist: torch-fourier-rescale
|
|
29
|
+
Requires-Dist: torch-grid-utils
|
|
30
|
+
Requires-Dist: torch-image-interpolation
|
|
31
|
+
Requires-Dist: torchvision
|
|
32
|
+
Provides-Extra: plot
|
|
33
|
+
Requires-Dist: matplotlib; extra == 'plot'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# torch-ctf-estimation
|
|
37
|
+
|
|
38
|
+
Contrast transfer function estimation for cryo-EM images in PyTorch.
|
|
39
|
+
|
|
40
|
+
## Overview
|
|
41
|
+
|
|
42
|
+
`torch-ctf-estimation` fits defocus, astigmatism, and (optionally) sample
|
|
43
|
+
thickness from a micrograph power spectrum.
|
|
44
|
+
|
|
45
|
+
- 1D defocus on the mean spectrum, then 2D defocus / astigmatism on patches
|
|
46
|
+
- Spatial defocus as a spline grid or a linear tilt model
|
|
47
|
+
- 1D thickness grid search against a thickness-modulated CTF, with optional
|
|
48
|
+
joint defocus+thickness refinement (1D scalar or 2D field)
|
|
49
|
+
- Laser phase plate (LPP) CTF support via `torch-ctf`
|
|
50
|
+
|
|
51
|
+
This package is the algorithm: `estimate_ctf` (defocus only) and
|
|
52
|
+
`estimate_ctf_and_thickness` (defocus + thickness) are self-contained
|
|
53
|
+
compositions of the lower-level primitives, usable directly from notebooks,
|
|
54
|
+
tests, or another program. Downstream tools can chain these primitives
|
|
55
|
+
differently and add optics / metrics file I/O.
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
This package is part of the [TeamTomo monorepo](https://github.com/teamtomo/teamtomo).
|
|
60
|
+
See the main repository README for development setup instructions.
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import torch
|
|
66
|
+
from torch_ctf_estimation import estimate_ctf
|
|
67
|
+
from torch_ctf_estimation.models import CTFFittingParams, OpticalParams
|
|
68
|
+
|
|
69
|
+
image = torch.randn(1024, 1024)
|
|
70
|
+
optical = OpticalParams(
|
|
71
|
+
pixel_spacing_angstroms=1.0,
|
|
72
|
+
voltage_kev=300.0,
|
|
73
|
+
spherical_aberration_mm=2.7,
|
|
74
|
+
amplitude_contrast_fraction=0.07,
|
|
75
|
+
)
|
|
76
|
+
fitting = CTFFittingParams(
|
|
77
|
+
defocus_grid_resolution=(1, 3, 3),
|
|
78
|
+
frequency_fit_range_angstroms=(30.0, 5.0),
|
|
79
|
+
defocus_range_microns=(0.5, 5.0),
|
|
80
|
+
patch_sidelength=128,
|
|
81
|
+
)
|
|
82
|
+
mean_ps, result1d, result2d = estimate_ctf(image, optical, fitting)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
To also estimate sample thickness, use `estimate_ctf_and_thickness` with a
|
|
86
|
+
`ThicknessParams`:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from torch_ctf_estimation import estimate_ctf_and_thickness
|
|
90
|
+
from torch_ctf_estimation.models import ThicknessParams
|
|
91
|
+
|
|
92
|
+
thickness = ThicknessParams(refine_dim="2d")
|
|
93
|
+
result = estimate_ctf_and_thickness(image, optical, fitting, thickness)
|
|
94
|
+
result.result2d, result.thickness1d, result.thickness_joint
|
|
95
|
+
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# torch-ctf-estimation
|
|
2
|
+
|
|
3
|
+
Contrast transfer function estimation for cryo-EM images in PyTorch.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`torch-ctf-estimation` fits defocus, astigmatism, and (optionally) sample
|
|
8
|
+
thickness from a micrograph power spectrum.
|
|
9
|
+
|
|
10
|
+
- 1D defocus on the mean spectrum, then 2D defocus / astigmatism on patches
|
|
11
|
+
- Spatial defocus as a spline grid or a linear tilt model
|
|
12
|
+
- 1D thickness grid search against a thickness-modulated CTF, with optional
|
|
13
|
+
joint defocus+thickness refinement (1D scalar or 2D field)
|
|
14
|
+
- Laser phase plate (LPP) CTF support via `torch-ctf`
|
|
15
|
+
|
|
16
|
+
This package is the algorithm: `estimate_ctf` (defocus only) and
|
|
17
|
+
`estimate_ctf_and_thickness` (defocus + thickness) are self-contained
|
|
18
|
+
compositions of the lower-level primitives, usable directly from notebooks,
|
|
19
|
+
tests, or another program. Downstream tools can chain these primitives
|
|
20
|
+
differently and add optics / metrics file I/O.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
This package is part of the [TeamTomo monorepo](https://github.com/teamtomo/teamtomo).
|
|
25
|
+
See the main repository README for development setup instructions.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import torch
|
|
31
|
+
from torch_ctf_estimation import estimate_ctf
|
|
32
|
+
from torch_ctf_estimation.models import CTFFittingParams, OpticalParams
|
|
33
|
+
|
|
34
|
+
image = torch.randn(1024, 1024)
|
|
35
|
+
optical = OpticalParams(
|
|
36
|
+
pixel_spacing_angstroms=1.0,
|
|
37
|
+
voltage_kev=300.0,
|
|
38
|
+
spherical_aberration_mm=2.7,
|
|
39
|
+
amplitude_contrast_fraction=0.07,
|
|
40
|
+
)
|
|
41
|
+
fitting = CTFFittingParams(
|
|
42
|
+
defocus_grid_resolution=(1, 3, 3),
|
|
43
|
+
frequency_fit_range_angstroms=(30.0, 5.0),
|
|
44
|
+
defocus_range_microns=(0.5, 5.0),
|
|
45
|
+
patch_sidelength=128,
|
|
46
|
+
)
|
|
47
|
+
mean_ps, result1d, result2d = estimate_ctf(image, optical, fitting)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
To also estimate sample thickness, use `estimate_ctf_and_thickness` with a
|
|
51
|
+
`ThicknessParams`:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from torch_ctf_estimation import estimate_ctf_and_thickness
|
|
55
|
+
from torch_ctf_estimation.models import ThicknessParams
|
|
56
|
+
|
|
57
|
+
thickness = ThicknessParams(refine_dim="2d")
|
|
58
|
+
result = estimate_ctf_and_thickness(image, optical, fitting, thickness)
|
|
59
|
+
result.result2d, result.thickness1d, result.thickness_joint
|
|
60
|
+
```
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# https://peps.python.org/pep-0517/
|
|
2
|
+
[build-system]
|
|
3
|
+
requires = ["hatchling", "hatch-vcs"]
|
|
4
|
+
build-backend = "hatchling.build"
|
|
5
|
+
|
|
6
|
+
# https://hatch.pypa.io/latest/config/metadata/
|
|
7
|
+
[tool.hatch.version]
|
|
8
|
+
source = "vcs"
|
|
9
|
+
tag-pattern = "^torch-ctf-estimation@v(?P<version>.+)$"
|
|
10
|
+
fallback-version = "0.5.0"
|
|
11
|
+
|
|
12
|
+
[tool.hatch.version.raw-options]
|
|
13
|
+
search_parent_directories = true
|
|
14
|
+
tag_regex = "^torch-ctf-estimation@v(?P<version>\\d+\\.\\d+\\.\\d+.*)$"
|
|
15
|
+
git_describe_command = "git describe --dirty --tags --long --match 'torch-ctf-estimation@v[0-9]*.[0-9]*.[0-9]*'"
|
|
16
|
+
|
|
17
|
+
# read more about configuring hatch at:
|
|
18
|
+
# https://hatch.pypa.io/latest/config/build/
|
|
19
|
+
[tool.hatch.build.targets.wheel]
|
|
20
|
+
only-include = ["src"]
|
|
21
|
+
sources = ["src"]
|
|
22
|
+
|
|
23
|
+
# https://peps.python.org/pep-0621/
|
|
24
|
+
[project]
|
|
25
|
+
name = "torch-ctf-estimation"
|
|
26
|
+
dynamic = ["version"]
|
|
27
|
+
description = "Contrast transfer function estimation for cryo-EM images in PyTorch"
|
|
28
|
+
readme = "README.md"
|
|
29
|
+
requires-python = ">=3.11"
|
|
30
|
+
license = { text = "BSD-3-Clause" }
|
|
31
|
+
authors = [
|
|
32
|
+
{ name = "Alister Burt", email = "alisterburt@gmail.com" },
|
|
33
|
+
{ name = "Josh Dickerson", email = "jdickerson@berkeley.edu" },
|
|
34
|
+
]
|
|
35
|
+
classifiers = [
|
|
36
|
+
"Development Status :: 3 - Alpha",
|
|
37
|
+
"License :: OSI Approved :: BSD License",
|
|
38
|
+
"Programming Language :: Python :: 3",
|
|
39
|
+
"Programming Language :: Python :: 3.11",
|
|
40
|
+
"Programming Language :: Python :: 3.12",
|
|
41
|
+
"Programming Language :: Python :: 3.13",
|
|
42
|
+
"Programming Language :: Python :: 3.14",
|
|
43
|
+
"Typing :: Typed",
|
|
44
|
+
]
|
|
45
|
+
dependencies = [
|
|
46
|
+
"einops",
|
|
47
|
+
"numpy",
|
|
48
|
+
"pydantic>=2.0,<3",
|
|
49
|
+
"scipy",
|
|
50
|
+
"teamtomo-basemodel",
|
|
51
|
+
"torch",
|
|
52
|
+
"torch-ctf",
|
|
53
|
+
"torch-cubic-spline-grids",
|
|
54
|
+
"torch-fourier-filter",
|
|
55
|
+
"torch-fourier-rescale",
|
|
56
|
+
"torch-grid-utils",
|
|
57
|
+
"torch-image-interpolation",
|
|
58
|
+
"torchvision",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[project.optional-dependencies]
|
|
62
|
+
plot = ["matplotlib"]
|
|
63
|
+
|
|
64
|
+
[project.urls]
|
|
65
|
+
homepage = "https://github.com/teamtomo/teamtomo"
|
|
66
|
+
repository = "https://github.com/teamtomo/teamtomo"
|
|
67
|
+
|
|
68
|
+
[dependency-groups]
|
|
69
|
+
test = ["pytest", "pytest-cov"]
|
|
70
|
+
dev = [
|
|
71
|
+
{ include-group = "test" },
|
|
72
|
+
"ipython",
|
|
73
|
+
"mypy",
|
|
74
|
+
"pdbpp",
|
|
75
|
+
"pre-commit",
|
|
76
|
+
"rich",
|
|
77
|
+
"ruff",
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
[tool.ruff]
|
|
81
|
+
line-length = 88
|
|
82
|
+
target-version = "py311"
|
|
83
|
+
src = ["src"]
|
|
84
|
+
|
|
85
|
+
[tool.ruff.lint]
|
|
86
|
+
pydocstyle = { convention = "numpy" }
|
|
87
|
+
select = [
|
|
88
|
+
"E",
|
|
89
|
+
"W",
|
|
90
|
+
"F",
|
|
91
|
+
"D",
|
|
92
|
+
"D417",
|
|
93
|
+
"I",
|
|
94
|
+
"UP",
|
|
95
|
+
"C4",
|
|
96
|
+
"B",
|
|
97
|
+
"A001",
|
|
98
|
+
"RUF",
|
|
99
|
+
"TCH",
|
|
100
|
+
"TID",
|
|
101
|
+
]
|
|
102
|
+
ignore = [
|
|
103
|
+
"D401",
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
[tool.ruff.lint.per-file-ignores]
|
|
107
|
+
"tests/*.py" = ["D", "S"]
|
|
108
|
+
|
|
109
|
+
[tool.ruff.format]
|
|
110
|
+
docstring-code-format = true
|
|
111
|
+
skip-magic-trailing-comma = false
|
|
112
|
+
|
|
113
|
+
[tool.mypy]
|
|
114
|
+
files = "src/**/"
|
|
115
|
+
strict = true
|
|
116
|
+
disallow_any_generics = false
|
|
117
|
+
disallow_subclassing_any = false
|
|
118
|
+
show_error_codes = true
|
|
119
|
+
pretty = true
|
|
120
|
+
|
|
121
|
+
[tool.pytest.ini_options]
|
|
122
|
+
minversion = "7.0"
|
|
123
|
+
testpaths = ["tests"]
|
|
124
|
+
filterwarnings = [
|
|
125
|
+
"error",
|
|
126
|
+
"ignore:CUDA initialization:UserWarning",
|
|
127
|
+
"ignore:Linear defocus gradient from 1D fits:UserWarning",
|
|
128
|
+
"ignore:Linear defocus gradient angle was NaN:UserWarning",
|
|
129
|
+
]
|
|
130
|
+
|
|
131
|
+
[tool.coverage.report]
|
|
132
|
+
show_missing = true
|
|
133
|
+
exclude_lines = [
|
|
134
|
+
"pragma: no cover",
|
|
135
|
+
"if TYPE_CHECKING:",
|
|
136
|
+
"@overload",
|
|
137
|
+
"except ImportError",
|
|
138
|
+
"\\.\\.\\.",
|
|
139
|
+
"raise NotImplementedError()",
|
|
140
|
+
"pass",
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
[tool.coverage.run]
|
|
144
|
+
source = ["torch_ctf_estimation"]
|
|
145
|
+
|
|
146
|
+
[tool.check-manifest]
|
|
147
|
+
ignore = [".pre-commit-config.yaml", ".ruff_cache/**/*", "tests/**/*"]
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Contrast transfer function estimation for cryo-EM images in PyTorch."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
__version__ = version("torch-ctf-estimation")
|
|
7
|
+
except PackageNotFoundError:
|
|
8
|
+
__version__ = "uninstalled"
|
|
9
|
+
__author__ = "Alister Burt"
|
|
10
|
+
__email__ = "alisterburt@gmail.com"
|
|
11
|
+
|
|
12
|
+
from torch_ctf_estimation.estimate_ctf import (
|
|
13
|
+
CTFEstimationResult,
|
|
14
|
+
estimate_ctf,
|
|
15
|
+
estimate_ctf_and_thickness,
|
|
16
|
+
)
|
|
17
|
+
from torch_ctf_estimation.estimate_ctf_1d import (
|
|
18
|
+
estimate_ctf_1d,
|
|
19
|
+
estimate_thickness_1d,
|
|
20
|
+
fit_background_spline_1d,
|
|
21
|
+
refine_defocus_and_thickness_1d,
|
|
22
|
+
)
|
|
23
|
+
from torch_ctf_estimation.estimate_ctf_2d import (
|
|
24
|
+
estimate_ctf_2d,
|
|
25
|
+
estimate_defocus_2d_at_1x1,
|
|
26
|
+
estimate_thickness_2d,
|
|
27
|
+
refine_defocus_and_thickness_2d,
|
|
28
|
+
)
|
|
29
|
+
from torch_ctf_estimation.models import (
|
|
30
|
+
CTFFittingParams,
|
|
31
|
+
Defocus1DResults,
|
|
32
|
+
Defocus2DResults,
|
|
33
|
+
LaserParams,
|
|
34
|
+
OpticalParams,
|
|
35
|
+
Thickness1DResults,
|
|
36
|
+
Thickness2DResults,
|
|
37
|
+
ThicknessParams,
|
|
38
|
+
)
|
|
39
|
+
from torch_ctf_estimation.utils.defocus_field_from_1d import defocus_field_from_1d_fits
|
|
40
|
+
from torch_ctf_estimation.utils.laser_axis_mask import (
|
|
41
|
+
apply_laser_axis_mask,
|
|
42
|
+
build_laser_axis_mask,
|
|
43
|
+
)
|
|
44
|
+
from torch_ctf_estimation.utils.patches import (
|
|
45
|
+
compute_patch_power_spectra,
|
|
46
|
+
extract_ctf_patches,
|
|
47
|
+
normalised_patch_positions,
|
|
48
|
+
)
|
|
49
|
+
from torch_ctf_estimation.utils.prepare_image import prepare_image_for_ctf
|
|
50
|
+
|
|
51
|
+
__all__ = [
|
|
52
|
+
"CTFEstimationResult",
|
|
53
|
+
"CTFFittingParams",
|
|
54
|
+
"Defocus1DResults",
|
|
55
|
+
"Defocus2DResults",
|
|
56
|
+
"LaserParams",
|
|
57
|
+
"OpticalParams",
|
|
58
|
+
"Thickness1DResults",
|
|
59
|
+
"Thickness2DResults",
|
|
60
|
+
"ThicknessParams",
|
|
61
|
+
"apply_laser_axis_mask",
|
|
62
|
+
"build_laser_axis_mask",
|
|
63
|
+
"compute_patch_power_spectra",
|
|
64
|
+
"defocus_field_from_1d_fits",
|
|
65
|
+
"estimate_ctf",
|
|
66
|
+
"estimate_ctf_1d",
|
|
67
|
+
"estimate_ctf_2d",
|
|
68
|
+
"estimate_ctf_and_thickness",
|
|
69
|
+
"estimate_defocus_2d_at_1x1",
|
|
70
|
+
"estimate_thickness_1d",
|
|
71
|
+
"estimate_thickness_2d",
|
|
72
|
+
"extract_ctf_patches",
|
|
73
|
+
"fit_background_spline_1d",
|
|
74
|
+
"normalised_patch_positions",
|
|
75
|
+
"prepare_image_for_ctf",
|
|
76
|
+
"refine_defocus_and_thickness_1d",
|
|
77
|
+
"refine_defocus_and_thickness_2d",
|
|
78
|
+
]
|