Exercise: frequency domain and phasors

Goal

By the end of this exercise you should be able to:

  • compute the phase, modulation, phase lifetime and modulation lifetime of a decay at a given frequency,
  • compute and place phasors: single lifetimes on the semicircle, mixtures on chords at their photon fractions,
  • convert photon fractions read from the plot into molecule fractions,
  • calibrate measured phasors with a reference,
  • recognise background, noise and coarse binning on a phasor plot,
  • (math) derive the semicircle, the linearity of phasors and the calibration rule, and prove \tau_\phi < \tau_m for mixtures.

Background

Idea What it means
ω 2\pi f; 80 MHz → 0.503 rad/ns
Phase, modulation one exponential: \tan\phi = \omega\tau, m = 1/\sqrt{1 + \omega^2\tau^2}
Phase / modulation lifetimes \tau_\phi = \tan\phi/\omega = s/(g\omega), \tau_m = \sqrt{1/m^2 - 1}/\omega; equal for one exponential, \tau_\phi < \tau_m for mixtures
Phasor (g, s) = (m\cos\phi, m\sin\phi) = \sum_j y_j(\cos\omega t_j, \sin\omega t_j)/\sum_j y_j
Semicircle (g - \tfrac12)^2 + s^2 = \tfrac14; g = 1/(1 + \omega^2\tau^2), s = \omega\tau g
Mixtures P = \sum_k f_kP_k, photon fractions f_k = \alpha_k\tau_k/\sum_j\alpha_j\tau_j
Calibration P_\text{true} = P_\text{meas}\,P_\text{ref,true}/P_\text{ref,meas}: subtract the phase error, divide by the modulation error

By hand

B1. At 80 MHz, τ = 2 ns: compute ωτ, φ, m and the phasor (g, s).

B2. Two pixels at 80 MHz have phasors (0.8, 0.4) and (0.6, 0.3). (a) Which one lies on the semicircle? (b) Compute \tau_\phi for both, and \tau_m for the second. What do you conclude about the second pixel?

B3. A mixture. At 80 MHz, free NADH (0.4 ns) and protein-bound NADH (2.5 ns). (a) Compute both phasors. (b) A pixel gets half its photons from each. Where is its phasor? Is it inside the semicircle? (c) Compute its \tau_\phi and \tau_m. (d) What fraction of the molecules is bound in this pixel (equal brightness per unit lifetime)?

B4. Lever rule. Two species of 0.6 ns and 3.5 ns have phasors (0.917, 0.276) and (0.244, 0.430) at 80 MHz. A pixel lies 30 % of the way from the 0.6 ns point to the 3.5 ns point. (a) What are its photon fractions and its phasor? (b) What are its molecule (amplitude) fractions?

B5. Background. A pure 2.5 ns dye (phasor (0.388, 0.487) at 80 MHz) in a pixel where 20 % of the photons are flat background. (a) Where does the pixel’s phasor lie? (b) Compute \tau_\phi and \tau_m. Which one is fooled by the background?

B6. Calibration. At 80 MHz, a 4.0 ns reference should give φ = 63.6° and m = 0.445, but the instrument measures φ = 70° and m = 0.40. A sample measures φ = 50°, m = 0.60. (a) Correct the sample’s phase and modulation. (b) Compute \tau_\phi and \tau_m. One lifetime, or more?

B7. Coarse bins. A histogram has only 4 bins over the period, with counts (8, 4, 2, 1); bin centres sit at 45°, 135°, 225° and 315° of the period. (a) Compute its phasor. (b) These counts are exactly the bins of a periodic exponential with τ = Δ/ln 2, where Δ = T/4. At T = 12.5 ns, what is τ, and where should its phasor be? (c) Is the 4-bin phasor on the semicircle? What does this mean in practice?

B1. ωτ = 1.005; φ = arctan 1.005 = 45.2°; m = 1/√(1 + 1.011) = 0.705; (g, s) = (0.497, 0.500).

B2. (a) (0.8, 0.4): 0.3^2 + 0.4^2 = 0.25, on the semicircle. (0.6, 0.3): 0.1^2 + 0.3^2 = 0.10 < 0.25, inside. (b) First: \tau_\phi = 0.4/(0.8 \cdot 0.503) = 0.99 ns (and \tau_m the same). Second: \tau_\phi = 0.3/(0.6 \cdot 0.503) = 0.99 ns, but m = \sqrt{0.45} = 0.671 gives \tau_m = \sqrt{1/0.45 - 1}/0.503 = 2.20 ns. Same phase, different modulation: the second pixel is a mixture (or has background, B5).

B3. (a) 0.4 ns: ωτ = 0.201, (0.961, 0.193); 2.5 ns: ωτ = 1.257, (0.388, 0.487). (b) The midpoint (0.674, 0.340); (0.174)^2 + 0.340^2 = 0.146 < 0.25, inside (distance 0.38 from the centre). (c) \tau_\phi = 0.340/(0.674 \cdot 0.503) = 1.00 ns; m = 0.756, \tau_m = 1.73 ns. (d) Molecules ∝ photons/τ: bound 0.5/2.5 = 0.2, free 0.5/0.4 = 1.25; bound fraction 0.2/1.45 = 0.14. Half the photons, but only 14 % of the molecules.

B4. (a) Photon fractions 0.7 (0.6 ns) and 0.3 (3.5 ns). Phasor 0.7(0.917, 0.276) + 0.3(0.244, 0.430) = (0.715, 0.322). (b) \alpha \propto f/\tau: 0.7/0.6 = 1.167 and 0.3/3.5 = 0.086: α = (0.93, 0.07). 30 % of the photons come from only 7 % of the molecules.

B5. (a) Background has phasor (0, 0), so P = 0.8 \cdot (0.388, 0.487) = (0.310, 0.390): on the line to the origin, inside the semicircle. (b) \tau_\phi = 0.390/(0.310 \cdot 0.503) = 2.50 ns: unchanged, because shrinking towards the origin keeps the angle. m = 0.498, \tau_m = 3.46 ns: the modulation lifetime is fooled. A point inside the semicircle need not be a mixture of two lifetimes: background looks the same.

B6. (a) Phase error 70 − 63.6 = 6.4°, modulation factor 0.445/0.40 = 1.113. Corrected: φ = 50 − 6.4 = 43.6°, m = 0.60 × 1.113 = 0.668. (b) \tau_\phi = \tan 43.6°/0.503 = 1.89 ns; \tau_m = \sqrt{1/0.668^2 - 1}/0.503 = 2.22 ns. \tau_\phi < \tau_m: more than one lifetime (if the calibration and the photon count are good enough to trust a 0.3 ns difference).

B7. (a) Sum 15. g = (8\cos 45° + 4\cos 135° + 2\cos 225° + 1\cos 315°)/15 = 0.707(8 - 4 - 2 + 1)/15 = 0.141; s = 0.707(8 + 4 - 2 - 1)/15 = 0.424. (b) Δ = 3.125 ns, τ = 3.125/0.693 = 4.51 ns, ωτ = 2.27: the semicircle point is (0.163, 0.369). (c) (0.141 - 0.5)^2 + 0.424^2 = 0.309: radius 0.556, outside the semicircle, rotated by 5.4° and 11 % longer than the true phasor. With so few bins, the sum over bin centres is a poor approximation of the integral (the higher harmonics of the decay fold onto the first). In practice: always calibrate with a reference measured with the same bins and settings; then the error largely cancels (in the phasorplot demo exactly, for a single exponential).

Math questions

B8. (math) Derive the phasor of e^{-t/\tau} (infinite window) and show that it lies on the circle |P - \tfrac12| = \tfrac12. Which lifetimes give the points (1, 0), (½, ½) and (0, 0)?

