pytme 0.2.4__tar.gz → 0.2.9__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.
- {pytme-0.2.4 → pytme-0.2.9}/MANIFEST.in +1 -0
- {pytme-0.2.4 → pytme-0.2.9}/PKG-INFO +8 -5
- {pytme-0.2.4 → pytme-0.2.9}/pyproject.toml +6 -5
- {pytme-0.2.4 → pytme-0.2.9}/pytme.egg-info/SOURCES.txt +15 -15
- {pytme-0.2.4 → pytme-0.2.9}/scripts/match_template.py +62 -63
- {pytme-0.2.4 → pytme-0.2.9}/scripts/postprocess.py +45 -83
- {pytme-0.2.4 → pytme-0.2.9}/scripts/preprocess.py +67 -6
- {pytme-0.2.4 → pytme-0.2.9}/scripts/preprocessor_gui.py +153 -74
- {pytme-0.2.4 → pytme-0.2.9}/tests/preprocessing/test_compose.py +1 -1
- {pytme-0.2.4 → pytme-0.2.9}/tests/preprocessing/test_frequency_filters.py +2 -2
- {pytme-0.2.4 → pytme-0.2.9}/tests/preprocessing/test_utils.py +1 -1
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_analyzer.py +26 -120
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_backends.py +81 -10
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_density.py +3 -8
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_matching_cli.py +8 -8
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_matching_exhaustive.py +13 -51
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_matching_memory.py +2 -2
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_matching_optimization.py +1 -51
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_matching_utils.py +0 -137
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_orientations.py +6 -4
- pytme-0.2.9/tests/test_rotations.py +153 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_structure.py +7 -3
- {pytme-0.2.4 → pytme-0.2.9}/tme/__init__.py +1 -0
- pytme-0.2.9/tme/__version__.py +1 -0
- pytme-0.2.9/tme/analyzer/__init__.py +2 -0
- pytme-0.2.9/tme/analyzer/_utils.py +186 -0
- pytme-0.2.9/tme/analyzer/aggregation.py +577 -0
- pytme-0.2.9/tme/analyzer/peaks.py +953 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/backends/__init__.py +21 -15
- pytme-0.2.9/tme/backends/_cupy_utils.py +734 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/backends/_jax_utils.py +1 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/backends/cupy_backend.py +54 -28
- {pytme-0.2.4 → pytme-0.2.9}/tme/backends/jax_backend.py +36 -19
- {pytme-0.2.4 → pytme-0.2.9}/tme/backends/matching_backend.py +59 -21
- {pytme-0.2.4 → pytme-0.2.9}/tme/backends/mlx_backend.py +22 -27
- {pytme-0.2.4 → pytme-0.2.9}/tme/backends/npfftw_backend.py +129 -78
- {pytme-0.2.4 → pytme-0.2.9}/tme/backends/pytorch_backend.py +104 -98
- {pytme-0.2.4 → pytme-0.2.9}/tme/density.py +61 -123
- pytme-0.2.9/tme/filters/__init__.py +6 -0
- {pytme-0.2.4/tme/preprocessing → pytme-0.2.9/tme/filters}/_utils.py +110 -16
- pytme-0.2.9/tme/filters/bandpass.py +230 -0
- {pytme-0.2.4/tme/preprocessing → pytme-0.2.9/tme/filters}/compose.py +27 -1
- pytme-0.2.9/tme/filters/ctf.py +393 -0
- pytme-0.2.9/tme/filters/reconstruction.py +160 -0
- pytme-0.2.9/tme/filters/wedge.py +542 -0
- pytme-0.2.9/tme/filters/whitening.py +191 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/matching_data.py +297 -178
- {pytme-0.2.4 → pytme-0.2.9}/tme/matching_exhaustive.py +149 -178
- {pytme-0.2.4 → pytme-0.2.9}/tme/matching_optimization.py +225 -219
- pytme-0.2.9/tme/matching_scores.py +1183 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/matching_utils.py +261 -340
- {pytme-0.2.4 → pytme-0.2.9}/tme/memory.py +23 -63
- {pytme-0.2.4 → pytme-0.2.9}/tme/orientations.py +64 -204
- {pytme-0.2.4 → pytme-0.2.9}/tme/parser.py +276 -19
- {pytme-0.2.4 → pytme-0.2.9}/tme/preprocessor.py +4 -3
- pytme-0.2.9/tme/rotations.py +350 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/structure.py +257 -92
- pytme-0.2.4/scripts/eval.py +0 -93
- pytme-0.2.4/scripts/extract_candidates.py +0 -257
- pytme-0.2.4/scripts/match_template_filters.py +0 -1200
- pytme-0.2.4/scripts/refine_matches.py +0 -626
- pytme-0.2.4/tests/data/Maps/.DS_Store +0 -0
- pytme-0.2.4/tests/data/Raw/.DS_Store +0 -0
- pytme-0.2.4/tests/data/Structures/.DS_Store +0 -0
- pytme-0.2.4/tests/test_packaging.py +0 -95
- pytme-0.2.4/tme/__version__.py +0 -1
- pytme-0.2.4/tme/analyzer.py +0 -1426
- pytme-0.2.4/tme/matching_scores.py +0 -887
- pytme-0.2.4/tme/preprocessing/__init__.py +0 -2
- pytme-0.2.4/tme/preprocessing/composable_filter.py +0 -32
- pytme-0.2.4/tme/preprocessing/frequency_filters.py +0 -385
- pytme-0.2.4/tme/preprocessing/tilt_series.py +0 -1073
- {pytme-0.2.4 → pytme-0.2.9}/LICENSE +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/README.md +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/scripts/__init__.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/scripts/estimate_ram_usage.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/setup.cfg +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/setup.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/__init__.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Blurring/blob_width18.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Blurring/edgegaussian_sigma3.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Blurring/gaussian_sigma2.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Blurring/hamming_width6.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Blurring/kaiserb_width18.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Blurring/localgaussian_sigma0510.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Blurring/mean_size5.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Blurring/ntree_sigma0510.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Blurring/rank_rank3.npy +0 -0
- {pytme-0.2.4/tests/data → pytme-0.2.9/tests/data/Maps}/.DS_Store +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Maps/emd_8621.mrc.gz +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/README.md +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Raw/em_map.map +0 -0
- {pytme-0.2.4/tests/data/Blurring → pytme-0.2.9/tests/data/Structures}/.DS_Store +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Structures/1pdj.cif +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Structures/1pdj.pdb +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Structures/5khe.cif +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Structures/5khe.ent +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Structures/5khe.pdb +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/data/Structures/5uz4.cif +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/preprocessing/__init__.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/preprocessing/test_preprocessor.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_extensions.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_matching_data.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tests/test_parser.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/__init__.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48n309.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48n527.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48n9.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u1.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u1153.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u1201.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u1641.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u181.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u2219.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u27.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u2947.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u3733.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u4749.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u5879.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u7111.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u815.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u83.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c48u8649.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c600v.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/c600vc.npy +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/metadata.yaml +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/quat_to_numpy.py +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/data/scattering_factors.pickle +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/external/bindings.cpp +0 -0
- {pytme-0.2.4 → pytme-0.2.9}/tme/types.py +0 -0
@@ -67,6 +67,7 @@ prune doc/_build
|
|
67
67
|
prune doc/reference/api
|
68
68
|
global-exclude tme/scoring.py
|
69
69
|
global-exclude tme/package.py
|
70
|
+
global-exclude tme/testing_utils.py
|
70
71
|
global-exclude tme/transforms.py
|
71
72
|
global-exclude tme/tests/test_packaging.py
|
72
73
|
global-exclude scripts/match_template_devel.py
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: pytme
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.9
|
4
4
|
Summary: Python Template Matching Engine
|
5
5
|
Author: Valentin Maurer
|
6
6
|
Author-email: Valentin Maurer <valentin.maurer@embl-hamburg.de>
|
@@ -13,16 +13,16 @@ Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
14
14
|
Requires-Dist: mrcfile>=1.4.3
|
15
15
|
Requires-Dist: numpy<2.0,>=1.22.2
|
16
|
+
Requires-Dist: scipy>=1.9.1
|
16
17
|
Requires-Dist: pyfftw>=0.13.1
|
17
18
|
Requires-Dist: pytest>=6.2.5
|
18
19
|
Requires-Dist: PyYAML>=6.0
|
19
20
|
Requires-Dist: scikit-image>=0.19.0
|
20
|
-
Requires-Dist: scikit_learn>=1.2.1
|
21
|
-
Requires-Dist: scipy>=1.9.1
|
22
21
|
Requires-Dist: pybind11
|
23
22
|
Requires-Dist: psutil
|
24
|
-
Requires-Dist: tifffile
|
25
23
|
Requires-Dist: h5py
|
24
|
+
Requires-Dist: importlib_resources
|
25
|
+
Requires-Dist: joblib
|
26
26
|
Provides-Extra: cupy
|
27
27
|
Requires-Dist: cupy-cuda12x; extra == "cupy"
|
28
28
|
Requires-Dist: voltools==0.6.0; extra == "cupy"
|
@@ -38,6 +38,9 @@ Requires-Dist: voltools==0.6.0; extra == "all"
|
|
38
38
|
Requires-Dist: torch; extra == "all"
|
39
39
|
Requires-Dist: jax; extra == "all"
|
40
40
|
Requires-Dist: jaxlib; extra == "all"
|
41
|
+
Requires-Dist: tifffile; extra == "all"
|
42
|
+
Dynamic: author
|
43
|
+
Dynamic: license-file
|
41
44
|
|
42
45
|
# Python Template Matching Engine (PyTME)
|
43
46
|
|
@@ -7,23 +7,23 @@ name="pytme"
|
|
7
7
|
authors = [
|
8
8
|
{ name = "Valentin Maurer", email = "valentin.maurer@embl-hamburg.de" },
|
9
9
|
]
|
10
|
-
version="0.2.
|
10
|
+
version="0.2.9"
|
11
11
|
description="Python Template Matching Engine"
|
12
12
|
readme="README.md"
|
13
13
|
requires-python = ">=3.11"
|
14
14
|
dependencies=[
|
15
15
|
"mrcfile>=1.4.3",
|
16
16
|
"numpy>=1.22.2,<2.0",
|
17
|
+
"scipy>=1.9.1",
|
17
18
|
"pyfftw>=0.13.1",
|
18
19
|
"pytest>=6.2.5",
|
19
20
|
"PyYAML>=6.0",
|
20
21
|
"scikit-image>=0.19.0",
|
21
|
-
"scikit_learn>=1.2.1",
|
22
|
-
"scipy>=1.9.1",
|
23
22
|
"pybind11",
|
24
23
|
"psutil",
|
25
|
-
"tifffile",
|
26
24
|
"h5py",
|
25
|
+
"importlib_resources",
|
26
|
+
"joblib"
|
27
27
|
]
|
28
28
|
license = {text = "Proprietary"}
|
29
29
|
classifiers = [
|
@@ -40,7 +40,8 @@ all = [
|
|
40
40
|
"voltools==0.6.0",
|
41
41
|
"torch",
|
42
42
|
"jax",
|
43
|
-
"jaxlib"
|
43
|
+
"jaxlib",
|
44
|
+
"tifffile"
|
44
45
|
]
|
45
46
|
|
46
47
|
[project.scripts]
|
@@ -5,14 +5,10 @@ pyproject.toml
|
|
5
5
|
setup.py
|
6
6
|
scripts/__init__.py
|
7
7
|
scripts/estimate_ram_usage.py
|
8
|
-
scripts/eval.py
|
9
|
-
scripts/extract_candidates.py
|
10
8
|
scripts/match_template.py
|
11
|
-
scripts/match_template_filters.py
|
12
9
|
scripts/postprocess.py
|
13
10
|
scripts/preprocess.py
|
14
11
|
scripts/preprocessor_gui.py
|
15
|
-
scripts/refine_matches.py
|
16
12
|
tests/__init__.py
|
17
13
|
tests/test_analyzer.py
|
18
14
|
tests/test_backends.py
|
@@ -25,12 +21,10 @@ tests/test_matching_memory.py
|
|
25
21
|
tests/test_matching_optimization.py
|
26
22
|
tests/test_matching_utils.py
|
27
23
|
tests/test_orientations.py
|
28
|
-
tests/test_packaging.py
|
29
24
|
tests/test_parser.py
|
25
|
+
tests/test_rotations.py
|
30
26
|
tests/test_structure.py
|
31
|
-
tests/data/.DS_Store
|
32
27
|
tests/data/README.md
|
33
|
-
tests/data/Blurring/.DS_Store
|
34
28
|
tests/data/Blurring/blob_width18.npy
|
35
29
|
tests/data/Blurring/edgegaussian_sigma3.npy
|
36
30
|
tests/data/Blurring/gaussian_sigma2.npy
|
@@ -42,7 +36,6 @@ tests/data/Blurring/ntree_sigma0510.npy
|
|
42
36
|
tests/data/Blurring/rank_rank3.npy
|
43
37
|
tests/data/Maps/.DS_Store
|
44
38
|
tests/data/Maps/emd_8621.mrc.gz
|
45
|
-
tests/data/Raw/.DS_Store
|
46
39
|
tests/data/Raw/em_map.map
|
47
40
|
tests/data/Structures/.DS_Store
|
48
41
|
tests/data/Structures/1pdj.cif
|
@@ -58,7 +51,6 @@ tests/preprocessing/test_preprocessor.py
|
|
58
51
|
tests/preprocessing/test_utils.py
|
59
52
|
tme/__init__.py
|
60
53
|
tme/__version__.py
|
61
|
-
tme/analyzer.py
|
62
54
|
tme/density.py
|
63
55
|
tme/matching_data.py
|
64
56
|
tme/matching_exhaustive.py
|
@@ -69,9 +61,15 @@ tme/memory.py
|
|
69
61
|
tme/orientations.py
|
70
62
|
tme/parser.py
|
71
63
|
tme/preprocessor.py
|
64
|
+
tme/rotations.py
|
72
65
|
tme/structure.py
|
73
66
|
tme/types.py
|
67
|
+
tme/analyzer/__init__.py
|
68
|
+
tme/analyzer/_utils.py
|
69
|
+
tme/analyzer/aggregation.py
|
70
|
+
tme/analyzer/peaks.py
|
74
71
|
tme/backends/__init__.py
|
72
|
+
tme/backends/_cupy_utils.py
|
75
73
|
tme/backends/_jax_utils.py
|
76
74
|
tme/backends/cupy_backend.py
|
77
75
|
tme/backends/jax_backend.py
|
@@ -104,9 +102,11 @@ tme/data/metadata.yaml
|
|
104
102
|
tme/data/quat_to_numpy.py
|
105
103
|
tme/data/scattering_factors.pickle
|
106
104
|
tme/external/bindings.cpp
|
107
|
-
tme/
|
108
|
-
tme/
|
109
|
-
tme/
|
110
|
-
tme/
|
111
|
-
tme/
|
112
|
-
tme/
|
105
|
+
tme/filters/__init__.py
|
106
|
+
tme/filters/_utils.py
|
107
|
+
tme/filters/bandpass.py
|
108
|
+
tme/filters/compose.py
|
109
|
+
tme/filters/ctf.py
|
110
|
+
tme/filters/reconstruction.py
|
111
|
+
tme/filters/wedge.py
|
112
|
+
tme/filters/whitening.py
|
@@ -12,26 +12,33 @@ from sys import exit
|
|
12
12
|
from time import time
|
13
13
|
from typing import Tuple
|
14
14
|
from copy import deepcopy
|
15
|
-
from os.path import
|
15
|
+
from os.path import exists
|
16
|
+
from tempfile import gettempdir
|
16
17
|
|
17
18
|
import numpy as np
|
18
19
|
|
20
|
+
from tme.backends import backend as be
|
19
21
|
from tme import Density, __version__
|
20
|
-
from tme.matching_utils import
|
22
|
+
from tme.matching_utils import scramble_phases, write_pickle
|
23
|
+
from tme.matching_exhaustive import scan_subsets, MATCHING_EXHAUSTIVE_REGISTER
|
24
|
+
from tme.rotations import (
|
25
|
+
get_cone_rotations,
|
21
26
|
get_rotation_matrices,
|
22
|
-
get_rotations_around_vector,
|
23
|
-
compute_parallelization_schedule,
|
24
|
-
scramble_phases,
|
25
|
-
write_pickle,
|
26
27
|
)
|
27
|
-
from tme.matching_exhaustive import scan_subsets, MATCHING_EXHAUSTIVE_REGISTER
|
28
28
|
from tme.matching_data import MatchingData
|
29
29
|
from tme.analyzer import (
|
30
30
|
MaxScoreOverRotations,
|
31
31
|
PeakCallerMaximumFilter,
|
32
32
|
)
|
33
|
-
from tme.
|
34
|
-
|
33
|
+
from tme.filters import (
|
34
|
+
CTF,
|
35
|
+
Wedge,
|
36
|
+
Compose,
|
37
|
+
BandPassFilter,
|
38
|
+
WedgeReconstructed,
|
39
|
+
ReconstructFromTilt,
|
40
|
+
LinearWhiteningFilter,
|
41
|
+
)
|
35
42
|
|
36
43
|
|
37
44
|
def get_func_fullname(func) -> str:
|
@@ -43,6 +50,8 @@ def print_block(name: str, data: dict, label_width=20) -> None:
|
|
43
50
|
"""Prints a formatted block of information."""
|
44
51
|
print(f"\n> {name}")
|
45
52
|
for key, value in data.items():
|
53
|
+
if isinstance(value, np.ndarray):
|
54
|
+
value = value.shape
|
46
55
|
formatted_value = str(value)
|
47
56
|
print(f" - {key + ':':<{label_width}} {formatted_value}")
|
48
57
|
|
@@ -122,19 +131,20 @@ def parse_rotation_logic(args, ndim):
|
|
122
131
|
if args.axis_sampling is None:
|
123
132
|
args.axis_sampling = args.cone_sampling
|
124
133
|
|
125
|
-
rotations =
|
134
|
+
rotations = get_cone_rotations(
|
126
135
|
cone_angle=args.cone_angle,
|
127
136
|
cone_sampling=args.cone_sampling,
|
128
137
|
axis_angle=args.axis_angle,
|
129
138
|
axis_sampling=args.axis_sampling,
|
130
139
|
n_symmetry=args.axis_symmetry,
|
140
|
+
axis=[0 if i != args.cone_axis else 1 for i in range(ndim)],
|
141
|
+
reference=[0, 0, -1],
|
131
142
|
)
|
132
143
|
return rotations
|
133
144
|
|
134
145
|
|
135
146
|
def compute_schedule(
|
136
147
|
args,
|
137
|
-
target: Density,
|
138
148
|
matching_data: MatchingData,
|
139
149
|
callback_class,
|
140
150
|
pad_edges: bool = False,
|
@@ -142,27 +152,15 @@ def compute_schedule(
|
|
142
152
|
# User requested target padding
|
143
153
|
if args.pad_edges is True:
|
144
154
|
pad_edges = True
|
145
|
-
|
146
|
-
|
147
|
-
template_box = tuple(0 for _ in range(len(template_box)))
|
148
|
-
|
149
|
-
target_padding = tuple(0 for _ in range(len(template_box)))
|
150
|
-
if pad_edges:
|
151
|
-
target_padding = matching_data._output_template_shape
|
152
|
-
|
153
|
-
splits, schedule = compute_parallelization_schedule(
|
154
|
-
shape1=target.shape,
|
155
|
-
shape2=tuple(int(x) for x in template_box),
|
156
|
-
shape1_padding=tuple(int(x) for x in target_padding),
|
157
|
-
max_cores=args.cores,
|
158
|
-
max_ram=args.memory,
|
159
|
-
split_only_outer=args.use_gpu,
|
155
|
+
|
156
|
+
splits, schedule = matching_data.computation_schedule(
|
160
157
|
matching_method=args.score,
|
161
158
|
analyzer_method=callback_class.__name__,
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
159
|
+
use_gpu=args.use_gpu,
|
160
|
+
pad_fourier=False,
|
161
|
+
pad_target_edges=pad_edges,
|
162
|
+
available_memory=args.memory,
|
163
|
+
max_cores=args.cores,
|
166
164
|
)
|
167
165
|
|
168
166
|
if splits is None:
|
@@ -171,21 +169,15 @@ def compute_schedule(
|
|
171
169
|
" available RAM or decreasing number of cores."
|
172
170
|
)
|
173
171
|
exit(-1)
|
172
|
+
|
174
173
|
n_splits = np.prod(list(splits.values()))
|
175
|
-
if pad_edges is False and n_splits > 1:
|
174
|
+
if pad_edges is False and len(matching_data._target_dim) == 0 and n_splits > 1:
|
176
175
|
args.pad_edges = True
|
177
|
-
return compute_schedule(args,
|
176
|
+
return compute_schedule(args, matching_data, callback_class, True)
|
178
177
|
return splits, schedule
|
179
178
|
|
180
179
|
|
181
180
|
def setup_filter(args, template: Density, target: Density) -> Tuple[Compose, Compose]:
|
182
|
-
from tme.preprocessing import LinearWhiteningFilter, BandPassFilter
|
183
|
-
from tme.preprocessing.tilt_series import (
|
184
|
-
Wedge,
|
185
|
-
WedgeReconstructed,
|
186
|
-
ReconstructFromTilt,
|
187
|
-
)
|
188
|
-
|
189
181
|
needs_reconstruction = False
|
190
182
|
template_filter, target_filter = [], []
|
191
183
|
if args.tilt_angles is not None:
|
@@ -195,7 +187,10 @@ def setup_filter(args, template: Density, target: Density) -> Tuple[Compose, Com
|
|
195
187
|
wedge.weight_type = args.tilt_weighting
|
196
188
|
if args.tilt_weighting in ("angle", None) and args.ctf_file is None:
|
197
189
|
wedge = WedgeReconstructed(
|
198
|
-
angles=wedge.angles,
|
190
|
+
angles=wedge.angles,
|
191
|
+
weight_wedge=args.tilt_weighting == "angle",
|
192
|
+
opening_axis=args.wedge_axes[0],
|
193
|
+
tilt_axis=args.wedge_axes[1],
|
199
194
|
)
|
200
195
|
except FileNotFoundError:
|
201
196
|
tilt_step, create_continuous_wedge = None, True
|
@@ -235,16 +230,18 @@ def setup_filter(args, template: Density, target: Density) -> Tuple[Compose, Com
|
|
235
230
|
weight_wedge=args.tilt_weighting == "angle",
|
236
231
|
create_continuous_wedge=create_continuous_wedge,
|
237
232
|
reconstruction_filter=args.reconstruction_filter,
|
233
|
+
opening_axis=args.wedge_axes[0],
|
234
|
+
tilt_axis=args.wedge_axes[1],
|
238
235
|
)
|
239
236
|
wedge_target = WedgeReconstructed(
|
240
237
|
angles=(np.abs(np.min(tilt_angles)), np.abs(np.max(tilt_angles))),
|
241
238
|
weight_wedge=False,
|
242
239
|
create_continuous_wedge=True,
|
240
|
+
opening_axis=args.wedge_axes[0],
|
241
|
+
tilt_axis=args.wedge_axes[1],
|
243
242
|
)
|
244
243
|
target_filter.append(wedge_target)
|
245
244
|
|
246
|
-
wedge.opening_axis = args.wedge_axes[0]
|
247
|
-
wedge.tilt_axis = args.wedge_axes[1]
|
248
245
|
wedge.sampling_rate = template.sampling_rate
|
249
246
|
template_filter.append(wedge)
|
250
247
|
if not isinstance(wedge, WedgeReconstructed):
|
@@ -255,8 +252,6 @@ def setup_filter(args, template: Density, target: Density) -> Tuple[Compose, Com
|
|
255
252
|
template_filter.append(reconstruction_filter)
|
256
253
|
|
257
254
|
if args.ctf_file is not None or args.defocus is not None:
|
258
|
-
from tme.preprocessing.tilt_series import CTF
|
259
|
-
|
260
255
|
needs_reconstruction = True
|
261
256
|
if args.ctf_file is not None:
|
262
257
|
ctf = CTF.from_file(args.ctf_file)
|
@@ -268,6 +263,7 @@ def setup_filter(args, template: Density, target: Density) -> Tuple[Compose, Com
|
|
268
263
|
"per micrograph."
|
269
264
|
)
|
270
265
|
ctf.angles = wedge.angles
|
266
|
+
ctf.no_reconstruction = False
|
271
267
|
ctf.opening_axis, ctf.tilt_axis = args.wedge_axes
|
272
268
|
else:
|
273
269
|
needs_reconstruction = False
|
@@ -439,6 +435,19 @@ def parse_args():
|
|
439
435
|
help="Half-angle of the cone to be sampled in degrees. Allows to sample a "
|
440
436
|
"narrow interval around a known orientation, e.g. for surface oversampling.",
|
441
437
|
)
|
438
|
+
angular_group.add_argument(
|
439
|
+
"--cone_axis",
|
440
|
+
dest="cone_axis",
|
441
|
+
type=check_positive,
|
442
|
+
default=2,
|
443
|
+
help="Principal axis to build cone around.",
|
444
|
+
)
|
445
|
+
angular_group.add_argument(
|
446
|
+
"--invert_cone",
|
447
|
+
dest="invert_cone",
|
448
|
+
action="store_true",
|
449
|
+
help="Invert cone handedness.",
|
450
|
+
)
|
442
451
|
angular_group.add_argument(
|
443
452
|
"--cone_sampling",
|
444
453
|
dest="cone_sampling",
|
@@ -581,8 +590,8 @@ def parse_args():
|
|
581
590
|
type=str,
|
582
591
|
required=False,
|
583
592
|
default=None,
|
584
|
-
help="Indices of wedge opening and tilt axis, e.g. 0
|
585
|
-
"in z
|
593
|
+
help="Indices of wedge opening and tilt axis, e.g. '2,0' for a wedge open "
|
594
|
+
"in z and tilted over the x-axis.",
|
586
595
|
)
|
587
596
|
filter_group.add_argument(
|
588
597
|
"--tilt_angles",
|
@@ -715,14 +724,6 @@ def parse_args():
|
|
715
724
|
help="Whether to pad the edges of the target. Useful if the target does not "
|
716
725
|
"a well-defined bounding box. Defaults to True if splitting is required.",
|
717
726
|
)
|
718
|
-
performance_group.add_argument(
|
719
|
-
"--pad_fourier",
|
720
|
-
dest="pad_fourier",
|
721
|
-
action="store_true",
|
722
|
-
default=False,
|
723
|
-
help="Whether input arrays should not be zero-padded to full convolution shape "
|
724
|
-
"for numerical stability. Typically only useful when working with small data.",
|
725
|
-
)
|
726
727
|
performance_group.add_argument(
|
727
728
|
"--pad_filter",
|
728
729
|
dest="pad_filter",
|
@@ -785,13 +786,9 @@ def parse_args():
|
|
785
786
|
args.interpolation_order = None
|
786
787
|
|
787
788
|
if args.temp_directory is None:
|
788
|
-
|
789
|
-
if os.environ.get("TMPDIR", None) is not None:
|
790
|
-
default = os.environ.get("TMPDIR")
|
791
|
-
args.temp_directory = default
|
789
|
+
args.temp_directory = gettempdir()
|
792
790
|
|
793
791
|
os.environ["TMPDIR"] = args.temp_directory
|
794
|
-
|
795
792
|
if args.score not in MATCHING_EXHAUSTIVE_REGISTER:
|
796
793
|
raise ValueError(
|
797
794
|
f"score has to be one of {', '.join(MATCHING_EXHAUSTIVE_REGISTER.keys())}"
|
@@ -1007,7 +1004,11 @@ def main():
|
|
1007
1004
|
args, template, target
|
1008
1005
|
)
|
1009
1006
|
|
1010
|
-
|
1007
|
+
matching_data.set_matching_dimension(
|
1008
|
+
target_dim=target.metadata.get("batch_dimension", None),
|
1009
|
+
template_dim=template.metadata.get("batch_dimension", None),
|
1010
|
+
)
|
1011
|
+
splits, schedule = compute_schedule(args, matching_data, callback_class)
|
1011
1012
|
|
1012
1013
|
n_splits = np.prod(list(splits.values()))
|
1013
1014
|
target_split = ", ".join(
|
@@ -1020,7 +1021,6 @@ def main():
|
|
1020
1021
|
"Center Template": not args.no_centering,
|
1021
1022
|
"Scramble Template": args.scramble_phases,
|
1022
1023
|
"Invert Contrast": args.invert_target_contrast,
|
1023
|
-
"Extend Fourier Grid": args.pad_fourier,
|
1024
1024
|
"Extend Target Edges": args.pad_edges,
|
1025
1025
|
"Interpolation Order": args.interpolation_order,
|
1026
1026
|
"Setup Function": f"{get_func_fullname(matching_setup)}",
|
@@ -1106,13 +1106,12 @@ def main():
|
|
1106
1106
|
callback_class_args=analyzer_args,
|
1107
1107
|
target_splits=splits,
|
1108
1108
|
pad_target_edges=args.pad_edges,
|
1109
|
-
pad_fourier=args.pad_fourier,
|
1110
1109
|
pad_template_filter=args.pad_filter,
|
1111
1110
|
interpolation_order=args.interpolation_order,
|
1112
1111
|
)
|
1113
1112
|
|
1114
1113
|
candidates = list(candidates) if candidates is not None else []
|
1115
|
-
if callback_class
|
1114
|
+
if issubclass(callback_class, MaxScoreOverRotations):
|
1116
1115
|
if target_mask is not None and args.score != "MCC":
|
1117
1116
|
candidates[0] *= target_mask.data
|
1118
1117
|
with warnings.catch_warnings():
|