sCMOS camera calibration¶
An sCMOS camera does not count photons directly. Each pixel has its own
offset, its own read noise and its own gain. pysrx.camera.calibrate
measures all three, pixel by pixel, from a dark stack and a few flat stacks,
with one batched least-squares fit on the GPU. Calibrate once per camera and
readout mode, then reuse the maps for every acquisition.
How an sCMOS camera reads out¶
During an exposure each pixel collects photoelectrons. Reading it out takes two steps: an amplifier turns the charge into a voltage, and an analogue-to-digital converter (ADC) turns the voltage into a number of counts.

- CCD. The charge is shifted, pixel by pixel, to a single amplifier and a single ADC. Every pixel goes through the same electronics, so the chip has one gain and one offset, but the serial readout is slow.
- sCMOS ("scientific CMOS"). Every pixel has its own amplifier and every column its own converters, all working in parallel, and the rows are read one after another (rolling shutter). This is what makes sCMOS fast and quiet, around 1 to 2 electrons of read noise at hundreds of frames per second.
- The cost. Millions of amplifiers and thousands of converters are never quite identical. Each pixel has its own offset, read noise and gain, columns show as stripes, and a few pixels are far noisier than the rest. These are the maps this page measures.
The standard: EMVA 1288¶
Cameras and image sensors are characterised by the EMVA 1288 standard of the European Machine Vision Association, which camera datasheets follow when they quote quantum efficiency, read noise in electrons, or full-well capacity. It models a pixel as a linear chain from photons to counts:
Here \(\mu_p\) is the mean number of photons on a pixel of area \(A\) under irradiance \(E\) for an exposure \(t_{\exp}\), \(\eta\) the quantum efficiency, \(K\) the system gain (counts per electron), \(\mu_d\) and \(\sigma_d\) the dark signal and dark (read) noise in electrons, and \(\sigma_q\) the quantisation noise of the ADC. The model goes all the way down to single photons: a camera whose read noise is well below one electron can resolve photon numbers.
The photon-transfer method of EMVA 1288 is the one used here. Subtracting the dark values gives \(\sigma_y^2 - \sigma_{y,\text{dark}}^2 = K\,(\mu_y - \mu_{y,\text{dark}})\): the same straight line as below, with \(K\) as its slope. The differences:
| EMVA 1288 | pysrx.camera.calibrate |
|---|---|
| \(K\), system gain | gain, \(g_p\), one per pixel |
| dark noise \(\sigma_d\) (electrons) and \(\sigma_q\) | read_var, \(\sigma_p^2\) in counts² (both together); read_noise_e in electrons |
| dark signal and offset | offset, \(o_p\) |
| DSNU, PRNU: the spread across pixels of the dark signal and of the response | kept as full maps, not summarised |
| quantum efficiency \(\eta\), from a calibrated light source | not measured: the flats are not calibrated, so photoelectrons are the end point |
Why calibrate¶
pySRX writes the microscope as a forward model and asks which sample best
explains the counts that were recorded. That question needs the noise model of
the camera. The solvers use a Poisson likelihood, and simulate.camera adds
Poisson photon noise and Gaussian read noise; both assume counts measured
above the offset and in known units. With raw counts, two things go wrong:
- The likelihood is wrong. An offset of 100 counts looks like 100 extra photons, and with a gain of 2 counts per electron the variance is twice what a Poisson model of the counts expects. The reconstruction then weighs bright and dim pixels wrongly.
- Split FRC is not valid. Binomial splitting divides photoelectrons into two independent halves. Applied to raw counts, the offset, the read noise and the fixed pattern go into both halves, and the FRC never reaches its threshold. See Measure and plot and the sensor card in Concepts.
camera.photon_transfer estimates one gain and one read-noise value from the
data itself, and camera.fixed_pattern estimates the offset pattern without
dark frames. Both are useful when nothing else is available. A calibration
measures the same quantities per pixel, independently of the sample.
The camera model¶
We follow Mandracchia et al. (2020). In frame \(k\), pixel \(p\) records
| Term | Meaning |
|---|---|
| \(n_k(p)\) | photoelectrons: Poisson, mean \(\lambda_p\) |
| \(g_p\) | gain, counts per photoelectron |
| \(o_p\) | offset (bias), counts |
| \(\sigma_p^2\) | read-noise variance, counts² |

The model, simulated. Top: one pixel over many exposures. The photoelectron count is Poisson (mean = variance = 12); the gain multiplies the mean by \(g\) and the variance by \(g^2\); read noise adds \(\sigma^2\) to the variance; the offset moves the mean but not the variance. Bottom: on an sCMOS chip each pixel (and each column) has its own amplifier and converter, so the offset, read variance and gain are maps, with column stripes, hot pixels and drifts across the chip. The calibration measures one photon-transfer line per pixel.
Dark current is negligible at exposures below about 1 s, so it is left out. The mean and the variance of a pixel under steady light are
so the light-induced variance is a straight line in the light-induced mean, with the gain as its slope:
This is the photon-transfer relation, written for every pixel separately. Once \(o_p\) and \(g_p\) are known, \((y - o_p) / g_p\) is in photoelectrons. Photons are photoelectrons divided by the quantum efficiency, which a calibration of this kind cannot separate from the gain.
Measuring¶
Record everything with the exposure time, readout rate, bit depth and cooling that you image with: the maps change with the readout mode.
- Dark stack. Close the shutter (or cap the camera) and record a few hundred frames. The per-pixel mean is the offset \(o_p\); the per-pixel variance is the read variance \(\sigma_p^2\).
- Flat stacks. Illuminate the sensor uniformly and steadily (no sample, a diffuser or a defocused lamp) and record a stack at each of 5 to 10 light levels, from just above dark to just below saturation. A few hundred frames per level is enough; flicker in the source adds variance and biases the gain upwards.
The variance of one pixel from \(N\) frames has a relative error of \(\sqrt{2/(N-1)}\): 10 % for 200 frames. The fit over several levels averages this down, to about 5 % per pixel with 7 levels of 200 frames.
The per-pixel fit¶
For each flat level \(l\), the light-induced mean and variance of every pixel are \(x_l = \bar y_l - o\) and \(v_l = s_l^2 - \sigma^2\). The gain is the slope of a weighted straight-line fit \(v_l = g\,x_l + c\) over the levels, where \(c\) should come out near zero. The weights are the inverse variance of a sample variance,
taken from the model rather than from the measured variance: a clipped level has a tiny measured variance and would otherwise dominate the fit. The fit starts from the per-pixel median of \(v_l / x_l\) and is refined twice. Each refinement is a closed-form weighted least-squares solution, computed for all pixels at once as sums over the levels, so a 2048 × 2048 camera is a few tensor operations on the GPU.
The filter. Near full well the response is no longer linear and the variance falls (clipped frames vary less). Two rules drop such points per pixel:
saturation: drop a level in a pixel if any of its frames reached this raw value;outlier: drop a point whose standardised residual \((v_l - g x_l - c)\sqrt{w_l}\) exceeds this value, before each refinement.
Calibration.level_kept reports the fraction of pixels that kept each level,
and chi2 the reduced chi-square of every pixel's fit (about 1 when the model
holds).
In code¶
import numpy as np
from pysrx.camera import calibrate
dark = np.load("dark.npy") # (N, Y, X): shutter closed
flats = [np.load(f"flat_{i}.npy") for i in range(8)] # (N, Y, X) each, rising light levels
cal = calibrate(dark, flats, saturation=65535, outlier=4.0) # CUDA if available, else CPU
print(f"{cal.seconds:.2f} s, gain {np.nanmedian(cal.gain):.2f} counts/e-, "
f"read noise {np.nanmedian(cal.read_noise_e):.2f} e- rms")
print("levels kept:", cal.level_kept)
np.savez("cam0_calibration.npz", offset=cal.offset, read_var=cal.read_var, gain=cal.gain)
electrons = cal.to_electrons(raw) # (..., Y, X) raw counts -> photoelectrons
The maps are NumPy arrays of the camera's shape. Frames are streamed to the
device frame_chunk at a time, so the stacks can be larger than GPU memory;
calibrate(..., device="cpu") runs the same code on the CPU. On 1024 × 1024
pixels with a dark stack and 6 flat levels of 100 frames each, the fit took
0.9 s on a Quadro RTX 4000 and 2.3 s on the CPU; most of that is moving the
frames.
The earlier implementation, the camera_calibration.ipynb notebook in
sCMOS-Denoise, fitted each
pixel with Gpufit, which needs its own CMake build. calibrate replaces it
with plain PyTorch.
Results¶

A lattice light-sheet sCMOS camera calibrated per pixel. Left: the offset \(o_p\) (counts), the read variance \(\sigma_p^2\) (counts²) and the gain \(g_p\). Right: the photon-transfer fit of every pixel, light-induced variance against light-induced mean, one line per pixel. Without the filter, the brightest level (near 2 500 counts) pulls the lines apart; with it, that level is dropped and the lines collapse onto one narrow band. Lattice light-sheet camera (CAM0), Oxford-Zeiss Centre of Excellence.
The maps are not flat. The offset carries the column pattern typical of sCMOS readout, and a band near the right edge has a higher read variance and a different gain: a single global value would misweight these regions.

A synthetic check with known maps: 128 × 192 pixels, a readout block
with lower gain (right), a dark stack and 7 flat levels of 200 frames, the brightest
level clipped at 3 000 counts. Top centre and right: three pixels, without and with
the filter (open circles: dropped as saturated). Bottom: recovered over true gain.
Unfiltered, the clipped level biases the gain low by 13 % on average; filtered
(saturation=3000, outlier=4), the median error is 0.2 % and the per-pixel rms
error 5 %, the limit set by 200 frames per level.
References¶
- B. Mandracchia, X. Hua, C. Guo, J. Son, T. Urner and S. Jia, "Fast and accurate sCMOS noise correction for fluorescence microscopy", Nature Communications 11, 94 (2020). doi:10.1038/s41467-019-13841-8
- European Machine Vision Association, EMVA Standard 1288: Standard for Characterization of Image Sensors and Cameras, Release 4.0 Linear (2021). emva.org/standards-technology/emva-1288