B9. (math) Show that the phasor of a sum of decays is the photon-fraction-weighted sum of their phasors, and express the photon fractions through amplitudes and lifetimes.

B10. (math) Show that convolving the decay with an IRF h multiplies the phasor by P_h, and derive the calibration rule P_\text{true} = P_\text{meas}\,P_{\tau_r}/P_\text{ref,meas}.

B11. (math) (a) In polar coordinates (m, \phi) around the origin, the semicircle is m = \cos\phi. Use this to show \tau_\phi < \tau_m for every point strictly inside it, hence for every mixture. (b) Show that two different single exponentials never share a phasor, but two different bi-exponentials can: find a mixture of 0.5 ns and a second lifetime that has the same 80 MHz phasor as a 50/50 photon mixture of 1 and 3 ns.

B8. \int_0^\infty e^{-t/\tau}e^{i\omega t}dt = \frac{1}{1/\tau - i\omega} = \frac{\tau}{1 - i\omega\tau}; divided by \int e^{-t/\tau} = \tau: P = \frac{1}{1 - i\omega\tau} = \frac{1 + i\omega\tau}{1 + \omega^2\tau^2}. Then g^2 + s^2 = g (Quiz Q8), i.e. |P - \tfrac12| = \tfrac12, with s \ge 0. τ → 0 gives (1, 0); ωτ = 1 gives (½, ½) (τ = 1.99 ns at 80 MHz); τ → ∞ gives (0, 0).

B9. P = \frac{\int\sum_k I_k e^{i\omega t}}{\int\sum_k I_k} = \sum_k\frac{N_k}{N}\cdot\frac{\int I_k e^{i\omega t}}{N_k} = \sum_k f_kP_k with N_k = \int I_k. For I_k = \alpha_k e^{-t/\tau_k}: N_k = \alpha_k\tau_k, so f_k = \alpha_k\tau_k/\sum_j\alpha_j\tau_j.

B10. \int (h * I)(t)e^{i\omega t}dt = \iint h(u)I(t - u)e^{i\omega u}e^{i\omega(t - u)}du\,dt = \hat h\,\hat I (with \hat{\ } the integral against e^{i\omega t}); at ω = 0 the same gives \int h * I = \int h\int I. Dividing: P_{h*I} = P_hP_I. A reference of known lifetime gives P_\text{ref,meas} = P_hP_{\tau_r}, so P_h = P_\text{ref,meas}/P_{\tau_r} and P_\text{true} = P_\text{meas}/P_h = P_\text{meas}P_{\tau_r}/P_\text{ref,meas}.

B11. (a) On the circle, g^2 + s^2 = g means m^2 = m\cos\phi, i.e. m = \cos\phi. A point strictly inside, at angle φ, has m < \cos\phi. Then \omega^2\tau_m^2 = 1/m^2 - 1 > 1/\cos^2\phi - 1 = \tan^2\phi = \omega^2\tau_\phi^2. Mixtures of different lifetimes lie strictly inside (a chord of a circle lies inside it), so \tau_\phi < \tau_m. (b) On the semicircle τ is a one-to-one function of the angle (\tan\phi = \omega\tau): different lifetimes, different points. A point inside lies on infinitely many chords: through P_0 = \tfrac12(P_{1\,\text{ns}} + P_{3\,\text{ns}}) = (0.552, 0.431) and P_{0.5\,\text{ns}} = (0.941, 0.236), the line meets the semicircle again at (0.425, 0.494), τ = 2.31 ns. So 24.6 % of the photons from 0.5 ns and 75.4 % from 2.31 ns give the same first-harmonic phasor: one harmonic cannot tell these two mixtures apart (the second harmonic can).

Explore: excitation and emission waves

Two periods of the excitation (orange) and the emission (blue), both with mean 1; the decay; and the phasor point. Two lifetimes with a photon fraction, and the modulation frequency.

