pyfli.data_vnp.mono_bi_classifier#
Classify mono- versus bi-exponential fit agreement and visualize parameter correlations.
This module belongs to pyfli.data_vnp and is part of PyFLI visualization,
normalization, plotting, and mono-versus-bi-exponential comparison tools. Public API
includes classes MonoBiClassifier and ParamCorrelationMatrix.
Classes
|
Classify agreement between mono- and bi-exponential fits across one or more datasets. |
|
Visualize pairwise parameter relationships under an agreement mask. |
- class MonoBiClassifier(b_bool_mask, names=None, alpha_upper=0.95, alpha_lower=0.05, tau_tol=0.01, coord=None, figsize=None)[source]#
Bases:
objectClassify agreement between mono- and bi-exponential fits across one or more datasets. It builds masks from lifetime and fraction criteria, summarizes agreement, and plots parameter comparisons.
- Parameters:
b_bool_mask (
np.ndarray) – Mask array used to select or label pixels.names (
Any | None) – Names used to label datasets, classes, or plotted groups.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.coord (
Any | None) – Pixel or ROI coordinate used for lookup and plotting.figsize (
np.ndarray | None) – Figure size passed to Matplotlib.
- CMAP_NAMES = ('jet', 'Spectral', 'Spectral_r')#
- PALETTE: ClassVar[list[str]] = ['#5DADE2', '#EC7063', '#58D68D', '#F4D03F', '#AF7AC5', '#EB984E', '#48C9B0', '#52BE80', '#AAB7B8', '#F1948A', '#BB8FCE', '#7FB3D5', '#76D7C4']#
- classify_one(res, name='Dataset')[source]#
Classify one.
- Parameters:
res (
Any) – Fit result object or dataset result dictionary.name (
str) – Dataset, experiment, figure, or output name.
- Returns:
Dictionary containing the data produced by classify one.
- Return type:
dict[Any,Any]
- display_one(result)[source]#
Display one.
- Parameters:
result (
Any) – Classification or fitting result to display.- Returns:
No object is returned; the function display one.
- Return type:
- classify(all_datasets, names=None, display=True)[source]#
Classify every dataset; store self.results and self.all_datasets.
- agreement(metric='jaccard', classes_to_show=('mono', 'bi'), cmap='viridis', figsize=None, show=True)[source]#
Pairwise agreement between methods on the mono/bi classification.
- metric‘count’ raw # pixels both methods call this class
‘jaccard’ |A∩B| / |A∪B| (symmetric, 0..1) ‘fraction’ |A∩B| / |A| (asymmetric, read by row)
Returns (dict {class: NxN matrix}, fig).
- param_scatter_matrix(param='tau1_map', cls='mono', agree='pairwise', max_points=3000, colors=None, figsize=None, rng=None, show=True)[source]#
Cross-method correlation of ONE parameter over the pixels of ONE class.
diagonal (i, i) histogram of param for method i over its cls pixels off-diag (i, j) scatter of method_i (y) vs method_j (x), 1:1 line + r
- agree‘pairwise’ (cell uses pixels both i & j call cls)
‘all’ (every cell uses pixels ALL methods agree on)
- agreed_param_table(cls='mono', params=('alpha1_map', 'tau1_map', 'tau2_map'))[source]#
Long-form table of parameter values at pixels where ALL methods agree on cls. One row per (pixel, method) -> groupby(‘method’).describe().
Parameters missing from a dataset (e.g. Phasor has only ‘tau_map’, mono-exp datasets lack ‘alpha1_map’/’tau2_map’) are filled with NaN instead of raising KeyError.
- class ParamCorrelationMatrix(all_datasets, bool_mask, names=None)[source]#
Bases:
objectVisualize pairwise parameter relationships under an agreement mask. It supports subsampling, scalar and distribution-valued maps, uncertainty display, and pairwise scatter panels.
- Parameters:
all_datasets (
np.ndarray) – Sequence or mapping of fitted datasets to compare.bool_mask (
np.ndarray) – Boolean mask selecting pixels included in the analysis.names (
Any | None) – Names used to label datasets, classes, or plotted groups.
- PALETTE: ClassVar[list[str]] = ['#5DADE2', '#EC7063', '#58D68D', '#F4D03F', '#AF7AC5', '#EB984E', '#48C9B0', '#52BE80', '#AAB7B8', '#F1948A', '#BB8FCE', '#7FB3D5', '#76D7C4']#
- scatter_matrix(param='tau1_map', agree='pairwise', max_points=3000, colors=None, figsize=None, rng=None, show=True)[source]#
N × N cross-method scatter matrix for a single parameter.
Diagonal : histogram of pixel means within the ROI. Off-diagonal: dataset_i (y) vs dataset_j (x) with identity line + r.
Scalar data → scatter points. Distribution data → mean circle with ± std error bars.
- Parameters:
param (
str Key present in the dataset dicts.)agree (str
'pairwise'— each cell uses pixels finite in both) – datasets. ‘all’ — restricted to pixels finite in ALL datasets simultaneously.max_points (
int Cap on plotted points (random sub-sample).)colors (
list Per-dataset colours (cycles PALETTE by default).)figsize (
tuple Figure size; auto-scaledtoN if None.)rng (
np.random.Generator For reproducible sub-sampling.)show (
bool Call plt.show() when True.)
- Returns:
fig
- Return type:
- pairwise_scatter(idx_a, idx_b, params=('tau1_map', 'tau2_map', 'alpha1_map'), max_points=3000, colors=None, figsize=None, rng=None, show=True)[source]#
Scatter plots for multiple parameters between exactly two datasets.
Scalar parameter (H, W) → plain scatter point per pixel. Distribution parameter (H, W, N) → mean circle with ± std error bars.
- Parameters:
idx_a (
intorstr) – Dataset for y-axis (idx_a) and x-axis (idx_b). Accepts integer position or name string.idx_b (
intorstr) – Dataset for y-axis (idx_a) and x-axis (idx_b). Accepts integer position or name string.params (
sequenceofstr) – Parameter keys to compare; missing keys produce blank panels.max_points (
int Cap on plotted points (random sub-sample).)colors (
list One colour per parameter panel (cycles PALETTE).)figsize (
tuple Figure size; auto-sizedtonumberofparams if None.)rng (
np.random.Generator For reproducible sub-sampling.)show (
bool Call plt.show() when True.)
- Returns:
fig
- Return type: