smlmlp.locs_individual_isogaussfit module

smlmlp.locs_individual_isogaussfit(crops, X0, Y0, /, ch=None, *, optimizer='lm', estimator='mle', distribution='poisson', channels_pixels_nm=1.0, channels_gains=1.0, channels_QE=1.0, cuda=False, parallel=False, channels_psf_sigmas_nm=93.8)[source]

Fit each crop independently with an isotropic 2D Gaussian model.

The function loops through channels, initializes a funclp.IsoGaussian model per event, runs the selected optimizer/estimator combination, and returns localized coordinates with fitted parameters.

Parameters:
  • crops (sequence of array-like) – Sequence of crop stacks, one per channel, shaped (N, Y, X).

  • X0 (array-like) – Detection-aligned 1D vector of x-origin pixel indices.

  • Y0 (array-like) – Detection-aligned 1D vector of y-origin pixel indices.

  • ch (array-like or None, optional) – One-based channel index for each detection. Required when crops has several channels.

  • optimizer (str, optional) – Optimizer key.

  • estimator (str, optional) – Estimator key.

  • distribution (str, optional) – Distribution key used by the estimator.

  • channels_pixels_nm (float or sequence, optional) – Pixel size specification per channel.

  • channels_gains (float or sequence, optional) – Gain value(s) used to convert fitted amplitudes.

  • channels_QE (float or sequence, optional) – Quantum efficiency value(s) used to convert fitted amplitudes.

  • cuda (bool, optional) – Whether to run the fit on GPU.

  • parallel (bool, optional) – Whether to enable CPU parallelization.

  • channels_psf_sigmas_nm (float or sequence, optional) – Initial/fixed isotropic PSF sigma for each channel.

Returns:

A tuple (mux, muy, info) where:

  • mux is the detection-aligned x localization array in nanometers,

  • muy is the detection-aligned y localization array in nanometers,

  • info is a dictionary with fitted parameter arrays.

info contains:

'amp'

Detection-aligned converted amplitudes.

'offset'

Detection-aligned converted offsets.

'sigma'

Detection-aligned fitted isotropic sigmas.

Return type:

tuple

Notes

  1. X0 and Y0 are split by ch so each origin vector follows the crop order inside its channel stack.

  2. A local coordinate grid is built from the channel pixel size, and each fit is initialized at the crop center with amplitude/offset from the crop maximum/minimum.

  3. The optimizer updates local model parameters, local coordinates are shifted by crop origins, and all outputs are remapped to detection order.

Examples

>>> import numpy as np
>>> crops = [np.random.rand(2, 7, 7).astype(np.float32)]
>>> x0 = np.array([10, 20], dtype=np.float32)
>>> y0 = np.array([30, 40], dtype=np.float32)
>>> mux, muy, info = locs_individual_isogaussfit(
...     crops,
...     x0,
...     y0,
...     channels_pixels_nm=[(100.0, 100.0)],
...     channels_psf_sigmas_nm=[90.0],
... )
>>> mux.shape == muy.shape
True
>>> sorted(info)
['amp', 'offset', 'sigma']
>>> mux, muy, info = locs_individual_isogaussfit(
...     crops,
...     x0,
...     y0,
...     channels_pixels_nm=[(100.0, 120.0)],
...     channels_psf_sigmas_nm=[80.0],
... )
>>> info['sigma'].ndim
1