pyfli.solver.global_fitter#

Fit cluster-level super-pixels and stitch global FLI fit results back into image maps.

This module belongs to pyfli.solver and is part of PyFLI least-squares, maximum- likelihood, CPU, GPU, binned, and global FLI fitting routines. Public API includes classes GlobalFLIFitter.

Functions

_lifetime_bounds(super_pixel, gi_tol)

Classes

GlobalFLIFitter(freq, base_fitter_class, ...)

Fit clusters or super-pixels before stitching parameters back into image maps.

class GlobalFLIFitter(freq, base_fitter_class, mle_fitter_class, processor_instance=None)[source]#

Bases: object

Fit clusters or super-pixels before stitching parameters back into image maps. It supports SNR-weighted cluster fitting, local refinement, and result reconstruction for global workflows.

Parameters:
  • freq (float) – Acquisition frequency information used to derive timing constants.

  • base_fitter_class (Any) – Least-squares fitter class used as a fitting backend.

  • mle_fitter_class (Any) – Maximum-likelihood fitter class used as a fitting backend.

  • processor_instance (Any | None) – Optional processor reused for pixel-level fitting or reconstruction.

make_clusters(image_cube, irf_cube, cluster_mask, min_cluster_size=10)[source]#

Extracts cluster-specific data and stores spatial coordinates for reconstruction.

Parameters:
Return type:

Any

super_pixel_fitting(cluster_strategy='snr_weighted', estimator='least_squares', model_type='bi-exponential', p0=None, bounds=None, fit_indices=None, shift_method='zero_pad', excitation='bin_start', gate_width=None, **fit_kwargs)[source]#

Performs high-SNR super-pixel fitting and triggers comparison plots.

fit_kwargs (e.g. weighting, max_iter) are passed to the fitter’s fit_with_estimator, as for the per-pixel cluster fits; shift_method, excitation and gate_width select the forward model (pyfli.cm_funcs.forward_model.model_numpy()).

Parameters:
Return type:

tuple[Any, …]

process_clusters(image_cube, irf_cube, mask=None, gi_tol=0.2, **kwargs)[source]#

global_inference=True: Super-pixel values are seeds (p0), bounds are wide. global_inference=False: Super-pixel values are seeds (p0), lifetimes constrained to [max(v (1 - tol), 1e-3), v (1 + tol)] around the super-pixel value v. gi_tol is one tolerance for every lifetime, or a dict of per-lifetime tolerances (keys "tau1", "tau2" / "tau"); lifetimes not in the dict are left free, e.g. {"tau2": 1.0} caps only the long lifetime at twice the super-pixel value.

Parameters:
Return type:

tuple[Any, …]

stitch_results(cluster_results, H, W, T, model_type='bi-exponential')[source]#

Combines cluster-wise datasets into global maps with corrected TR naming.

Parameters:
Return type:

Any