Histograms & Labels
Native 1-D / 2-D histograms and per-photon label lookup, used as the fastest way to build images and decay curves from photon streams.
from photonscore import histogram, label
# 2-D image of a LINCam recording
img = histogram(x, 0, 4096, 512, y, 0, 4096, 512)
# Decay curve
dt_hist = histogram(dt, 0, 4096, 1024)
# Tag each photon with a label image
roi = label(label_image, x, 0, 4096, y, 0, 4096)
histogram
histogram.histogram(x, x_min, x_max, x_bins, y=None, y_min=None, y_max=None, y_bins=None)
Compute a 1-D or 2-D histogram of x (and optionally y).
When y is omitted the function returns a 1-D histogram of x with
x_bins equal-width bins in the half-open range
[x_min, x_max). When y is supplied, a 2-D histogram is returned
instead; if any of y_min, y_max, y_bins are omitted they
default to the matching x_* value so the result is square.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Sample values along the first axis. |
required |
x_min
|
float
|
Lower edge of the first-axis range. |
required |
x_max
|
float
|
Upper edge of the first-axis range (exclusive). |
required |
x_bins
|
int
|
Number of bins along the first axis. |
required |
y
|
ndarray | None
|
Sample values along the second axis. Pass |
None
|
y_min
|
float | None
|
Lower edge for the second axis. Defaults to |
None
|
y_max
|
float | None
|
Upper edge for the second axis. Defaults to |
None
|
y_bins
|
int | None
|
Number of second-axis bins. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
NumPy array of counts — shape |
ndarray
|
|
Source code in histogram.py
13 14 15 16 17 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 46 47 48 49 50 51 52 53 54 | |
label
labels.label(labels, x, x_min, x_max, y, y_min=None, y_max=None)
Look up the label at each (x, y) coordinate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
ndarray
|
2-D integer NumPy array — the label image. |
required |
x
|
ndarray
|
Per-photon x-coordinates. |
required |
x_min
|
float
|
Lower bound of the x-axis (maps to label column 0). |
required |
x_max
|
float
|
Upper bound of the x-axis (maps to the last column). |
required |
y
|
ndarray
|
Per-photon y-coordinates. |
required |
y_min
|
float | None
|
Lower bound of the y-axis. Defaults to |
None
|
y_max
|
float | None
|
Upper bound of the y-axis. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
1-D NumPy array of label values, one per photon. |
Source code in labels.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |