FLIM Analysis
Fluorescence-lifetime-imaging utilities: file summaries, per-pixel sorting into decay histograms, instrument-response and decay-model generators, and an intensity-weighted-lifetime colourisation helper.
import photonscore.flim as flim
# Quick file summary
info = flim.info("measurement.photons")
print(info)
# Sort into a 256×256 image with per-pixel decay histograms
result = flim.sort(x, 0, 4096, 256, y, dt)
intensity = result.intensity()
tau = result.mean()
Sort
flim.sort.sort(x, x_min, x_max, x_bins, y, *args)
Sort photons into a 2-D grid of decay histograms.
Two calling conventions are supported:
sort(x, x_min, x_max, x_bins, y, dt)— uses the same range and bin count for the y-axis as for the x-axis.sort(x, x_min, x_max, x_bins, y, y_min, y_max, y_bins, dt)— explicit y-axis range and bin count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Per-photon x-coordinates. |
required |
x_min
|
float
|
Lower bound of the x-axis. |
required |
x_max
|
float
|
Upper bound of the x-axis. |
required |
x_bins
|
int
|
Number of x-axis bins. |
required |
y
|
ndarray
|
Per-photon y-coordinates. |
required |
*args
|
object
|
|
()
|
Returns:
| Type | Description |
|---|---|
SortResult
|
class: |
Source code in flim/sort.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
flim.sort.SortResult
Per-pixel decay histograms returned by :func:sort.
Attributes:
| Name | Type | Description |
|---|---|---|
counts |
3-D NumPy array of shape |
|
dt |
Bin edges of the delta-t axis (NumPy 1-D array). |
Source code in flim/sort.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
intensity(dt_range=None)
Per-pixel photon count within dt_range.
Source code in flim/sort.py
43 44 45 | |
mean(dt_range=None)
Per-pixel mean arrival time within dt_range (default: full range).
Source code in flim/sort.py
35 36 37 | |
median(dt_range=None)
Per-pixel median arrival time within dt_range.
Source code in flim/sort.py
39 40 41 | |
Convolution
flim.convolve.convolve(irf, irf_shift, tau, tau_ref=None, channels=None)
Convolve irf with one or more exponential decays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
irf
|
ndarray
|
Instrument-response function as a 1-D NumPy array. |
required |
irf_shift
|
float
|
Sub-channel shift applied to the IRF before convolution. |
required |
tau
|
float | ndarray
|
Exponential decay constant(s). Scalar or sequence — when a sequence is passed, the result is one decay per element. |
required |
tau_ref
|
float | None
|
Optional reference / IRF lifetime to deconvolve from
|
None
|
channels
|
int | None
|
Length of the output. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
NumPy array of the convolved decay(s). |
Source code in flim/convolve.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
Synthetic models
flim.gaussian_irf.gaussian_irf(mu, fwhm, channels=1000)
Generate a unit-area Gaussian IRF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
float
|
Centre of the Gaussian, in channels. |
required |
fwhm
|
float
|
Full-width at half-maximum, in channels. |
required |
channels
|
int
|
Length of the output array. |
1000
|
Returns:
| Type | Description |
|---|---|
ndarray
|
NumPy array of length |
Source code in flim/gaussian_irf.py
8 9 10 11 12 13 14 15 16 17 18 19 | |
flim.gaussian_decay.gaussian_decay(mu, fwhm, tau, channels=1000)
Generate the decay produced by convolving a Gaussian IRF with a single exponential.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mu
|
float
|
Centre of the Gaussian instrument response, in channels. |
required |
fwhm
|
float
|
Full-width at half-maximum of the IRF, in channels. |
required |
tau
|
float
|
Exponential decay constant, in channels. |
required |
channels
|
int
|
Length of the output array. |
1000
|
Returns:
| Type | Description |
|---|---|
ndarray
|
NumPy array of length |
Source code in flim/gaussian_decay.py
7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Colourisation
flim.iwtau.iwtau(n, tau, pal, n_range=None, tau_range=None)
Render an intensity-weighted lifetime RGB image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
ndarray
|
Count image (2-D NumPy array). |
required |
tau
|
ndarray
|
Lifetime image, same shape as |
required |
pal
|
ndarray
|
Palette of shape |
required |
n_range
|
list[float] | None
|
Clip range for |
None
|
tau_range
|
list[float] | None
|
Clip range for |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
RGB image of shape |
Source code in flim/iwtau.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
flim.iwtau.iwtau_n_range(n)
Suggest an intensity range from a count image.
Lower bound is 0, upper bound is 0.9 * max(n).
Source code in flim/iwtau.py
25 26 27 28 29 30 | |
flim.iwtau.iwtau_tau_range(tau)
Suggest a reasonable lifetime range for iwtau from a tau image.
Returns the 10th- and 90th-percentile of strictly positive entries
in tau — these values usually correspond to the bulk of the
lifetime distribution and produce a stable colour mapping.
Source code in flim/iwtau.py
11 12 13 14 15 16 17 18 19 20 21 22 | |
File summary
flim.info.info(path)
Open path and return an :class:Info summary.
Reads the photon coordinate streams to find the total count and the millisecond marker stream to derive the duration.
Source code in flim/info.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
flim.info.Info
Lightweight description of a Photonscore data file.
Attributes:
| Name | Type | Description |
|---|---|---|
filename |
Path to the file. |
|
duration |
Acquisition duration in seconds. |
|
total_counts |
Total number of photons recorded. |
Source code in flim/info.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |