pyfli.simulator.calibration_engine#

Calibrate simulator hardware parameters against experimental decay cubes.

This module belongs to pyfli.simulator and is part of PyFLI synthetic FLI/FLIM data generation, hardware noise modeling, calibration, and validation tools. Public API includes classes FLICalibrator.

Classes

FLICalibrator(irf_data[, method, threshold, ...])

Estimate simulator hardware parameters from experimental decay cubes.

class FLICalibrator(irf_data, method='analytical', threshold=10, normalize_stats=False)[source]#

Bases: object

Estimate simulator hardware parameters from experimental decay cubes. It optimizes noise and detector settings, reports calibration quality, cross-validates results, and can save reusable hardware profiles.

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

  • method (str) – Algorithm or model-selection method to use.

  • threshold (int) – Threshold applied to counts, masks, or statistics.

  • normalize_stats (bool) – Whether calibration statistics are normalized before comparison.

objective_function(x, exp_decay_cube, base_cfg)[source]#

Run the objective function routine.

Parameters:
  • x (np.ndarray) – Input array, coordinate, or signal being transformed.

  • exp_decay_cube (np.ndarray) – Experimental decay cube used for calibration.

  • base_cfg (np.ndarray) – Base simulator configuration copied during calibration.

Returns:

Object produced by objective function.

Return type:

Any

display_report(results)[source]#

Display report.

Parameters:

results (Any) – Calibration, fitting, or validation results.

Returns:

No object is returned; the function display report.

Return type:

None

run_calibration(exp_decay_cube, base_config, initial_guess=None)[source]#

Run calibration.

Parameters:
  • exp_decay_cube (np.ndarray) – Experimental decay cube used for calibration.

  • base_config (np.ndarray) – Base simulator configuration used for calibration or sensitivity analysis.

  • initial_guess (np.ndarray | None) – Initial optimizer parameter vector.

Returns:

Calibration results for the configured simulator.

Return type:

np.ndarray

cross_validate(calibrated_cfg, test_exp_cube)[source]#

Run the cross validate routine.

Parameters:
  • calibrated_cfg (np.ndarray) – Calibrated simulator configuration used for validation.

  • test_exp_cube (np.ndarray) – Experimental decay cube used for cross-validation.

Returns:

Cross-validation scores for the calibration model.

Return type:

np.ndarray

save_hardware_profile(filename='hw_profile.json')[source]#

Save hardware profile.

Parameters:

filename (str) – File name used for saving or loading results.

Returns:

No object is returned; the function save hardware profile.

Return type:

None

static load_hardware_profile(filename)[source]#

Load hardware profile.

Parameters:

filename (str) – File name used for saving or loading results.

Returns:

Object produced by load hardware profile.

Return type:

Any

plot_noise_sensitivity(train_exp_cube, base_config, dcr_range=(0.001, 0.1, 10), sigma_range=(0.5, 4.0, 10))[source]#

Plot noise sensitivity.

Parameters:
  • train_exp_cube (np.ndarray) – Array cube processed by the routine.

  • base_config (np.ndarray) – Base simulator configuration used for calibration or sensitivity analysis.

  • dcr_range (tuple[float, float, int]) – Dark-count-rate values evaluated during sensitivity analysis.

  • sigma_range (tuple[float, float, int]) – Read-noise sigma values evaluated by the sensitivity plot.

Returns:

Tuple containing noise-sensitivity figure data and summary metrics.

Return type:

tuple[Any, ]