E1. Preset one lifetime (2.5 ns, 80 MHz). Read φ, m, \tau_\phi and \tau_m, and check them against the formulas. Then two lifetimes (4 ns and 0.5 ns, half the photons each): what happens to \tau_\phi and \tau_m?

E2. Preset frequency too low (10 MHz). Read φ and m, then drag τ₁ to about 1.3 ns. Why is this a bad frequency for nanosecond lifetimes? Preset frequency too high (200 MHz, 4 ns): what is the problem now?

E3. Which frequency gives ωτ = 1 for τ = 0.4 ns (free NADH)? For τ = 4 ns?

E1. φ = 51.5°, m = 0.623, \tau_\phi = \tau_m = 2.50 ns (\arctan 1.257 = 51.5°, 1/\sqrt{2.58} = 0.623). Two lifetimes: φ = 29.1°, m = 0.652, \tau_\phi = 1.11 ns, \tau_m = 2.31 ns. They disagree: the signature of a mixture.

E2. φ = 8.9°, m = 0.988 for 2.5 ns; at 1.26 ns, φ = 4.5°, m = 0.997. Over this whole range of lifetimes the emission is almost an exact copy of the excitation: tiny differences buried in any noise. At 200 MHz a 4 ns decay leaves m = 0.195: the wave is flattened to a fifth, and the small oscillation is hard to measure precisely.

E3. f = 1/(2πτ): 398 MHz for 0.4 ns, 40 MHz for 4 ns. 80 MHz is a compromise for the common 1 to 4 ns range.

Explore: the phasor plot

The phasor plane at a chosen frequency, up to three species on the semicircle (drag them), and a mixture point (drag it along the chord or inside the triangle). The middle shows the expected histogram (IRF σ adjustable at 0.4 ns delay; bins adjustable) and its components. Pixels adds 150 simulated pixels with N photons each; calibrate uses a 4 ns reference measured with the same IRF and bins.

E4. Preset single lifetimes live on the semicircle. Drag the species along the semicircle and watch the decay. Where do short and long lifetimes sit? Change the frequency: what happens to the tick marks, and to the position of a 2.5 ns species?

E5. Preset two species: a straight line. Drag the mixture point from one end to the other. Read the photon and amplitude fractions halfway, and \tau_\phi, \tau_m. Then photon fraction is not amplitude fraction: where does a 50/50 mixture of molecules sit?

E6. Preset three species: a triangle. Drag the mixture point to a corner, an edge and the centre, and read the fractions. Can a fourth species be found from one phasor? Tick harmonic 2 with two species: do the points stay on a semicircle, and does the mixture stay on the chord?

E7. Preset uncalibrated IRF. What does the dashed red curve show? How large are the rotation and the shrink? Tick calibrate. Then preset coarse time bins (4 bins): where does the 2.5 ns species land, and does calibration repair it?

E8. Preset 100 photons: a cloud. Read the spread and compare it with ½/√N. Change the photons per pixel to about 1 700 and to 100 000. Does the spread follow ½/√N?

E4. Short lifetimes near (1, 0), long ones near the origin; ωτ = 1 at the top. At a higher frequency all ticks move towards the origin (each τ has a larger ωτ): a 2.5 ns species moves left; at a lower frequency it moves towards (1, 0). Choose f so that the interesting lifetimes are spread over the semicircle.

E5. Halfway (half the photons each) of 0.5 and 3 ns: the point (0.623, 0.348), amplitude fractions 0.86 and 0.14, \tau_\phi = 1.11 ns, \tau_m = 1.95 ns. With 0.4 and 4 ns and equal molecules (α = 0.50 each), the photon fractions are 0.09 and 0.91: the point sits close to the 4 ns end, at (0.268, 0.380).

