pyfli.analysis.fit_analysis#

Plot fitted parameter maps, diagnostics, classifier summaries, and two-dimensional comparisons.

This module belongs to pyfli.analysis and is part of PyFLI post-processing, diagnostics, statistical comparison, and result-loading utilities for fitted FLI/FLIM datasets. Public API includes functions plot_fitting_maps(), plot_diagnostics(), plot_pixel_evidence(), plot_statistical_comparison(), plot_2d_analysis(), and run_mono_bi_classifier().

Functions

_resolve_threshold(map_key, per_key_thresholds)

Return the threshold for map_key, checking user overrides first.

plot_2d_analysis(all_datasets, names, ...[, ...])

2D subplot analysis (map + histogram + violin + boxplot + KDE + qq + CDF) per parameter map, for every fitting result.

plot_diagnostics(binned_decay, all_fitset, ...)

Pixel diagnostic overlays for all fitting results (log and linear scale).

plot_fitting_maps(all_datasets, names, map_keys)

Plot parameter maps for every fitting result.

plot_pixel_evidence(binned_decay, ...[, ...])

Single-pixel fit evidence plot for a randomly selected valid pixel.

plot_statistical_comparison(all_datasets, ...)

Comparative statistical plot per parameter key (box / violin / KDE / ...).

run_mono_bi_classifier(all_datasets, names, mask)

Run mono bi classifier.

plot_fitting_maps(all_datasets, names, map_keys, v_ranges=None, saver=None, cmap=None)[source]#

Plot parameter maps for every fitting result.

Parameters:
  • all_datasets (list[dict]   from load_fitting_results())

  • names (list[str])

  • map_keys (list[str]    keys to extract, e.g. [``’tau_map’``] or) – [‘alpha1_map’, ‘tau1_map’, ‘tau2_map’]

  • v_ranges (list[tuple] or None) – Display range per map, e.g. [(0, 1.5)] or [(0,1),(0,2),(0,2)]. Pass None to let DataViewer auto-scale.

  • saver (DataSaver or None)

  • cmap (colormap — defaults to jet with zero→black)

Return type:

None

plot_diagnostics(binned_decay, all_fitset, names, mask, saver=None)[source]#

Pixel diagnostic overlays for all fitting results (log and linear scale).

Returns:

fig_log, fig_lin

Return type:

Figure

Parameters:
  • binned_decay (Any)

  • all_fitset (Any)

  • names (Any)

  • mask (Any)

  • saver (Any | None)

plot_pixel_evidence(binned_decay, binned_irf, all_fitset, all_datasets, names, mask, saver=None, num=0)[source]#

Single-pixel fit evidence plot for a randomly selected valid pixel.

Parameters:
  • num (int   index into all_fitset / all_datasets to display (default 0))

  • binned_decay (Any)

  • binned_irf (Any)

  • all_fitset (Any)

  • all_datasets (Any)

  • names (Any)

  • mask (Any)

  • saver (Any | None)

Return type:

None

plot_statistical_comparison(all_datasets, names, map_keys, mask, saver=None, graph_type='box', colors_list=None, test_type='none', per_key_thresholds=None, percentile_clip=(1, 99))[source]#

Comparative statistical plot per parameter key (box / violin / KDE / …).

One figure is produced per key so that each parameter is filtered by its own physically valid range (e.g. alpha ∈ [0,1] vs tau ∈ [0,5 ns]). Thresholds fall back to DEFAULT_KEY_THRESHOLDS when not overridden.

Parameters:
  • all_datasets (list[dict])

  • names (list[str])

  • map_keys (list[str]   e.g. [``’tau_map’``] or) – [‘alpha1_map’, ‘tau1_map’, ‘tau2_map’]

  • mask (np.ndarray  (H, W) bool)

  • graph_type (str 'box', 'violin', 'swarm', 'overlay',) – ‘raincloud’, or ‘kde’

  • test_type (str 'none', 'paired', or 'welch')

  • colors_list (list        per-source colour hex strings)

  • per_key_thresholds (dict or None) – Override thresholds per key, e.g. {'tau_map': (0, 3), 'alpha1_map': (0, 1)}. Keys not listed fall back to DEFAULT_KEY_THRESHOLDS.

  • percentile_clip (tuple or None   (low%, high%) applied to every key;) – pass None to disable

  • saver (Any | None)

Returns:

figs

Return type:

dict[str, Figure]   keyed by map_key

plot_2d_analysis(all_datasets, names, map_keys, mask, per_key_thresholds=None, saver=None, cmap='jet')[source]#

2D subplot analysis (map + histogram + violin + boxplot + KDE + qq + CDF) per parameter map, for every fitting result.

Thresholds are resolved per key via DEFAULT_KEY_THRESHOLDS so that alpha maps are automatically clipped to [0, 1] and tau maps to [0, 5] unless overridden.

Parameters:
  • all_datasets (list[dict])

  • names (list[str])

  • map_keys (list[str]   e.g. [``’tau_map’``] or) – [‘alpha1_map’, ‘tau1_map’, ‘tau2_map’]

  • mask (np.ndarray  (H, W) bool)

  • per_key_thresholds (dict or None) – Override per key, e.g. {'tau2_map': (0, 3)}. Keys not listed fall back to DEFAULT_KEY_THRESHOLDS.

  • saver (DataSaver or None)

  • cmap (str   colormap for the spatial map panels)

Return type:

None

run_mono_bi_classifier(all_datasets, names, mask, alpha_upper=0.95, alpha_lower=0.05, tau_tol=0.01, scatter_keys=None, saver=None)[source]#

Run mono bi classifier.

Parameters:
  • all_datasets (Any) – Collection of fitted datasets to classify, compare, or summarize.

  • names (Any) – Dataset names used in summaries and plots.

  • mask (Any) – Boolean or labeled mask selecting pixels for the operation.

  • alpha_upper (float) – Upper alpha-fraction threshold used by the classifier.

  • alpha_lower (float) – Lower alpha-fraction threshold used by the classifier.

  • tau_tol (float) – Lifetime tolerance used by the mono/bi classifier.

  • scatter_keys (Any | None) – Parameter keys used in classifier scatter plots.

  • saver (Any | None) – Optional saver used to persist messages or figures.

Returns:

Tuple containing classifier outputs and mono/bi-exponential labels.

Return type:

tuple[Any, ]