pyfli.solver.shared_metrics#

Centralize tau ordering, lifetime summaries, FRET efficiency, and fit-quality metrics.

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 functions enforce_tau_ordering(), compute_fli_stats(), compute_average_lifetime(), and compute_fret_efficiency().

Functions

compute_average_lifetime(popt)

Compute average lifetime.

compute_fli_stats(final_model, d_fit, n_params)

Compute FLI fit statistics.

compute_fret_efficiency(popt)

Compute FRET efficiency.

enforce_tau_ordering(popt[, perr, pcov, bounds])

Enforce tau ordering.

enforce_tau_ordering(popt, perr=None, pcov=None, bounds=None)[source]#

Enforce tau ordering.

Parameters:
  • popt (np.ndarray) – Optimized model parameter vector.

  • perr (Any | None) – One-standard-deviation parameter uncertainty estimates.

  • pcov (np.ndarray | None) – Parameter covariance matrix.

  • bounds (tuple[np.ndarray, np.ndarray] | None) – Optional (low, high) bound vectors used for the fit. When either tau1 or tau2 was pinned by the caller (low == high), that parameter’s slot is left alone.

Returns:

Tuple containing the reordered parameter vector and any reordered uncertainty or covariance data.

Return type:

tuple[Any, ]

compute_fli_stats(final_model, d_fit, n_params)[source]#

Compute FLI fit statistics.

Parameters:
  • final_model (np.ndarray) – Model decay evaluated at the fitted parameters.

  • d_fit (np.ndarray) – Measured decay samples over the fitted range.

  • n_params (int) – Number of fitted model parameters.

Returns:

Tuple containing SSR, chi-square, reduced chi-square, R-squared, and RMSE statistics.

Return type:

tuple[Any, ]

compute_average_lifetime(popt)[source]#

Compute average lifetime.

Parameters:

popt (np.ndarray) – Optimized model parameter vector.

Returns:

Amplitude-weighted average lifetime for bi-exponential fits or the mono-exponential lifetime.

Return type:

float

compute_fret_efficiency(popt)[source]#

Compute FRET efficiency.

Parameters:

popt (np.ndarray) – Optimized model parameter vector.

Returns:

FRET efficiency estimated from the fitted short and long lifetimes.

Return type:

float