E6. At a corner one fraction is 1; on an edge the opposite corner’s fraction is 0; inside, three positive fractions summing to 1 (preset: 0.3, 0.4, 0.3 of the photons, amplitude fractions 0.79, 0.17, 0.04). A fourth species cannot be found from one phasor: two numbers (g, s) plus “fractions sum to 1” give three equations, enough for three fractions, not four. At harmonic 2 single exponentials still lie on the semicircle (at 2ωτ), and mixtures still on chords: the point moves to (0.449, 0.350); a second harmonic gives two more equations.

E7. Where single exponentials land without calibration: the semicircle turned anticlockwise by 11.5° and shrunk by 0.956 (IRF σ = 0.6 ns, delay 0.4 ns). The mixture’s measured point (0.517, 0.445) gives wrong lifetimes (\tau_\phi = 1.71 instead of 1.11 ns). Calibrated: back to (0.623, 0.348). With 4 bins the 2.5 ns decay lands at (0.267, 0.581), outside the semicircle; calibration with a 4 ns reference on the same 4 bins puts it back at (0.388, 0.487), the true point.

E8. At 100 photons the spread is 0.052, close to ½/√100 = 0.050. At about 1 700 photons, 0.012 (½/√N = 0.012); at 100 000, 0.001 (½/√N = 0.0016). It follows 1/\sqrt N, with a constant that depends on where the point is (here roughly ½ or a little less): the variance of \cos\omega t and \sin\omega t over the decay, divided by N.

Explore: a cell on the phasor plot

The cell’s phasor histogram (calibrated), the intensity and the lifetime \tau_\phi images. The magenta cursor’s pixels light up magenta in the intensity image (drag it, change its radius); painting on an image shows those pixels in orange on the plot.

E9. Preset a cloud on a line (two species, 0.6 and 3.5 ns, in varying proportions). Where does the line through the cloud meet the semicircle? Drag the cursor along the cloud: how does the selected region move through the cell?

E10. Preset cursor ↔︎ image (two dyes, 1.0 ns and 3.0 ns, same brightness). Which pixels does the cursor at (0.80, 0.40) select? Paint over the nucleus: where do its pixels land on the plot?

E11. Preset median-filtered phasors (60 photons in bright pixels). Untick and tick median g, s: how many pixels fall in the cursor in each case, and what happens to the line’s lifetimes? What does the filter cost?

E12. Preset background pulls to the origin. Describe the cloud. Tick line: which lifetimes does it give? Raise mask below to 100 photons and read the line again.

E9. At 0.60 and 3.55 ns (true 0.6 and 3.5): no fit, just a line through the cloud. Moving the cursor from the short end to the long end moves the selection from the left of the cell (and the nucleus) to its right side: the photon fraction of the long species follows the gradient across the cell.

E10. 870 pixels, the nucleus: the 1.0 ns dye at (0.80, 0.40). Painted nucleus pixels land in the same spot; cytoplasm pixels land near (0.22, 0.41) (3.0 ns). The cursor and the brush are two directions of the same link between image and plot.

E11. Without the filter, the cursor (radius 0.05 at (0.50, 0.40)) holds 744 pixels; with it, 1 374: the cloud is tighter, so more pixels fall near its centre. The line gives 0.62 and 3.65 ns without, 0.63 and 3.67 ns with the filter. The cost: g and s are averaged over 3 × 3 neighbours, so at compartment borders pixels mix, much like binning (but the intensity image stays sharp).

E12. The cloud is smeared from the chord towards the origin: dim pixels have relatively more background. The line through all of it gives 1.01 and 18.3 ns, nonsense. Masking pixels below 100 photons keeps only bright pixels (little background): 0.54 and 4.29 ns, closer. Better still: subtract the background or fit it (decay unit).

Code

Write the algorithms of this unit yourself, in Rust. Setup, and how to run and check your code: coding exercises: getting started. Your code goes in flim/src/phasor/exercise.rs. Times are in nanoseconds, ω in rad/ns (80 MHz: ω = 0.503).

C1. phasor(counts, period): the phasor of a histogram over one laser period T:

