Optical cross-talk¶
Cross-talk is measured on the Kelpie v2 sensor by reading, for each 2×2 macropixel, two on-chip counters over the same set of frames:
coinc— frames in which both micropixels of the pair fired (logical AND)OR— frames in which at least one of the pair fired (logical union)
The per-macropixel cross-talk metric is the ratio of the accumulated counts:
which is dimensionless (a probability), so the frame time cancels and no exposure time is needed.
This slightly overestimates true optical cross-talk
The raw ratio includes accidental coincidences from independent dark counts landing in the same frame.
Macropixels where OR = 0 are undefined and come back as NaN. Everything in
core.plots is NaN-aware, so those pixels are dropped from
the statistics rather than poisoning them.
SPAD geometry — the indices run clockwise¶
This is the single most important fact in this module, and it is not the convention you would guess. Inside one 2×2 macropixel the four SPADs are indexed clockwise, not row-major:
So relative to S0:
| pairing | neighbour | direction | cell offset |
|---|---|---|---|
S0S1 |
right | horizontal | (0, 1) |
S0S3 |
below | vertical | (1, 0) |
S0S2 |
corner | diagonal | (1, 1) |
Note that S0S2 is the diagonal pairing and S0S3 the vertical one — the
reverse of what a row-major reading gives. Vertical and diagonal cross-talk are
physically different magnitudes (diagonal SPADs sit further apart), so swapping
them silently mislabels two real measurements.
The layout is encoded once, in
core.reduce.SPAD_LAYOUT (see core.reduce), which both the
(64, 64) quadrant assembly of DCR and hitmap and the
cross-talk directions read. tests/test_spad_geometry.py pins it, and
crosstalk_analysis._DIRECTIONS, against an independent spelling of it, so the
encodings cannot drift apart.
Data layout¶
One folder per micropixel pairing, e.g. S0S1, S0S2, S0S3. Each folder holds
many repeated .bin acquisitions per counter, named like
CT_coincS0S1<n>.bin / CT_ORS0S1<n>.bin; the counts are summed across every
acquisition for statistics.
The coinc and OR files are told apart by their counter token, case sensitively:
coinc files carry coinc, OR files OR. The pairing (S0S1...) is read from
the file names.
The 01 preliminary batches use a CT01_ / CT02_ prefix and are excluded by
the default tag="CT_", so the two acquisitions are never silently
mixed.
Processing and plotting¶
Pointed at a folder holding one pairing's coinc/OR files,
process_crosstalk
saves its (32, 32) macropixel map as processed/<name>_ct_crosstalk.npy — the
tag, not the pair, is in the file name; the pair is in the sidecar.
plot_crosstalk loads it
and saves a heatmap and a sorted distribution, in percent, to
results/crosstalk/.
from dapkel.functions import crosstalk_analysis as ct
ct.process_crosstalk("path/to/S0S1", nframes=1000)
ct.plot_crosstalk("path/to/S0S1")
# a parent of S0S1 / S0S3 / S0S2: each pairing, then the combined map
ct.process_crosstalk("path/to/crosstalk", nframes=1000)
ct.plot_crosstalk("path/to/crosstalk")
The combined 64×64 map¶
Pointed at a parent folder holding one sub-folder per pairing instead,
process_crosstalk processes and saves each sub-folder the same way, then lays
the (32, 32) directional maps onto a single (64, 64) micropixel grid, saved in
the parent. Sub-folders that are not S0-based pairings are skipped, and a
missing direction is reported. Within each 2×2 block the neighbour cells carry S0's
cross-talk in that direction, and the S0 cell carries the mean of the available
directions:
plot_crosstalk on the parent draws that (64, 64) map and a bar chart of the
median cross-talk per direction (..._direction_summary.png).
API¶
crosstalk_analysis ¶
Optical cross-talk (CT) maps from the on-chip coinc/OR counters.
process_crosstalk raw '.bin' -> processed/<name>_<tag>_crosstalk.npy
plot_crosstalk that array -> results/crosstalk/ figures
CT = sum(coinc) / sum(OR) per macropixel - dimensionless, so the frame time
cancels and no exposure time is needed. NaN where OR = 0.
A folder holds one micropixel pairing (S0S1...), read from the file names.
Point 'process_crosstalk' at a parent folder of pairings instead and it also
combines them: S0's cross-talk towards its horizontal, vertical and diagonal
neighbour laid onto one (64, 64) micropixel map.
NOTE: the SPAD indices run CLOCKWISE inside a 2x2 macropixel ('core.reduce.SPAD_LAYOUT')::
S0 (0,0) S1 (0,1)
S3 (1,0) S2 (1,1)
so S0S1 is horizontal, S0S3 VERTICAL and S0S2 DIAGONAL - the reverse
of a row-major reading. See docs/guide/crosstalk.md.
process_crosstalk ¶
Unpack the coinc/OR files, compute the cross-talk map and save it.
On a folder holding one pairing's '.bin' files this saves its (32, 32) macropixel map. On a parent folder - one sub-folder per pairing, e.g. S0S1 / S0S3 / S0S2 - it processes and saves each sub-folder the same way, then saves the combined (64, 64) map in the parent: in every 2x2 block the neighbour cells hold S0's cross-talk in that direction and the S0 cell the mean over the directions measured.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Folder with the coinc/OR '.bin' files, or a parent of such folders. |
required |
nframes
|
int
|
Frames the acquisition recorded per '.bin' file (one value for every pairing). |
required |
tag
|
str
|
Filename prefix selecting the measurement batch. The default is
|
'CT_'
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the saved '.npy' (the combined map for a parent folder). |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
Raised when neither |
Source code in src/dapkel/functions/crosstalk_analysis.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
plot_crosstalk ¶
Load a saved cross-talk map and save its figures.
A single pairing gets a heatmap and a sorted distribution; a combined parent-folder map gets the (64, 64) directional heatmap and a bar chart of the median cross-talk per direction. All values are drawn in percent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Folder that 'process_crosstalk' was run on. |
required |
tag
|
str
|
The prefix it was run with. The default is |
'CT_'
|
cmap
|
str | None
|
Matplotlib colormap name for the heatmap. The default is None - the active style's. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The cross-talk map (dimensionless ratio, NaN where undefined). |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
Raised when no saved map exists for |
Source code in src/dapkel/functions/crosstalk_analysis.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |