7  Lifetime Features (Fit)

Biological samples often contain mixtures of fluorescent species, each with its own characteristic lifetime. By modeling the decay as a sum of exponentials, the analysis can separate and quantify these different contributions. For example, NADH in cells exists in both free (short lifetime, ~0.4 ns) and protein-bound (longer lifetime, ~2–3 ns) states; by fitting the fluorescence decay with a bi-exponential model, one can estimate the fraction of each state, which provides direct insight into cellular metabolism and energy production pathways.

FLIM Playground extracts cell-level lifetime fitting features in this feature extractor, including the fraction of each lifetime component (\(\alpha_i\)), their lifetimes (\(\tau_i\)), mean lifetime (\(\tau_{mean}\)), intensity-weighted mean lifetime (\(\tau_{m,iw}\)), and the reduced chi-square (\(\chi^2_r\)) goodness-of-fit metric. (See here for the definition of the equation below)

\[I(t) = \sum_{i=1}^n A_i \, e^{-t/\tau_i}\]

7.1 Fitting

If the decays have not been pre-fit, FLIM Playground applies the confirmed fitting options (number of components, fixed lifetimes, time gates, metric, and fitting mode) to the reconvolution fitting process. The IRF shift is fixed at the confirmed value for the channel or FOV. After confirmation, cell-level fitting defaults to Local; see When to choose Hybrid over Local for the mode behavior and trade-offs. These per-cell fits are parallelized across CPU cores. Reconvolution fitting minimizes the selected cost metric between the measured decay and a multi-exponential model convolved with the IRF.

Local is the recommended default for cell-level fits after shift calibration. It performs a one-time differential-evolution warm start on the mean decay, then fits each cell with a local optimizer (leastsq for WLS or nelder otherwise). Hybrid runs differential evolution separately for each cell before the same local refinement, so it usually takes longer.

The benchmark below simulated mono-, bi-, and tri-exponential decays with a fixed, correctly calibrated IRF, Poisson noise, 2% background, and 20-cell batches at 1,000–300,000 photons. The error is median per-cell lifetime MAPE; lower is better.

Model Accuracy result
Mono-exponential Accuracy was indistinguishable
Bi-exponential Accuracy was indistinguishable
Tri-exponential Local was equal or better overall; at 1,000 photons, MLE was 30.8% for Local vs. 33.0% for Hybrid, and WLS was 13.7% vs. 36.1%

A separate production-path timing used 342 real T-cell decays with a bi-exponential model, a fixed measured IRF, fit_shift=False, and eight physical worker processes. The complete batch was fit in:

Fit metric Local Hybrid Hybrid/Local
MLE 5.7 s 45.7 s 8.0×
WLS 7.2 s 47.6 s 6.6×

This larger batch exposes the cost of the per-cell global searches that multiprocessing can hide in a small 20-cell benchmark.

Choose Hybrid when Local produces a suspicious fit, such as a lifetime at a parameter boundary, a weak or merged component, failed convergence, or a visibly poor residual. It can also help with difficult real data whose model or IRF differs from the warm-start assumptions. If Local produces a valid fit with good residuals, Hybrid is unlikely to improve the lifetime estimate.

These results support Local as the default; they do not show that Hybrid is never useful for model mismatch or very low-count tri-exponential decays.

Otherwise, FLIM Playground uses the pre-fit values to calculate the fitting features.

In the final dataset, the primary fitting features are prefixed by the combination of the feature extractor name (i.e. Lifetime fit) and the channel name, allowing Data Analysis to group the features. For example, Lifetime fit_nadh: a1 means the fraction of the first lifetime component for the NAD(P)H channel.

Not every column produced by this extractor carries that prefix. The lifetimes (\(\tau_i\), \(\tau_{mean}\), \(\tau_{m,iw}\)) and the leading fractions do, but the raw amplitudes (\(A_i\)), the constant offset, the reduced chi-square, and the final fraction (which is derived as the remainder of the others) are written with only the channel name, e.g. nadh_reduced_chi_square. These are treated as bookkeeping values, so Data Analysis places them in the Uncategorized Features group rather than under Lifetime fit_nadh.

ImportantUnits in the exported dataset

The extracted CSV mixes three units, so check the column before using a value in a formula:

  • Lifetimes (t1, t2, t3, tm, tm_iw) are exported in picoseconds, even though this chapter writes the formulas in nanoseconds.
  • Fractions (a1, a2, a3) are exported as percentages in the range 0–100, not as the 0–1 fraction \(\alpha_i\) used in the formulas below. Divide by 100 before substituting them into \(\tau_{mean}\) or \(\tau_{m,iw}\).
  • Phasor-derived lifetimes from the Lifetime fit free extractor (Tau_phase, Tau_mod) are in nanoseconds.

7.1.1 Preprocessing

It sums up all the pixel decays belonging to the same cell ROI labeled by the ROI mask as one decay curve1. The ROI summing reduces variability and bias and allows for short integration times at acquisition in exchange for sub-cellular resolution (i.e., pixel-level). Users do not need to specify the bin factor (each pixel sums up the surrounding pixels’ decay curves) to account for insufficient photon counts. ROI-level aggregation also keeps the workload manageable; independent ROI fits are then run in parallel across CPU cores.

It also shifts the IRF using the shift values from the IRF shift calibration step. To shift an IRF, FLIM Playground upsamples the IRF 10 times using linear interpolation to fill the gaps. Then it shifts the IRF by the shift values \(\times 10\) and downsamples the IRF back to the original size.

7.1.2 Fraction of components

In addition to the absolute amplitudes of each component directly from the fitting result, FLIM Playground calculates the fraction of each component, \(\alpha_i\), as the amplitude of the component divided by the sum of all amplitudes. This normalization allows lifetime to be independent of the absolute intensity of the signal.

\(\alpha_i\) is a value between 0 and 1, and it is used in that form throughout the formulas in this chapter. In the exported dataset, however, the corresponding a1/a2/a3 columns are stored as percentages (\(\alpha_i \times 100\), ranging from 0 to 100). The final fraction is not fitted independently; it is derived as the remainder that makes the fractions sum to 100.

7.1.3 Mean lifetime

The mean lifetime, \(\tau_{mean}\), is calculated as the weighted average of the lifetimes of all components, where the weights are the fractions of each component.

\[\tau_{mean} = \sum_{i=1}^n \alpha_i \tau_i\]

7.1.4 Intensity-weighted mean lifetime

The mean lifetime above is amplitude-weighted: each component is weighted by its fraction \(\alpha_i\). The intensity-weighted mean lifetime, \(\tau_{m,iw}\), instead weights each component by its relative intensity contribution (\(\alpha_i \tau_i\)), so longer-lived components — which emit more photons per molecule — count more.

\[\tau_{m,iw} = \frac{\sum_{i=1}^n \alpha_i \tau_i^2}{\sum_{i=1}^n \alpha_i \tau_i} = \frac{\sum_{i=1}^n \alpha_i \tau_i^2}{\tau_{mean}}\]

For a single component, \(\tau_{m,iw} = \tau_1\).

Both fitting and the pixel pre-fit workflow export \(\tau_{mean}\) (tm) and \(\tau_{m,iw}\) (tm_iw) only for two or three components. For a single component, both mean lifetimes equal \(\tau_1\): use the exported t1 column, as no separate tm or tm_iw columns are written.

7.1.5 Goodness of fit

For each fitted decay, FLIM Playground also reports the reduced chi-square (\(\chi^2_r\)) as a goodness-of-fit diagnostic:

\[\chi^2_r = \frac{1}{N - p}\sum_{n} \frac{\bigl(y_n - \hat{y}_n\bigr)^2}{\hat{y}_n}\]

where the sum runs over the time bins within the time gates that have a positive model value (\(\hat{y}_n > 0\)), \(y_n\) is the measured count, \(\hat{y}_n\) is the fitted value, \(N\) is the number of those bins, and \(p\) is the number of free parameters (amplitudes, lifetimes, and the offset, minus any fixed lifetimes). Values near 1 indicate a good fit.

7.2 Pixel pre-fit

Currently, FLIM Playground supports pixel pre-fit lifetime features from SPCImage. The pixel-level lifetime fitting features are expected to be stored in 2D arrays in spatial dimensions, with each row and column having the value of a lifetime feature outputted from SPCImage. SPCImage assigns 0 for pixels that are not fitted (e.g. thresholded out). To avoid them biasing the results, FLIM Playground uses np.ma.masked_array to create a masked array and disregards them when calculating the averages using np.ma.average.

Then it uses the ROI mask to calculate the cell-level lifetime features by averaging the pixel-level features within each ROI.

1.
Samimi, K. et al. Segmentation-guided photon pooling enables robust single cell analysis and fast fluorescence lifetime imaging microscopy. bioRxiv https://doi.org/10.1101/2025.09.30.679660 (2025) doi:10.1101/2025.09.30.679660.