pyfli.phasor.phasorS.phasor_simple#

Implement a compact phasor analyzer for CPU and optional GPU workflows.

This module belongs to pyfli.phasor.phasorS and is part of PyFLI’s compact phasor analyzer for CPU and optional GPU FLI workflows. Public API includes classes PhasorAnalyzer.

Classes

PhasorAnalyzer(frequency_hz, time_axis_ns[, ...])

Compute, calibrate, and interpret FLI phasors from decay data.

class PhasorAnalyzer(frequency_hz, time_axis_ns, n_harmonics=1, device=None)[source]#

Bases: PhasorPlotsMixin

Compute, calibrate, and interpret FLI phasors from decay data. The analyzer supports NumPy and optional Torch execution, multi-harmonic phasors, IRF calibration, lifetime conversion, fractional component estimates, and plotting through the phasor mixin.

Parameters:
  • frequency_hz (float) – Excitation frequency in hertz.

  • time_axis_ns (np.ndarray) – Time axis for decay samples in nanoseconds.

  • n_harmonics (int) – Number of phasor harmonics to compute.

  • device (Any | None) – Execution device, such as a Torch device or device string.

create_phasor_cpu(decay)[source]#

Create phasor cpu.

Parameters:

decay (np.ndarray) – Time-resolved decay signal or decay cube.

Returns:

Object produced by create phasor CPU.

Return type:

Any

create_phasor_gpu(decay)[source]#

Create phasor gpu.

Parameters:

decay (np.ndarray) – Time-resolved decay signal or decay cube.

Returns:

Tuple containing GPU-computed phasor coordinates and intensity values.

Return type:

tuple[Any, ]

calibrate(G, S, irf)[source]#

Run the calibrate routine.

Parameters:
  • G (np.ndarray) – Phasor real coordinate.

  • S (np.ndarray) – Phasor imaginary coordinate or shift amount.

  • irf (np.ndarray) – Instrument response function aligned with the decay signal.

Returns:

Tuple containing calibrated phasor coordinates and calibration factors.

Return type:

tuple[Any, ]

calibrate_pixelwise(G, S, irf)[source]#

Run the calibrate pixelwise routine.

Parameters:
  • G (np.ndarray) – Phasor real coordinate.

  • S (np.ndarray) – Phasor imaginary coordinate or shift amount.

  • irf (np.ndarray) – Instrument response function aligned with the decay signal.

Returns:

Tuple containing per-pixel calibrated phasor coordinates and factors.

Return type:

tuple[Any, ]

calibratre_reference(G, S, ref_data, ref_lifetime_ns=None)[source]#

Run the calibratre reference routine.

Parameters:
  • G (np.ndarray) – Phasor real coordinate.

  • S (np.ndarray) – Phasor imaginary coordinate or shift amount.

  • ref_data (np.ndarray) – Decay trace of a reference sample used for calibration.

  • ref_lifetime_ns (float | None) – Known lifetime of the reference sample in nanoseconds. When None, the reference is treated as a zero-lifetime instrument response, matching calibrate().

Returns:

Tuple containing calibrated phasor coordinates and calibration factors.

Return type:

tuple[Any, ]

calibratre_reference_pixelwise(G, S, ref_data, ref_lifetime_ns=None)[source]#

Run the calibratre reference pixelwise routine.

Parameters:
  • G (np.ndarray) – Phasor real coordinate.

  • S (np.ndarray) – Phasor imaginary coordinate or shift amount.

  • ref_data (np.ndarray) – Per-pixel decay cube of a reference sample used for calibration.

  • ref_lifetime_ns (float | None) – Known lifetime of the reference sample in nanoseconds. When None, the reference is treated as a zero-lifetime instrument response, matching calibrate_pixelwise().

Returns:

Tuple containing per-pixel calibrated phasor coordinates and factors.

Return type:

tuple[Any, ]

lifetime_to_phasor(tau_ns, frequency_hz)[source]#

Run the lifetime to phasor routine.

Parameters:
  • tau_ns (np.ndarray) – Lifetime value in nanoseconds.

  • frequency_hz (float) – Excitation frequency in hertz.

Returns:

Tuple containing phasor coordinates for the supplied lifetime values.

Return type:

tuple[Any, ]

compute_lifetime(G, S)[source]#

Compute lifetime.

Parameters:
  • G (np.ndarray) – Phasor real coordinate.

  • S (np.ndarray) – Phasor imaginary coordinate or shift amount.

Returns:

Lifetime map derived from phasor coordinates.

Return type:

np.ndarray

compute_modulation_lifetime(G, S)[source]#

Compute modulation lifetime.

Parameters:
  • G (np.ndarray) – Phasor real coordinate.

  • S (np.ndarray) – Phasor imaginary coordinate or shift amount.

Returns:

Object produced by compute modulation lifetime.

Return type:

Any

compute_fractions(G, S, tau1_ns, tau2_ns, mask=None, hexbin_color=None, plot_graph=True, ax=None, half_circle=False)[source]#

Compute fractions.

Parameters:
  • G (np.ndarray) – Phasor real coordinate.

  • S (np.ndarray) – Phasor imaginary coordinate or shift amount.

  • tau1_ns (np.ndarray) – Short lifetime component in nanoseconds.

  • tau2_ns (np.ndarray) – Long lifetime component in nanoseconds.

  • mask (np.ndarray | None) – Boolean or labeled mask selecting pixels for the operation.

  • hexbin_color (np.ndarray | None) – Optional values used to color phasor hexbin density.

  • plot_graph (bool) – Whether the phasor graph should be drawn.

  • ax (Any | None) – Matplotlib axes object on which the plot is drawn.

  • half_circle (bool) – Whether to draw only the upper half of the universal phasor circle.

Returns:

Tuple containing component fractions estimated from phasor geometry.

Return type:

tuple[Any, ]

analyze_biexponential_and_reconstruct(G, S, irf, tau1_ns=None, tau2_ns=None, plot=True, axes=None)[source]#

Run the analyze biexponential and reconstruct routine.

Parameters:
  • G (np.ndarray) – Phasor real coordinate.

  • S (np.ndarray) – Phasor imaginary coordinate or shift amount.

  • irf (np.ndarray) – Instrument response function aligned with the decay signal.

  • tau1_ns (np.ndarray | None) – Short lifetime component in nanoseconds.

  • tau2_ns (np.ndarray | None) – Long lifetime component in nanoseconds.

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

  • axes (Any | None) – Matplotlib axes collection used for drawing subplots.

Returns:

Object produced by analyze biexponential and reconstruct.

Return type:

Any

generate_intensity_image(decay)[source]#

Generate intensity image.

Parameters:

decay (np.ndarray) – Time-resolved decay signal or decay cube.

Returns:

Intensity image obtained by integrating the decay along the time axis.

Return type:

np.ndarray

save_phasors_hdf5(Gc, Sc, tau_phasor, save_file)[source]#

Save phasors hdf5.

Parameters:
  • Gc (Any) – Calibrated phasor real coordinate map.

  • Sc (Any) – Calibrated phasor imaginary coordinate map.

  • tau_phasor (np.ndarray) – Lifetime map estimated from phasor coordinates.

  • save_file (np.ndarray) – HDF5 path where phasor results are saved.

Returns:

No object is returned; the function save phasors hdf5.

Return type:

None