pyfli.solver.comparison#

Compare least-squares and maximum-likelihood fitters across selected pixels and datasets.

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 FittingComparator.

Classes

FittingComparator(freq, base_fitter_class, ...)

Compare fitting methods on selected pixels or whole datasets.

class FittingComparator(freq, base_fitter_class, mle_fitter_class)[source]#

Bases: object

Compare fitting methods on selected pixels or whole datasets. It runs base and MLE fitters, summarizes model statistics, plots comparisons, and saves comparison outputs.

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.

compare_selected(methods, y_data, irf_data, model_type='bi-exponential', p0=None, bounds=None, yscale='log', plot=True, fit_indices=None)[source]#

Compare selected.

Parameters:
  • methods (np.ndarray) – Names of fitting methods to include in the comparison.

  • y_data (np.ndarray) – Observed decay data passed to the fitter.

  • irf_data (np.ndarray) – Instrument response data used to convolve or simulate decays.

  • model_type (str) – FLI model family, such as mono- or bi-exponential.

  • p0 (Any | None) – Initial parameter vector supplied to the optimizer.

  • bounds (np.ndarray | None) – Lower and upper parameter bounds supplied to the optimizer.

  • yscale (str) – Scale used for the y-axis.

  • plot (bool) – Whether diagnostic plots should be generated.

  • fit_indices (tuple[int, int] | None) – Optional (gate_num_start, gate_num_end) gate range to fit over.

Returns:

Tuple containing comparison metrics for the selected fitting methods.

Return type:

tuple[Any, ]

run_all(y_data, irf_data, model_type='bi-exponential', p0=None, bounds=None, yscale='log', plot=True, fit_indices=None)[source]#

Run all.

Parameters:
  • y_data (np.ndarray) – Observed decay data passed to the fitter.

  • irf_data (np.ndarray) – Instrument response data used to convolve or simulate decays.

  • model_type (str) – FLI model family, such as mono- or bi-exponential.

  • p0 (Any | None) – Initial parameter vector supplied to the optimizer.

  • bounds (np.ndarray | None) – Lower and upper parameter bounds supplied to the optimizer.

  • yscale (str) – Scale used for the y-axis.

  • plot (bool) – Whether diagnostic plots should be generated.

  • fit_indices (tuple[int, int] | None) – Optional (gate_num_start, gate_num_end) gate range to fit over.

Returns:

Object produced by run all.

Return type:

Any

save_results(saver, results_table, fig=None, model_type='bi-exponential', name='fitting_comparison')[source]#

Save results.

Parameters:
  • saver (Any) – Optional saver used to persist messages or figures.

  • results_table (np.ndarray) – Rows of fit comparison results written to disk.

  • fig (Any | None) – Matplotlib figure object to update or save.

  • model_type (str) – FLI model family, such as mono- or bi-exponential.

  • name (str) – Dataset, experiment, figure, or output name.

Returns:

No object is returned; the function save results.

Return type:

None