ω = 2π / T
for every bin j:   t_j = (j + ½) · T / n                # the centre of the bin
g = Σ_j y_j cos(ω t_j) / Σ_j y_j
s = Σ_j y_j sin(ω t_j) / Σ_j y_j

The checks: the four bins of B7, a finely binned 2.5 ns decay (on the semicircle, at the point of B3), and a mixture of 300 and 700 photons, whose phasor is the 0.3 : 0.7 mix of the two phasors.

C2. single_phasor(tau, omega): g = 1/(1 + \omega^2\tau^2), s = \omega\tau g; and phase_and_modulation_lifetimes(g, s, omega): \tau_\phi = s/(g\omega), \tau_m = \sqrt{1/m^2 - 1}/\omega with m^2 = g^2 + s^2. The checks are B1, B2, B3(a) and B5.

C3. calibrate(p, ref_measured, ref_tau, omega): with phasors as complex numbers P = g + is, return P \cdot P_{\text{ref,true}} / P_{\text{ref,measured}}, where P_{\text{ref,true}} is single_phasor(ref_tau, omega). The check is B6.

C4. fraction_along(p, a, b): the lever rule, by projecting p onto the line from a to b:

f = ((p − a) · (b − a)) / |b − a|²          # 0 at a, 1 at b

The check is B4.

Then cargo run -p flim -- phasor and open the pictures in out/phasor/. The program simulates a 128 \times 128 FLIM image of nuclei holding two species, 0.6 and 3.5 ns, whose photon fraction rises from left to right, photon by photon through an IRF of width 0.3 ns at a delay of 0.6 ns (64 bins over 12.5 ns). It measures a 4 ns reference through the same IRF, computes every nucleus pixel’s phasor and calibrates it, and draws the phasor plots before and after calibration (the red dots are the two species). It finds the straight line through each cloud and where it meets the semicircle, and makes a map of the photon fraction of the 3.5 ns species by the lever rule.

C5. Compare phasor-uncalibrated.png with phasor-calibrated.png and read the printed reference. How is the uncalibrated cloud displaced, and why? What do the lines through the two clouds give?

C6. Read the phasor and the two lifetimes of the pixel with half its photons from each species. Which of the two lifetimes is closer to the intensity-weighted mean lifetime \bar\tau_f = \tfrac12(0.6 + 3.5)? Why are they different at all?

The model solution is flim/src/phasor/solution.rs in the download.

C5. The 4 ns reference is measured at φ = 80.8°, m = 0.440, instead of 63.6° and 0.445: the IRF’s delay turns every phasor by 17.2° (anticlockwise on the plot, towards larger phase), and its width shrinks it by a factor of only 0.989. So the uncalibrated cloud is turned towards the long-lifetime end and partly lies outside the semicircle; the straight line through it misses the semicircle altogether. After calibration the cloud lies inside, along the chord between the two red dots, and its line meets the semicircle at 0.61 and 3.53 ns (true 0.6 and 3.5), without any fit. The lever rule then gives each pixel’s photon fraction of the 3.5 ns species with an error of +0.002 ± 0.056: fraction-long.png is darker on the left and brighter on the right.

C6. The phasor is (0.579, 0.354): \tau_\phi = 1.22 ns and \tau_m = 2.15 ns. Neither is \bar\tau_f = 2.05 ns, but \tau_m is much closer. For a single exponential both would be equal; for a mixture the point lies inside the semicircle, so \tau_\phi < \tau_m (B11). Each is a different nonlinear average of the two lifetimes: the phase is pulled towards the short lifetime.

Where this leads

The last unit of the day uses all of this for one of the main applications of FLIM: FRET measured by lifetime, where the phasor plot separates the efficiency of the interaction from the fraction of molecules that interact, and label-free metabolic imaging of NADH. The same transform applied to spectra (a spectral phasor) is an alternative to the least squares of the spectral unmixing day.