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.IsoGaussianmodel 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
cropshas 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:muxis the detection-aligned x localization array in nanometers,muyis the detection-aligned y localization array in nanometers,infois a dictionary with fitted parameter arrays.
infocontains:'amp'Detection-aligned converted amplitudes.
'offset'Detection-aligned converted offsets.
'sigma'Detection-aligned fitted isotropic sigmas.
- Return type:
tuple
Notes
X0andY0are split bychso each origin vector follows the crop order inside its channel stack.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.
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