pytme 0.2.9.post1__cp311-cp311-macosx_15_0_arm64.whl → 0.3b0__cp311-cp311-macosx_15_0_arm64.whl

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.
Files changed (63) hide show
  1. pytme-0.2.9.post1.data/scripts/estimate_ram_usage.py → pytme-0.3b0.data/scripts/estimate_memory_usage.py +16 -33
  2. {pytme-0.2.9.post1.data → pytme-0.3b0.data}/scripts/match_template.py +224 -223
  3. {pytme-0.2.9.post1.data → pytme-0.3b0.data}/scripts/postprocess.py +283 -163
  4. {pytme-0.2.9.post1.data → pytme-0.3b0.data}/scripts/preprocess.py +11 -8
  5. {pytme-0.2.9.post1.data → pytme-0.3b0.data}/scripts/preprocessor_gui.py +10 -9
  6. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/METADATA +10 -9
  7. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/RECORD +61 -58
  8. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/entry_points.txt +1 -1
  9. scripts/{estimate_ram_usage.py → estimate_memory_usage.py} +16 -33
  10. scripts/extract_candidates.py +224 -0
  11. scripts/match_template.py +224 -223
  12. scripts/postprocess.py +283 -163
  13. scripts/preprocess.py +11 -8
  14. scripts/preprocessor_gui.py +10 -9
  15. scripts/refine_matches.py +626 -0
  16. tests/preprocessing/test_frequency_filters.py +9 -4
  17. tests/test_analyzer.py +143 -138
  18. tests/test_matching_cli.py +85 -30
  19. tests/test_matching_exhaustive.py +1 -2
  20. tests/test_matching_optimization.py +4 -9
  21. tests/test_orientations.py +0 -1
  22. tme/__version__.py +1 -1
  23. tme/analyzer/__init__.py +2 -0
  24. tme/analyzer/_utils.py +25 -17
  25. tme/analyzer/aggregation.py +384 -220
  26. tme/analyzer/base.py +138 -0
  27. tme/analyzer/peaks.py +150 -91
  28. tme/analyzer/proxy.py +122 -0
  29. tme/backends/__init__.py +4 -3
  30. tme/backends/_cupy_utils.py +25 -24
  31. tme/backends/_jax_utils.py +4 -3
  32. tme/backends/cupy_backend.py +4 -13
  33. tme/backends/jax_backend.py +6 -8
  34. tme/backends/matching_backend.py +4 -3
  35. tme/backends/mlx_backend.py +4 -3
  36. tme/backends/npfftw_backend.py +7 -5
  37. tme/backends/pytorch_backend.py +14 -4
  38. tme/cli.py +126 -0
  39. tme/density.py +4 -3
  40. tme/filters/__init__.py +1 -1
  41. tme/filters/_utils.py +4 -3
  42. tme/filters/bandpass.py +6 -4
  43. tme/filters/compose.py +5 -4
  44. tme/filters/ctf.py +426 -214
  45. tme/filters/reconstruction.py +58 -28
  46. tme/filters/wedge.py +139 -61
  47. tme/filters/whitening.py +36 -36
  48. tme/matching_data.py +4 -3
  49. tme/matching_exhaustive.py +17 -16
  50. tme/matching_optimization.py +5 -4
  51. tme/matching_scores.py +4 -3
  52. tme/matching_utils.py +41 -3
  53. tme/memory.py +4 -3
  54. tme/orientations.py +9 -6
  55. tme/parser.py +5 -4
  56. tme/preprocessor.py +4 -3
  57. tme/rotations.py +10 -7
  58. tme/structure.py +4 -3
  59. tests/data/Maps/.DS_Store +0 -0
  60. tests/data/Structures/.DS_Store +0 -0
  61. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/WHEEL +0 -0
  62. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/licenses/LICENSE +0 -0
  63. {pytme-0.2.9.post1.dist-info → pytme-0.3b0.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,10 @@
1
1
  #!python
2
- """ GUI for identifying adequate template matching filter and masks.
2
+ """
3
+ GUI for identifying suitable masks and analyzing template matchign results.
3
4
 
4
- Copyright (c) 2023 European Molecular Biology Laboratory
5
+ Copyright (c) 2023 European Molecular Biology Laboratory
5
6
 
6
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
7
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
7
8
  """
8
9
  import inspect
9
10
  import argparse
@@ -23,9 +24,9 @@ from napari.utils.events import EventedList
23
24
 
24
25
  from tme.backends import backend
25
26
  from tme.rotations import align_vectors
26
- from tme.filters import BandPassFilter, CTF
27
27
  from tme import Preprocessor, Density, Orientations
28
28
  from tme.matching_utils import create_mask, load_pickle
29
+ from tme.filters import BandPassFilter, CTFReconstructed
29
30
 
30
31
  preprocessor = Preprocessor()
31
32
  SLIDER_MIN, SLIDER_MAX = 0, 25
@@ -71,15 +72,14 @@ def ctf_filter(
71
72
  fast_shape = [next_fast_len(x) for x in np.multiply(template.shape, 2)]
72
73
  template_pad = backend.topleft_pad(template, fast_shape)
73
74
  template_ft = np.fft.rfftn(template_pad, s=template_pad.shape)
74
- ctf = CTF(
75
- angles=[0],
75
+ ctf = CTFReconstructed(
76
76
  shape=fast_shape,
77
77
  defocus_x=[defocus_angstrom],
78
78
  acceleration_voltage=acceleration_voltage * 1e3,
79
79
  spherical_aberration=spherical_aberration * 1e7,
80
80
  amplitude_contrast=amplitude_contrast,
81
- phase_shift=[phase_shift],
82
- defocus_angle=[defocus_angle],
81
+ phase_shift=phase_shift,
82
+ defocus_angle=defocus_angle,
83
83
  sampling_rate=np.max(sampling_rate),
84
84
  return_real_fourier=True,
85
85
  flip_phase=flip_phase,
@@ -1216,7 +1216,8 @@ def main():
1216
1216
 
1217
1217
  def parse_args():
1218
1218
  parser = argparse.ArgumentParser(
1219
- description="GUI for preparing and analyzing template matching runs."
1219
+ description="GUI for preparing and analyzing template matching runs.",
1220
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
1220
1221
  )
1221
1222
  args = parser.parse_args()
1222
1223
  return args
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytme
3
- Version: 0.2.9.post1
3
+ Version: 0.3b0
4
4
  Summary: Python Template Matching Engine
5
5
  Author: Valentin Maurer
6
6
  Author-email: Valentin Maurer <valentin.maurer@embl-hamburg.de>
7
- License: Proprietary
7
+ License-Expression: GPL-2.0-only
8
8
  Project-URL: Homepage, https://github.com/KosinskiLab/pyTME
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Operating System :: OS Independent
@@ -12,7 +12,7 @@ Requires-Python: >=3.11
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: mrcfile>=1.4.3
15
- Requires-Dist: numpy<2.0,>=1.22.2
15
+ Requires-Dist: numpy>=1.22.2
16
16
  Requires-Dist: scipy>=1.9.1
17
17
  Requires-Dist: pyfftw>=0.13.1
18
18
  Requires-Dist: pytest>=6.2.5
@@ -25,19 +25,20 @@ Requires-Dist: h5py
25
25
  Requires-Dist: importlib_resources
26
26
  Requires-Dist: joblib
27
27
  Provides-Extra: cupy
28
- Requires-Dist: cupy-cuda12x; extra == "cupy"
29
- Requires-Dist: voltools==0.6.0; extra == "cupy"
28
+ Requires-Dist: cupy-cuda12x>=13.0.0; extra == "cupy"
30
29
  Provides-Extra: pytorch
31
30
  Requires-Dist: torch; extra == "pytorch"
32
31
  Requires-Dist: torchvision; extra == "pytorch"
33
32
  Provides-Extra: jax
34
- Requires-Dist: jax; extra == "jax"
33
+ Requires-Dist: jax[cuda12]; extra == "jax"
35
34
  Requires-Dist: jaxlib; extra == "jax"
35
+ Provides-Extra: jax-cpu
36
+ Requires-Dist: jax; extra == "jax-cpu"
37
+ Requires-Dist: jaxlib; extra == "jax-cpu"
36
38
  Provides-Extra: all
37
- Requires-Dist: cupy; extra == "all"
38
- Requires-Dist: voltools==0.6.0; extra == "all"
39
+ Requires-Dist: cupy-cuda12x>=13.0.0; extra == "all"
39
40
  Requires-Dist: torch; extra == "all"
40
- Requires-Dist: jax; extra == "all"
41
+ Requires-Dist: jax[cuda12]; extra == "all"
41
42
  Requires-Dist: jaxlib; extra == "all"
42
43
  Requires-Dist: tifffile; extra == "all"
43
44
  Dynamic: author
@@ -1,27 +1,29 @@
1
- pytme-0.2.9.post1.data/scripts/estimate_ram_usage.py,sha256=R1NDpFajcF-MonJ4a43SfDlA-nxBYwK7D2quzCdsVFM,2767
2
- pytme-0.2.9.post1.data/scripts/match_template.py,sha256=k_PACJyQfVBwB7zJiFvkurTtsnej_h6LEnvajZjJkus,39558
3
- pytme-0.2.9.post1.data/scripts/postprocess.py,sha256=Wlbn284vN-Jjo2qpzNNsnW0zOHHHGLQEMeQp5RQJjZk,22759
4
- pytme-0.2.9.post1.data/scripts/preprocess.py,sha256=7NJRUmPGaSFpGSA5C8f4JUzajRo6alMJ4aEprIyS0oo,6512
5
- pytme-0.2.9.post1.data/scripts/preprocessor_gui.py,sha256=2b_xqZwEdB7GKmwWGu5Z4qewN71XZcEa1OVTe-15YF0,41789
6
- pytme-0.2.9.post1.dist-info/licenses/LICENSE,sha256=K1IUNSVAz8BXbpH5EA8y5FpaHdvFXnAF2zeK95Lr2bY,18467
1
+ pytme-0.3b0.data/scripts/estimate_memory_usage.py,sha256=ymDHkRcoFn0eXVHgJu3xh-y4bad5RV3CktH_v5lnDrI,2210
2
+ pytme-0.3b0.data/scripts/match_template.py,sha256=_BSf2aCnJKYz0PKfagIUwFI4i8sFegWsvz-FSb99jp0,39405
3
+ pytme-0.3b0.data/scripts/postprocess.py,sha256=itLpTUe6PtVPjJerL2ajsi4JFbi9n1Wqr8tN9H0z-BU,26964
4
+ pytme-0.3b0.data/scripts/preprocess.py,sha256=Xq9e0on55QeWlAL-Eqo_NQZ2NXznUcj_19qKfIMdNVo,6686
5
+ pytme-0.3b0.data/scripts/preprocessor_gui.py,sha256=gI4FrDOL0qDHdljZ8FWJ8J5V-nV6qccV0szfk4uwo6w,41859
6
+ pytme-0.3b0.dist-info/licenses/LICENSE,sha256=K1IUNSVAz8BXbpH5EA8y5FpaHdvFXnAF2zeK95Lr2bY,18467
7
7
  scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- scripts/estimate_ram_usage.py,sha256=rN7haobnHg3YcgGJIp81FNiCzy8-saJGeEurQlmQmNQ,2768
9
- scripts/match_template.py,sha256=8OkGMpvJe35mNVP9EMRd1KOTTrvMm9xB0OHLVkNlTV4,39559
10
- scripts/postprocess.py,sha256=TnmNY6b2GUOr_dZoi1F71TPpOzyhffmUULRs79LLefQ,22760
11
- scripts/preprocess.py,sha256=GP8lPh_rqFv_CDkPTeFbve_tC1Y7KQZl1YrD9w9wvT4,6513
12
- scripts/preprocessor_gui.py,sha256=8P-xhufzTeH0qEH08ZbF9onHFTq-5FinnhNaNbEv8Lg,41790
8
+ scripts/estimate_memory_usage.py,sha256=pAtEx0TRVjAPmd_Ea0-G4oICUyVdJGM03FgynjBBDPE,2211
9
+ scripts/extract_candidates.py,sha256=GnJb7LI0z2UpMvOS3uY6oIXUJ90R4f2V1jPK5SvJbXg,7246
10
+ scripts/match_template.py,sha256=mxnJhgXZoMJVcAHc0JgDanvwVyi2GGuc5G3DG9H9uKY,39406
11
+ scripts/postprocess.py,sha256=m62N4LqQE2SWq93bHF_EgIpz136YXjSpunXNflSsEFw,26965
12
+ scripts/preprocess.py,sha256=aDKBhv8NN8WAiP8LaHGm-eTfq3mcpNF5OBqMy8FcAmk,6687
13
+ scripts/preprocessor_gui.py,sha256=MaIgt_0Mk-WNvXeJOrL1M41zgzjUgsdXXF5UJQ4xq54,41860
14
+ scripts/refine_matches.py,sha256=Y17Ku_t0W9vglPNF2oU5EFrqoedJIm3lCGl-hXRHvjc,21920
13
15
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- tests/test_analyzer.py,sha256=fMuY0WCh1_D1XdzaryKzq3Mj9Q3pJFpWCNeEO-DYY20,7949
16
+ tests/test_analyzer.py,sha256=FczMo_S3Y1cIn4Z-U-iT_gsNTt9PJXYlIyvv3MX9i6o,8611
15
17
  tests/test_backends.py,sha256=29HlacgrX4fRjFXfzNNh3yDjqHRd7WvCFpTpRQwAsmA,17541
16
18
  tests/test_density.py,sha256=vzzy0Gk3uUR096aZgA-e5gOfLnw9qG3RH-xyXtHCO_I,18971
17
19
  tests/test_extensions.py,sha256=1Zv9dG_dmmC2mlbX91YIPyGLSToPC0202-ffLAfVcr4,5203
18
- tests/test_matching_cli.py,sha256=VoGVi4QhakccVbC3pIQzEwaL97Zgi2Ll4np1zVqdpvo,9345
20
+ tests/test_matching_cli.py,sha256=UxWQZD9gUSTFNdPsIumTr2bp2MFQKF2O4te0TT0Lxlk,11210
19
21
  tests/test_matching_data.py,sha256=TyvnSJPzdLPiXYWdz9coQ-m4H1tUS_cbD0WaBdvrevg,6062
20
- tests/test_matching_exhaustive.py,sha256=2_uG8Ir8QUyvGXMHcsBRdvr27j83cgpd53FnRyIkF8M,4055
22
+ tests/test_matching_exhaustive.py,sha256=bRPCN0pyZk3DmXMrWRcEGAksYoch8P7fRiwE3g0yIf4,4039
21
23
  tests/test_matching_memory.py,sha256=XrBGRi4cIp3-4nN6s7tj0pBbFJrvJaG3vQdtK-6uzY0,1151
22
- tests/test_matching_optimization.py,sha256=KBmFojKpr1iC_T90vpsrvZoEeFzI41xmejC-WuINZGU,7941
24
+ tests/test_matching_optimization.py,sha256=bYt3d_nHewTRxKCXgGaMLhObkqBufGwrYL4gfinr_jE,7732
23
25
  tests/test_matching_utils.py,sha256=9wJPKh5LF_Vb75pKbXy-JT8u_FGLfWioA7nFcOkAto4,6356
24
- tests/test_orientations.py,sha256=HtCYJB_XGMLjWEvTfCXSxKpE_FvrGg5Uk39dn1zB-4g,6837
26
+ tests/test_orientations.py,sha256=ydqYZc3mOWSweFEGWMrMaygxX7-7in7forUtiNWfQKc,6767
25
27
  tests/test_parser.py,sha256=57oaksWrKNB4Z_22IxfW0nXMyQWLJFVsuvnJQPhMn10,993
26
28
  tests/test_rotations.py,sha256=CTEkpO8Z-6afgCIk2wGexXBaOqUeGJL2-krm1z4YRFY,5358
27
29
  tests/test_structure.py,sha256=Qgrex3wYl9TpFLcqMeUOkq-7w93bzEsMNStKdJdsbnw,8881
@@ -35,10 +37,8 @@ tests/data/Blurring/localgaussian_sigma0510.npy,sha256=KXASnlhxAnvvcgIDCniIHkak-
35
37
  tests/data/Blurring/mean_size5.npy,sha256=2APwsCR_1fpwGIc_mG0dPegpcbgXhUbcEEeQo9Wa1iA,42688
36
38
  tests/data/Blurring/ntree_sigma0510.npy,sha256=HxYh_ItxdKulp8UiPMzQ0ze2iiQ3Oi7seWFvEzO1kWQ,21408
37
39
  tests/data/Blurring/rank_rank3.npy,sha256=MxCsomoNPmiV0Cd-5nl2S8TYCfLyEj-WV19gLH_xe0c,21408
38
- tests/data/Maps/.DS_Store,sha256=1lFlJ5EFymdzGAUAaI30vcaaLHt3F1LwpG7xILf9jsM,6148
39
40
  tests/data/Maps/emd_8621.mrc.gz,sha256=ZAlSOQRT9B_e8xpeodio9j0WBzygl2R1ctg9m8QhCRA,4572566
40
41
  tests/data/Raw/em_map.map,sha256=YeY_R0p-90-oZgxfbKGIsyE5bui_uWq9iGhWl0bLYZI,22304
41
- tests/data/Structures/.DS_Store,sha256=1lFlJ5EFymdzGAUAaI30vcaaLHt3F1LwpG7xILf9jsM,6148
42
42
  tests/data/Structures/1pdj.cif,sha256=QdO4e2ulO621PVoK3q9n0qDPDKnzJpV6sPeG6zQec1A,169343
43
43
  tests/data/Structures/1pdj.pdb,sha256=nTFGjecultoXNVUBDdsyho0CEzX5i1fSo_aBYDh5-pU,115749
44
44
  tests/data/Structures/5khe.cif,sha256=SnC0so37wyuoYwAX5UDTTLvQiknZXxeJrvkGai-11rw,214644
@@ -47,38 +47,41 @@ tests/data/Structures/5khe.pdb,sha256=AjXInxR_DgglZATzSNgB1rs7-LgAn2G1NdgnHb6fAm
47
47
  tests/data/Structures/5uz4.cif,sha256=KIcBaOf-RvOV4VRl1AU_EK4BsMxGXS8s8_UdlIhyeWk,6079401
48
48
  tests/preprocessing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  tests/preprocessing/test_compose.py,sha256=z44fgQhxJU0-zHSV0CLBMEJqwhK5gEFDhUCLuVsQpQc,2490
50
- tests/preprocessing/test_frequency_filters.py,sha256=rFms5nQb6KzxQE2IvMu37u8f15kTcN5tD7gr3v5Z-Jo,6610
50
+ tests/preprocessing/test_frequency_filters.py,sha256=EDSkQ8si5mZDEA8edqGBZSdTuooExjICSt5jGoOk3Ko,6705
51
51
  tests/preprocessing/test_preprocessor.py,sha256=XyR4xc4YM76PUKuTIiive76Q85DdcyDAvbXNGcoKL8w,4820
52
52
  tests/preprocessing/test_utils.py,sha256=2V1a9XtFZYmCyQzgsj0qWzWuXg-JAsOoG5_rtTwxvGg,3031
53
53
  tme/__init__.py,sha256=GXfIuzU4fh2KZfgUOIXnNeKlJ8kSp3EqoBr6bSik848,217
54
- tme/__version__.py,sha256=F8OVhAhMXSkvvXYgZtbPn2SG1AQC3joK4yu-FrHt81Y,22
55
- tme/density.py,sha256=vCBZHtMyQZ1lr0sTGfPa7RP-TpPf22etRHDzeL7yqaM,82424
54
+ tme/__version__.py,sha256=P5VZtc3R0HZUTa5n7H1OdUHLN6ZvKTYlVWMZKc0waOw,23
55
+ tme/cli.py,sha256=48Q7QGIuCwNSms5wOnGmWjMSlZrXjAQUz_9zsIFT9tY,3652
56
+ tme/density.py,sha256=5IGnbp7Lq8-N5mGPg_bmVIPTd5un63opD26qi8ZSke4,82416
56
57
  tme/extensions.cpython-311-darwin.so,sha256=vNaZYhhSrVlCjBlj5nzpKcnnJ_L_-84WhTRz2kWYK2Y,395696
57
- tme/matching_data.py,sha256=hhtjQl_EimGGmyR2DHiZi82Aeq3xmNF98koevZT7mKc,31238
58
- tme/matching_exhaustive.py,sha256=VXWOMaLF9m_31d9Hy3mn-PuUBJ0zgsTRb5v4sdRvJPU,18817
59
- tme/matching_optimization.py,sha256=wQ8k1VBK74twymogr_1LIOjNlhr_Nyl8CN4XxjEADHQ,45688
60
- tme/matching_scores.py,sha256=A8558Yj1lCEbcLYeevoVXMfhO3jILZeO3ztgp8gA9Xo,41023
61
- tme/matching_utils.py,sha256=Oa7ytvvaSyck6PSci3XBoakgz8-9tL8Qtv2Sx7P3pVo,36362
62
- tme/memory.py,sha256=gRKOsputjOjpVhqgrLn2q8JfSCiXGtRdV8wd9XG_Fho,9687
63
- tme/orientations.py,sha256=yQKJaYQWkBqDOIYFmVDP47rjdvqwoAHBCvmpu36qoOo,21023
64
- tme/parser.py,sha256=bqgJ9FPecbnvqFF-xZhRZOwPxawtMqs69SEGS3oaxWQ,21565
65
- tme/preprocessor.py,sha256=AafqtzBXX0OywZ6B8J0IBtZPMWCGhnJStbqZviRJPBc,40371
66
- tme/rotations.py,sha256=CO35CwD7qHxmiUSFBqFU9y-O4tRM8BKp-U7d52y2eLs,10630
67
- tme/structure.py,sha256=EktAzR_t0cK5J0iBiWlDDGw1okFoiEQgwACAIRDNdgY,72143
58
+ tme/matching_data.py,sha256=UIuFtu1yeNCaNfVUUsmnqV0zeMTcpW3s9ws6J2EBnP0,31230
59
+ tme/matching_exhaustive.py,sha256=2cTWaqZo4_ZjJTQ0lHBmjmfQgwX3I60FrT1lUnkDsa8,18781
60
+ tme/matching_optimization.py,sha256=xWWjCN_BsTEdHwkIs1-BgTh6ayh4e7SlwotSykDtix4,45687
61
+ tme/matching_scores.py,sha256=AYbWqQmWdcK_7fEJ8keUsbACGg65RLqQea3CzsQ9_E4,41015
62
+ tme/matching_utils.py,sha256=EqEmSppq6I6GXikBPKKmR14FYWOi4d8ki7juygX-sMs,37406
63
+ tme/memory.py,sha256=UC8L00aINgz7po2xqwpZzKZRrnsoCJGp58rCjZSwGb4,9679
64
+ tme/orientations.py,sha256=8t9QCLY4GkIOFZfUmqH_8v5ASFXLfRNweZJ4RXo_mfI,21060
65
+ tme/parser.py,sha256=8FHO1meaoRqlM9bYuDqwqMKAQoQweO_BxYLIxOCQL0A,21557
66
+ tme/preprocessor.py,sha256=Y2nYfEstuB7PSR-E_E5QgTDQh86Y5Ia2beIPDN_nP0Y,40363
67
+ tme/rotations.py,sha256=VTWzVyfsih1qGeE5hHPvusAAsic2trWA7-bjyAizoYU,10622
68
+ tme/structure.py,sha256=ojk-IQnIe1JrzxUVHlNlyLxtwzNkNykvxTaXvyBMmbs,72135
68
69
  tme/types.py,sha256=NAY7C4qxE6yz-DXVtClMvFfoOV-spWGLNfpLATZ1LcU,442
69
- tme/analyzer/__init__.py,sha256=DgEulEr9nERtXttTpmEeL8pNLCW-OxGWB4PMMCQ0INs,48
70
- tme/analyzer/_utils.py,sha256=ioG90NdGGyjC1bXLu9cdBSPFStOG2n5GlPOeS_0SFGs,6083
71
- tme/analyzer/aggregation.py,sha256=NYk9EWr670GmYO0gTJ5AalpCbDh30SEAfoA59m6IMGA,21104
72
- tme/analyzer/peaks.py,sha256=dVIJ1zCT7XPJSVK368uFdVcj7DcwRJYKJQbG9VhEDbQ,33028
73
- tme/backends/__init__.py,sha256=iGTq1c9CR0ZCAj9uOY6DzqPePYG0ZVvv637FukH-I7I,5257
74
- tme/backends/_cupy_utils.py,sha256=tzfoR-WyHViSY1E39mKoO5os-1L8zpChIdbf52QN0t4,24650
75
- tme/backends/_jax_utils.py,sha256=Bo47XU338rNdJ-BNLR4XKmbnnlAz8zxeLQomTNhgLmk,5907
76
- tme/backends/cupy_backend.py,sha256=4kzqTmcQET1ZySkwK_z5noxmKYTAsxRpIzV4M9E3kjs,10246
77
- tme/backends/jax_backend.py,sha256=m3GdCJXgDeBofOwYGz1GwnoxrLyjVh1gh6oJhZEIiwE,11050
78
- tme/backends/matching_backend.py,sha256=o0L5P80yN3E7KbjfcsgNjICc6kEaVlACxlc2WdCq0wc,34864
79
- tme/backends/mlx_backend.py,sha256=gMAxk7ue2xocSmdLzBj3H-jbVUCKZ5Q13TDpK4kyqV8,7764
80
- tme/backends/npfftw_backend.py,sha256=BMHRkT0MRLiVCdfkG6GuBINO8lYQ9lb9vjzOMBYAGHc,19295
81
- tme/backends/pytorch_backend.py,sha256=t1sNfLU_gt8XrbPaRhO2MGvp-YKUptpSLge3zxJeZwo,14800
70
+ tme/analyzer/__init__.py,sha256=nmGTRU9BWjBiqI1UOpuLCGbmXIi4ihtxDOmRUYZDW_M,88
71
+ tme/analyzer/_utils.py,sha256=fYpobxbodYkMDNt8b5nGE5kce1TJq1ialS7dFq6oLsc,6404
72
+ tme/analyzer/aggregation.py,sha256=knI_eqPBR48pIqqwxiVWlJDowr2oCkZ-QDT2eBr3Sys,27466
73
+ tme/analyzer/base.py,sha256=1U9iKBZ3sFVuUsctpjcD37epKFaM30guBI7Z1xx8_Vk,4207
74
+ tme/analyzer/peaks.py,sha256=qWm7r9cKb8cYLAIV63DK3xZ3SX3uO9srUb0DibL0WBg,34913
75
+ tme/analyzer/proxy.py,sha256=lVPed8S0VVbyT2ZAdFMttW7razVX0azSsHyAmH2nKoo,4161
76
+ tme/backends/__init__.py,sha256=VUvEnpfjmZQVn_9QHkLPBoa6y8M3gDyNNL9kq4OQNGE,5249
77
+ tme/backends/_cupy_utils.py,sha256=scxCSK9BcsDaIbHR2mFxAJRIxdc0r5JTC1gCJmVJa64,24558
78
+ tme/backends/_jax_utils.py,sha256=lKvRA-QbK661xd-xQYoqKsMYNT82gGd1VHGQse7krN0,5899
79
+ tme/backends/cupy_backend.py,sha256=vpaDTw1gwit9zWrcTFtdt2LMPKEHB4LDDGsIFtcYCAA,9762
80
+ tme/backends/jax_backend.py,sha256=GOIgoyLUOtMNBYOrxJmVrgkNnBNQEURq5pr6teuuYzg,10912
81
+ tme/backends/matching_backend.py,sha256=eFBtFy4_kSoprFJugkXEZ8QYQsTFnJX46STRw6b70Aw,34856
82
+ tme/backends/mlx_backend.py,sha256=DxcKJmORTDuFFJ6EVVhZOuuiYt88swc314M6MbmCfSw,7756
83
+ tme/backends/npfftw_backend.py,sha256=RALpSuk3qXf7_MJhpgFTOT2oIJHnoYv_hovkSrcJGdY,19352
84
+ tme/backends/pytorch_backend.py,sha256=C6VqgxajljhjjUbGz0C0bFq3nbQTzsqFl7POuwLYH24,15040
82
85
  tme/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
86
  tme/data/c48n309.npy,sha256=NwH64mOEbm3tStq5c98o81fY1vMOoq4nvXDAh7Z7iZg,296768
84
87
  tme/data/c48n527.npy,sha256=saSUMTa1R0MisPvgFL02a7IHQSwEZ-mJu0v3qJjg5AU,506048
@@ -104,16 +107,16 @@ tme/data/metadata.yaml,sha256=fAgX-mEzB0QMHTEtYDG4cSMbJhYxBbDJH3sdvJvL7a8,750
104
107
  tme/data/quat_to_numpy.py,sha256=-gkDZb10fKBxwfYrSLCUWvMB76TzZWELCeKsYProwws,1333
105
108
  tme/data/scattering_factors.pickle,sha256=ZHktBc_AlS4H6uoER8AMmn5zOgjBwzgC92hUyww3Nik,38669
106
109
  tme/external/bindings.cpp,sha256=CIukugVf55LicY2uSCasHWQlrlO9GS2iUuCR3WLvncM,12912
107
- tme/filters/__init__.py,sha256=iCPAyxlXtvZdinMKk_nDzk8Ew8K9NkhMFDs1JF5_zEM,243
108
- tme/filters/_utils.py,sha256=rrgWXdlF8rbAdhQwXcDn3EPE5euhtr1uJDJeqMFmNmI,10106
109
- tme/filters/bandpass.py,sha256=YygCDFG5d3VZkoX5IxZwmjVgrVnQwyh9p3G-aeaanqo,7795
110
- tme/filters/compose.py,sha256=czOBaihYcRYKrfNFAAEodurtEYg3SF0PFPMLkCqR8tk,1992
111
- tme/filters/ctf.py,sha256=ymOi90sf-bSPfHFpdvMPeEsoDHgOerMjH6q1sRNlNiY,14801
112
- tme/filters/reconstruction.py,sha256=oomYOtWGiw7DXs_NVnQxPVv8zK8hwXZTONiwaFQNTE8,5436
113
- tme/filters/wedge.py,sha256=t9LKPydjyuhtY9NtkiQug-S5bGt2DDTBAaeNDbH5T9E,17583
114
- tme/filters/whitening.py,sha256=Rhr-sxxvAVp60yUieiyL96iJcDasbdgq9q1iTtCxS1w,6324
115
- pytme-0.2.9.post1.dist-info/METADATA,sha256=iRWxbDR6p4Lq4q2PbfXzscjDDxGjMe46KItWTvdbTHA,5374
116
- pytme-0.2.9.post1.dist-info/WHEEL,sha256=SPbiHAOPLnBtml4sk5MIwvWF6YnGfOfy9C__W6Bpeg4,109
117
- pytme-0.2.9.post1.dist-info/entry_points.txt,sha256=ff3LQL3FCWfCYOwFiP9zatm7laUbnwCkuPELkQVyUO4,241
118
- pytme-0.2.9.post1.dist-info/top_level.txt,sha256=ovCUR7UXXouH3zYt_fJLoqr_vtjp1wudFgjVAnztQLE,18
119
- pytme-0.2.9.post1.dist-info/RECORD,,
110
+ tme/filters/__init__.py,sha256=URdfFWPJrgHIHPbWZYkOV6BN4xTAOU41vMENyxgxxRw,261
111
+ tme/filters/_utils.py,sha256=apH5Qgd3-YTA0a4DWPcsC0eg5zunqoVbMbCjPlbYupY,10098
112
+ tme/filters/bandpass.py,sha256=7y0-7K8QNWDKVsHHWKjldk0CNgZjv8f5F7fmI0kvqZo,7837
113
+ tme/filters/compose.py,sha256=yeC84D0HznqhRJ7guV6Cpxzq2UWpvV6nouhFECjIDEw,1980
114
+ tme/filters/ctf.py,sha256=6NHOksV1yEs0KvG_nC5avdkhnJ0yVMJraGASYC4On4Y,21702
115
+ tme/filters/reconstruction.py,sha256=BHcKPuz67tCS7wgoIzAihMiTNPuFAmKZfqIOBIlZoBA,6595
116
+ tme/filters/wedge.py,sha256=bLawfE_oHWB1VvFpjb49GTkvxttq_FNLNWsvo4t1bCk,19920
117
+ tme/filters/whitening.py,sha256=Wcepxg75M3hNtQ3NjCTdyjesZym3Cc52OAxztFdLsiE,6440
118
+ pytme-0.3b0.dist-info/METADATA,sha256=lj3LgLZPoZf0yU_gMIXF-yLqFH4E--l8hiv2MhtksEA,5425
119
+ pytme-0.3b0.dist-info/WHEEL,sha256=SPbiHAOPLnBtml4sk5MIwvWF6YnGfOfy9C__W6Bpeg4,109
120
+ pytme-0.3b0.dist-info/entry_points.txt,sha256=elQ5JqLhmA3XX51WGIkm7hEdB_saxXKVMjqKqdHl--A,247
121
+ pytme-0.3b0.dist-info/top_level.txt,sha256=ovCUR7UXXouH3zYt_fJLoqr_vtjp1wudFgjVAnztQLE,18
122
+ pytme-0.3b0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  [console_scripts]
2
- estimate_ram_usage = scripts:estimate_ram_usage.main
2
+ estimate_memory_usage = scripts:estimate_memory_usage.main
3
3
  match_template = scripts:match_template.main
4
4
  postprocess = scripts:postprocess.main
5
5
  preprocess = scripts:preprocess.main
@@ -1,20 +1,21 @@
1
1
  #!python3
2
- """ Estimate RAM requirements for template matching jobs.
2
+ """Estimate memory requirements for template matching jobs.
3
3
 
4
- Copyright (c) 2023 European Molecular Biology Laboratory
4
+ Copyright (c) 2023 European Molecular Biology Laboratory
5
5
 
6
- Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
7
7
  """
8
8
  import numpy as np
9
9
  import argparse
10
10
  from tme import Density
11
- from tme.matching_utils import estimate_ram_usage
11
+ from tme.memory import estimate_memory_usage
12
12
  from tme.matching_exhaustive import MATCHING_EXHAUSTIVE_REGISTER
13
13
 
14
14
 
15
15
  def parse_args():
16
16
  parser = argparse.ArgumentParser(
17
- description="Estimate RAM usage for template matching."
17
+ description="Estimate memory usage for template matching.",
18
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
18
19
  )
19
20
  parser.add_argument(
20
21
  "-m",
@@ -32,14 +33,9 @@ def parse_args():
32
33
  required=True,
33
34
  help="Path to a template in PDB/MMCIF or CCP4/MRC format.",
34
35
  )
35
- parser.add_argument(
36
- "--matching_method",
37
- required=False,
38
- default=None,
39
- help="Analyzer method to use.",
40
- )
41
36
  parser.add_argument(
42
37
  "-s",
38
+ "--score",
43
39
  dest="score",
44
40
  type=str,
45
41
  default="FLCSphericalMask",
@@ -50,21 +46,12 @@ def parse_args():
50
46
  "--ncores", type=int, help="Number of cores for parallelization.", required=True
51
47
  )
52
48
  parser.add_argument(
53
- "--no_edge_padding",
54
- dest="no_edge_padding",
49
+ "--pad_edges",
50
+ dest="pad_edges",
55
51
  action="store_true",
56
52
  default=False,
57
- help="Whether to pad the edges of the target. This is useful, if the target"
58
- " has a well defined bounding box, e.g. a density map.",
59
- )
60
- parser.add_argument(
61
- "--no_fourier_padding",
62
- dest="no_fourier_padding",
63
- action="store_true",
64
- default=False,
65
- help="Whether input arrays should be zero-padded to the full convolution shape"
66
- " for numerical stability. When working with very large targets such as"
67
- " tomograms it is safe to use this flag and benefit from the performance gain.",
53
+ help="Whether to pad the edges of the target. Useful if the target does not "
54
+ "a well-defined bounding box. Defaults to True if splitting is required.",
68
55
  )
69
56
  args = parser.parse_args()
70
57
  return args
@@ -72,19 +59,15 @@ def parse_args():
72
59
 
73
60
  def main():
74
61
  args = parse_args()
75
- target = Density.from_file(args.target)
76
- template = Density.from_file(args.template)
77
-
78
- target_box = target.shape
79
- if not args.no_edge_padding:
80
- target_box = np.add(target_box, template.shape)
62
+ target = Density.from_file(args.target, use_memmap=True)
63
+ template = Density.from_file(args.template, use_memmap=True)
81
64
 
82
65
  template_box = template.shape
83
- if args.no_fourier_padding:
66
+ if not args.pad_edges:
84
67
  template_box = np.ones(len(template_box), dtype=int)
85
68
 
86
- result = estimate_ram_usage(
87
- shape1=target_box,
69
+ result = estimate_memory_usage(
70
+ shape1=target.shape,
88
71
  shape2=template_box,
89
72
  matching_method=args.score,
90
73
  ncores=args.ncores,
@@ -0,0 +1,224 @@
1
+ #!python3
2
+ """ Prepare orientations stack for refinement.
3
+
4
+ Copyright (c) 2023 European Molecular Biology Laboratory
5
+
6
+ Author: Valentin Maurer <valentin.maurer@embl-hamburg.de>
7
+ """
8
+ import argparse
9
+ from os.path import splitext
10
+
11
+ import numpy as np
12
+
13
+ from tme import Density, Orientations
14
+ from tme.matching_utils import (
15
+ generate_tempfile_name,
16
+ rotation_aligning_vectors,
17
+ euler_from_rotationmatrix,
18
+ euler_to_rotationmatrix,
19
+ )
20
+
21
+
22
+ class ProgressBar:
23
+ """
24
+ ASCII progress bar.
25
+ """
26
+
27
+ def __init__(self, message: str, nchars: int, total: int):
28
+ self._size = nchars - len(message) - (len(str(total))+2) * 2
29
+ self._message = message
30
+ self._total = total
31
+
32
+ def update(self, cur):
33
+ x = int(cur * self._size / self._total)
34
+ print(
35
+ "%s[%s%s] %i/%i\r"
36
+ % (self._message, "#" * x, "." * (self._size - x), cur, self._total),
37
+ end="",
38
+ )
39
+
40
+
41
+ def parse_args():
42
+ parser = argparse.ArgumentParser(
43
+ description="Extract matching candidates for further refinement.",
44
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
45
+ )
46
+
47
+ io_group = parser.add_argument_group("Input / Output")
48
+ io_group.add_argument(
49
+ "--target",
50
+ required=True,
51
+ type=str,
52
+ help="Extract candidates from this target.",
53
+ )
54
+ io_group.add_argument(
55
+ "--orientations",
56
+ required=True,
57
+ type=str,
58
+ help="Path to file generated by postprocess.py using output_format orientations.",
59
+ )
60
+ io_group.add_argument(
61
+ "--orientations_sampling",
62
+ required=False,
63
+ type=float,
64
+ default=1.0,
65
+ help="Factor to map candidate coordinates onto the target. Only relevant if "
66
+ "target sampling rate differs from candidate orientation sampling rate.",
67
+ )
68
+ io_group.add_argument(
69
+ "-o",
70
+ "--output_file",
71
+ required=True,
72
+ type=str,
73
+ help="Path to write output H5 file.",
74
+ )
75
+
76
+ alignment_group = parser.add_argument_group("Alignment")
77
+ alignment_group.add_argument(
78
+ "--align_orientations",
79
+ action="store_true",
80
+ required=False,
81
+ help="Whether to align extracted orientations based on their angles. Allows "
82
+ "for efficient subsequent sampling of cone angles.",
83
+ )
84
+ alignment_group.add_argument(
85
+ "--angles_are_vector",
86
+ action="store_true",
87
+ required=False,
88
+ help="Considers euler_z euler_y, euler_x as vector that will be rotated to align "
89
+ "with the z-axis (1,0,0). Only considered when --align_orientations is set.",
90
+ )
91
+ alignment_group.add_argument(
92
+ "--interpolation_order",
93
+ dest="interpolation_order",
94
+ required=False,
95
+ type=int,
96
+ default=1,
97
+ help="Interpolation order for alignment, less than zero is no interpolation.",
98
+ )
99
+
100
+ extraction_group = parser.add_argument_group("Extraction")
101
+ extraction_group.add_argument(
102
+ "--box_size",
103
+ required=False,
104
+ type=int,
105
+ help="Box size for extraction, defaults to two times the template.",
106
+ )
107
+ extraction_group.add_argument(
108
+ "--translation_uncertainty",
109
+ required=False,
110
+ type=int,
111
+ help="Sets box size for extraction to template box plus this value.",
112
+ )
113
+ extraction_group.add_argument(
114
+ "--keep_out_of_box",
115
+ action="store_true",
116
+ required=False,
117
+ help="Whether to keep orientations that fall outside the box. If the "
118
+ "orientations are sensible, it is safe to pass this flag.",
119
+ )
120
+
121
+ args = parser.parse_args()
122
+
123
+ return args
124
+
125
+
126
+ def main():
127
+ args = parse_args()
128
+ orientations = Orientations.from_file(args.orientations)
129
+ orientations.translations = np.divide(
130
+ orientations.translations, args.orientations_sampling
131
+ )
132
+
133
+ target = Density.from_file(args.target, use_memmap=True)
134
+
135
+ box_size = np.array(args.box_size)
136
+ box_size = np.repeat(box_size, target.data.ndim // box_size.size).astype(int)
137
+
138
+ extraction_shape = np.copy(box_size)
139
+ if args.align_orientations:
140
+ extraction_shape[:] = int(np.linalg.norm(box_size) + 1)
141
+
142
+ orientations, cand_slices, obs_slices = orientations.get_extraction_slices(
143
+ target_shape=target.shape,
144
+ extraction_shape=extraction_shape,
145
+ drop_out_of_box=not args.keep_out_of_box,
146
+ return_orientations=True,
147
+ )
148
+
149
+ if args.align_orientations:
150
+ for index in range(orientations.rotations.shape[0]):
151
+ rotation_matrix = euler_to_rotationmatrix(orientations.rotations[index])
152
+ rotation_matrix = np.linalg.inv(rotation_matrix)
153
+ if args.angles_are_vector:
154
+ rotation_matrix = rotation_aligning_vectors(
155
+ orientations.rotations[index], target_vector=(1, 0, 0)
156
+ )
157
+ orientations.rotations[index] = euler_from_rotationmatrix(rotation_matrix)
158
+
159
+ filename = generate_tempfile_name()
160
+ output_dtype = target.data.dtype
161
+ if args.align_orientations is not None:
162
+ output_dtype = np.float32
163
+
164
+ target.data = target.data.astype(output_dtype)
165
+
166
+ dens = Density(
167
+ np.memmap(
168
+ filename,
169
+ mode="w+",
170
+ shape=(len(obs_slices), *box_size),
171
+ dtype=output_dtype,
172
+ ),
173
+ sampling_rate=(1, *target.sampling_rate),
174
+ origin=(0, *target.origin),
175
+ )
176
+ dens.data[:] = target.metadata["mean"]
177
+
178
+ data_subset = np.zeros(extraction_shape, dtype=target.data.dtype)
179
+ pbar = ProgressBar(message="Aligning ", nchars=80, total=len(obs_slices))
180
+ for index, (obs_slice, cand_slice) in enumerate(zip(obs_slices, cand_slices)):
181
+ pbar.update(index + 1)
182
+
183
+ data_subset.fill(0)
184
+ data_subset[cand_slice] = target.data[obs_slice]
185
+ target_subset = Density(
186
+ data_subset,
187
+ sampling_rate=target.sampling_rate,
188
+ origin=target.origin,
189
+ )
190
+
191
+ if args.align_orientations:
192
+ rotation_matrix = euler_to_rotationmatrix(orientations.rotations[index])
193
+ target_subset = target_subset.rigid_transform(
194
+ rotation_matrix=rotation_matrix,
195
+ use_geometric_center=True,
196
+ order=args.interpolation_order,
197
+ )
198
+ target_subset.pad(box_size, center=True)
199
+
200
+ # target_value = target.data[tuple(orientations.translations[index].astype(int))]
201
+ # center = np.divide(target_subset.data.shape, 2).astype(int)
202
+ # print(np.where(target_subset.data == target_value), center)
203
+ # print(target_subset.data[tuple(center.astype(int))],
204
+ # target_value,
205
+ # target_subset.data[tuple(center.astype(int))] == target_value
206
+ # )
207
+
208
+ dens.data[index] = target_subset.data
209
+ print("")
210
+
211
+ target_meta = {
212
+ k: v for k, v in target.metadata.items() if k in ("mean", "max", "min", "std")
213
+ }
214
+ dens.metadata.update(target_meta)
215
+ dens.metadata["batch_dimension"] = (0,)
216
+ dens.metadata["normals"] = orientations.rotations
217
+
218
+ dens.to_file(args.output_file)
219
+ orientations.to_file(
220
+ f"{splitext(args.output_file)[0]}_aligned.tsv", file_format="text"
221
+ )
222
+
223
+ if __name__ == "__main__":
224
+ main()