implement gaussian_pixel_int and modal_analysis

This commit is contained in:
w.pomp committed 2026-11-17 11:58:36 +01:00
1 parent 7a0b09c4c1
commit 3f2f01d795
7 files changed
+729 -16

No files matched your search

+53
View File
@@ -1,11 +1,15 @@
# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401, F403, F405
import builtins
import numpy
import numpy.typing
import typing
__all__ = [
"gaussian",
"gaussian_pixel_int",
"modal_analysis",
]
def gaussian(x: numpy.typing.ArrayLike, p: numpy.typing.ArrayLike) -> numpy.typing.NDArray[numpy.float64]:
@@ -13,3 +17,52 @@ def gaussian(x: numpy.typing.ArrayLike, p: numpy.typing.ArrayLike) -> numpy.typi
x: n 1d arrays, defining coordinates in each dimension
p: I, x0, x1, ... xn, s00, s01, ..., s0n, s10, s11, ..., s1n, ..., sn0, sn1, ..., snn, o, o0, o1, ..., on
"""
def gaussian_pixel_int(x: numpy.typing.ArrayLike, p: numpy.typing.ArrayLike) -> numpy.typing.NDArray[numpy.float64]:
r"""
p: I, x0, x1, ... xn, s00, s01, ..., s0n, s10, s11, ..., s1n, ..., sn0, sn1, ..., snn, o, o0, o1, ..., on
x: n 1d arrays, defining coordinates in each dimension
gaussian, but the signal is integrated over each pixel
Pixels are assumed to be unit hypercubes, i.e. pixel `i` in each dimension
covers `[x_i - 1/2, x_i + 1/2]`.
The pixel integral is evaluated as a product of 1D analytic integrals in
the eigenspace of the covariance (exact when the covariance is diagonal,
and the standard product-form approximation otherwise). Eigenvalues below
`n * eps * lambda_max` are treated as zero, in which case that dimension
contributes the point-emitter limit: 1 inside the pixel containing the
center, 1/2 on its boundary, and 0 elsewhere. Unlike `gaussian`, this works
for rank-deficient covariances.
"""
def modal_analysis(
g: numpy.typing.ArrayLike,
x: typing.Sequence[builtins.float],
s: typing.Sequence[builtins.float],
window_size: typing.Sequence[builtins.int],
n_iter: builtins.int,
tolerance: builtins.float,
background_subtraction: builtins.str,
fix_location: builtins.bool,
) -> builtins.list[builtins.float]:
r"""
Applies the algorithm from [Thompson et al. (2002) PNAS, 82:2775].
Parameters:
- g: an array with the image
- x: approximate coordinates of the spot to localize
- s: sigma
- fix_location: If 1, applied the iterative localization refinement algorithm, starting with the coordinates provided in coo. If 0, only measures the spot intensity at the coordinates provided in coo.
- background_subtraction: 0 -> no background subtraction. 1 -> constant background subtraction. 2 -> tilted plane background subtraction.
- window_size: size of the window (in pixels) around the position in coo, used for the iterative localization and for the background subtraction.
- tolerance: cutoff to determine convergence, i.e. the distance (in pixels) between two iterations
- n_iter: the maximal number of iterations.
Returns
- the intensity value of the spot.
- the coordinates of the spot.
- the backgound offset
- the tilted background
raises MaxIterations if not found after n_iter iterations
"""