pytme 0.2.1__cp311-cp311-macosx_14_0_arm64.whl → 0.2.3__cp311-cp311-macosx_14_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.
- {pytme-0.2.1.data → pytme-0.2.3.data}/scripts/match_template.py +219 -216
- {pytme-0.2.1.data → pytme-0.2.3.data}/scripts/postprocess.py +86 -54
- pytme-0.2.3.data/scripts/preprocess.py +132 -0
- {pytme-0.2.1.data → pytme-0.2.3.data}/scripts/preprocessor_gui.py +181 -94
- pytme-0.2.3.dist-info/METADATA +92 -0
- pytme-0.2.3.dist-info/RECORD +75 -0
- {pytme-0.2.1.dist-info → pytme-0.2.3.dist-info}/WHEEL +1 -1
- pytme-0.2.1.data/scripts/preprocess.py → scripts/eval.py +1 -1
- scripts/extract_candidates.py +20 -13
- scripts/match_template.py +219 -216
- scripts/match_template_filters.py +154 -95
- scripts/postprocess.py +86 -54
- scripts/preprocess.py +95 -56
- scripts/preprocessor_gui.py +181 -94
- scripts/refine_matches.py +265 -61
- tme/__init__.py +0 -1
- tme/__version__.py +1 -1
- tme/analyzer.py +458 -813
- tme/backends/__init__.py +40 -11
- tme/backends/_jax_utils.py +187 -0
- tme/backends/cupy_backend.py +109 -226
- tme/backends/jax_backend.py +230 -152
- tme/backends/matching_backend.py +445 -384
- tme/backends/mlx_backend.py +32 -59
- tme/backends/npfftw_backend.py +240 -507
- tme/backends/pytorch_backend.py +30 -151
- tme/density.py +248 -371
- tme/extensions.cpython-311-darwin.so +0 -0
- tme/matching_data.py +328 -284
- tme/matching_exhaustive.py +195 -1499
- tme/matching_optimization.py +143 -106
- tme/matching_scores.py +887 -0
- tme/matching_utils.py +287 -388
- tme/memory.py +377 -0
- tme/orientations.py +78 -21
- tme/parser.py +3 -4
- tme/preprocessing/_utils.py +61 -32
- tme/preprocessing/composable_filter.py +7 -4
- tme/preprocessing/compose.py +7 -3
- tme/preprocessing/frequency_filters.py +49 -39
- tme/preprocessing/tilt_series.py +44 -72
- tme/preprocessor.py +560 -526
- tme/structure.py +491 -188
- tme/types.py +5 -3
- pytme-0.2.1.dist-info/METADATA +0 -73
- pytme-0.2.1.dist-info/RECORD +0 -73
- tme/helpers.py +0 -881
- tme/matching_constrained.py +0 -195
- {pytme-0.2.1.data → pytme-0.2.3.data}/scripts/estimate_ram_usage.py +0 -0
- {pytme-0.2.1.dist-info → pytme-0.2.3.dist-info}/LICENSE +0 -0
- {pytme-0.2.1.dist-info → pytme-0.2.3.dist-info}/entry_points.txt +0 -0
- {pytme-0.2.1.dist-info → pytme-0.2.3.dist-info}/top_level.txt +0 -0
tme/backends/mlx_backend.py
CHANGED
@@ -9,12 +9,12 @@ from typing import Tuple, List, Callable
|
|
9
9
|
import numpy as np
|
10
10
|
|
11
11
|
from .npfftw_backend import NumpyFFTWBackend
|
12
|
-
from ..types import NDArray, MlxArray, Scalar
|
12
|
+
from ..types import NDArray, MlxArray, Scalar, shm_type
|
13
13
|
|
14
14
|
|
15
15
|
class MLXBackend(NumpyFFTWBackend):
|
16
16
|
"""
|
17
|
-
A
|
17
|
+
A mlx-based matching backend.
|
18
18
|
"""
|
19
19
|
|
20
20
|
def __init__(
|
@@ -72,6 +72,15 @@ class MLXBackend(NumpyFFTWBackend):
|
|
72
72
|
return None
|
73
73
|
return self._array_backend.add(x1, x2, **kwargs)
|
74
74
|
|
75
|
+
def multiply(self, x1, x2, out: MlxArray = None, **kwargs) -> MlxArray:
|
76
|
+
x1 = self.to_backend_array(x1)
|
77
|
+
x2 = self.to_backend_array(x2)
|
78
|
+
|
79
|
+
if out is not None:
|
80
|
+
out[:] = self._array_backend.multiply(x1, x2, **kwargs)
|
81
|
+
return None
|
82
|
+
return self._array_backend.multiply(x1, x2, **kwargs)
|
83
|
+
|
75
84
|
def std(self, arr: MlxArray, axis) -> Scalar:
|
76
85
|
return self._array_backend.sqrt(arr.var(axis=axis))
|
77
86
|
|
@@ -84,30 +93,12 @@ class MLXBackend(NumpyFFTWBackend):
|
|
84
93
|
def tobytes(self, arr):
|
85
94
|
return self.to_numpy_array(arr).tobytes()
|
86
95
|
|
87
|
-
def preallocate_array(self, shape: Tuple[int], dtype: type = None) -> NDArray:
|
88
|
-
"""
|
89
|
-
Returns a byte-aligned array of zeros with specified shape and dtype.
|
90
|
-
|
91
|
-
Parameters
|
92
|
-
----------
|
93
|
-
shape : Tuple[int]
|
94
|
-
Desired shape for the array.
|
95
|
-
dtype : type, optional
|
96
|
-
Desired data type for the array.
|
97
|
-
|
98
|
-
Returns
|
99
|
-
-------
|
100
|
-
NDArray
|
101
|
-
Byte-aligned array of zeros with specified shape and dtype.
|
102
|
-
"""
|
103
|
-
arr = self._array_backend.zeros(shape, dtype=dtype)
|
104
|
-
return arr
|
105
|
-
|
106
96
|
def full(self, shape, fill_value, dtype=None):
|
107
97
|
return self._array_backend.full(shape=shape, dtype=dtype, vals=fill_value)
|
108
98
|
|
109
|
-
def fill(self, arr: MlxArray, value: Scalar) ->
|
99
|
+
def fill(self, arr: MlxArray, value: Scalar) -> MlxArray:
|
110
100
|
arr[:] = value
|
101
|
+
return arr
|
111
102
|
|
112
103
|
def zeros(self, shape: Tuple[int], dtype: type = None) -> MlxArray:
|
113
104
|
return self._array_backend.zeros(shape=shape, dtype=dtype)
|
@@ -189,13 +180,11 @@ class MLXBackend(NumpyFFTWBackend):
|
|
189
180
|
|
190
181
|
return rfftn, irfftn
|
191
182
|
|
192
|
-
def
|
193
|
-
|
194
|
-
) -> MlxArray:
|
195
|
-
return shm
|
183
|
+
def from_sharedarr(self, arr: MlxArray) -> MlxArray:
|
184
|
+
return arr
|
196
185
|
|
197
186
|
@staticmethod
|
198
|
-
def
|
187
|
+
def to_sharedarr(arr: MlxArray, shared_memory_handler: type = None) -> shm_type:
|
199
188
|
return arr
|
200
189
|
|
201
190
|
def topk_indices(self, arr: NDArray, k: int):
|
@@ -204,7 +193,7 @@ class MLXBackend(NumpyFFTWBackend):
|
|
204
193
|
ret = [self.to_backend_array(x) for x in ret]
|
205
194
|
return ret
|
206
195
|
|
207
|
-
def
|
196
|
+
def rigid_transform(
|
208
197
|
self,
|
209
198
|
arr: NDArray,
|
210
199
|
rotation_matrix: NDArray,
|
@@ -214,10 +203,8 @@ class MLXBackend(NumpyFFTWBackend):
|
|
214
203
|
out: NDArray = None,
|
215
204
|
out_mask: NDArray = None,
|
216
205
|
order: int = 3,
|
206
|
+
**kwargs,
|
217
207
|
) -> None:
|
218
|
-
rotate_mask = arr_mask is not None
|
219
|
-
return_type = (out is None) + 2 * rotate_mask * (out_mask is None)
|
220
|
-
|
221
208
|
arr = self.to_numpy_array(arr)
|
222
209
|
rotation_matrix = self.to_numpy_array(rotation_matrix)
|
223
210
|
|
@@ -227,46 +214,32 @@ class MLXBackend(NumpyFFTWBackend):
|
|
227
214
|
if translation is not None:
|
228
215
|
translation = self.to_numpy_array(translation)
|
229
216
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
out_mask_pass = self.to_numpy_array(out_mask)
|
217
|
+
if out is None:
|
218
|
+
out = self.zeros(arr.shape)
|
219
|
+
if out_mask is None and arr_mask is not None:
|
220
|
+
out_mask_pass = self.zeros(arr_mask.shape)
|
235
221
|
|
236
|
-
ret = NumpyFFTWBackend().
|
222
|
+
ret = NumpyFFTWBackend().rigid_transform(
|
237
223
|
arr=arr,
|
238
224
|
rotation_matrix=rotation_matrix,
|
239
225
|
arr_mask=arr_mask,
|
240
226
|
translation=translation,
|
241
227
|
use_geometric_center=use_geometric_center,
|
242
|
-
out=out_pass,
|
243
|
-
out_mask=out_mask_pass,
|
244
228
|
order=order,
|
245
229
|
)
|
246
230
|
|
247
|
-
|
248
|
-
|
249
|
-
out_pass = ret
|
250
|
-
elif len(ret) == 1 and out_mask is None:
|
251
|
-
out_mask_pass = ret
|
252
|
-
else:
|
253
|
-
out_pass, out_mask_pass = ret
|
231
|
+
out_pass, out_mask_pass = ret
|
232
|
+
out[:] = self.to_backend_array(out_pass)
|
254
233
|
|
255
|
-
if
|
256
|
-
|
234
|
+
if out_mask_pass is not None:
|
235
|
+
out_mask_pass = self.to_backend_array(out_mask_pass)
|
257
236
|
|
258
237
|
if out_mask is not None:
|
259
|
-
out_mask[:] =
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
case 1:
|
265
|
-
return out
|
266
|
-
case 2:
|
267
|
-
return out_mask
|
268
|
-
case 3:
|
269
|
-
return out, out_mask
|
238
|
+
out_mask[:] = out_mask_pass
|
239
|
+
else:
|
240
|
+
out_mask = out_mask_pass
|
241
|
+
|
242
|
+
return out, out_mask
|
270
243
|
|
271
244
|
def indices(self, arr: List) -> MlxArray:
|
272
245
|
ret = NumpyFFTWBackend().indices(arr)
|