smlmlp.globloc_fit module
- smlmlp.globloc_fit(crops, X0, Y0, /, channels_models, channels_fit_inits, *, optimizer='lm', estimator='mle', distribution='poisson', channels_pixels_nm=1.0, channels_gains=1.0, channels_QE=1.0, cuda=False, parallel=False)[source]
Fit global localizations from channel crops using joint fitting.
Uses
funclp.JointFunctionto fit all crops simultaneously, sharing position parameters across channels.- Parameters:
crops (sequence of ndarray) – Crop stacks to fit, one per channel, shaped
(N, Y, X).X0 (sequence of ndarray) – Crop x origins in pixels.
Y0 (sequence of ndarray) – Crop y origins in pixels.
channels_models (sequence of str) – Model per channel, one of
"gauss","isogauss","spline".channels_fit_inits (sequence of dict) – Initial fit parameters per channel.
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 for fitted amplitudes.
channels_QE (float or sequence, optional) – Quantum efficiency value(s) used for fitted amplitudes.
cuda (bool, optional) – Whether to use CUDA execution.
parallel (bool, optional) – Whether to use parallel execution.
- Returns:
A tuple
(mux, muy, info)where:muxis the concatenated x localization array in nanometers,muyis the concatenated y localization array in nanometers,infois a dictionary with fitted parameter arrays.
- Return type:
tuple
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)] >>> models = ["gauss"] >>> inits = [{"sigx": 90.0, "sigy": 90.0, "theta": 0.0, "theta_fit": False}] >>> mux, muy, info = globloc_fit( ... crops, x0, y0, ... channels_models=models, ... channels_fit_inits=inits, ... channels_pixels_nm=[(100.0, 100.0)], ... ) >>> mux.shape == muy.shape True
>>> 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)] >>> models = ["isogauss"] >>> inits = [{"sig": 90.0}] >>> mux, muy, info = globloc_fit( ... crops, x0, y0, ... channels_models=models, ... channels_fit_inits=inits, ... channels_pixels_nm=[(100.0, 100.0)], ... ) >>> info['sigma'].ndim 1