Every optical module in a Flow2 headset produces a stream of photon-timing histograms, many per second on every channel. I built the pipeline that turns them into numbers an engineer can act on: GPU-vectorized metrics corrected against each source's own reference pulse, spec checks that match the factory station exactly, PDF failure reports, and statistical process control across every burn-in run.
Select a stage to see what happens there.
Time-domain fNIRS sends picosecond laser pulses into the head and times each returning photon. Photons that wander deeper take longer to come back, so a detector's arrival-time histogram (the distribution of time of flight, or DTOF) carries both how much light the tissue absorbed and how far it scattered.
Each module has three sources and six detectors on a 13.5 mm circle. The pipeline reads nine source–detector pairs per module, three at each of three separations. The detectors' on-chip timers sort arrivals into 128 bins of 52.5 ps, a 6.7 ns window, and the system records a fresh histogram for every pair, at every wavelength, many times a second.
A second, very short optical path inside the module carries a sample of each laser pulse straight to a detector. That histogram is the instrument response function (IRF): the shape of the pulse plus every delay and blur the electronics add. Every timing metric on this page is measured against it, so drift in the laser or the electronics cancels out.
One session, one tensor. The IRF arrives as a matching tensor indexed by source.
A long recording holds tens of thousands of frames for every channel. Looping over them in Python was the bottleneck, so the core metrics run as array operations in CuPy: each channel's whole time series goes to the GPU as one frames × bins block, and every frame is processed at once. The pipeline caps itself at 20 GB of the card's 24 GB so the workstation's display never starves.
These curves come from a toy model: a pulse shape like the one the pipeline fits, blurred by textbook diffusion through tissue with made-up optical properties, plus Poisson noise and a flat background. The metrics underneath are computed live in your browser with the same steps the pipeline uses.
Drift between the measured curve and its IRF is found by cross-correlating the two. The peak of a cross-correlation only lands on whole bins, so a bare argmax reports timing in 52.5 ps steps. The pipeline smooths the correlation with a Gaussian low-pass in the frequency domain, keeps only the top 10 % of the peak (the "snowcap"), and takes that cap's centre of mass. The estimate then moves continuously.
Here the demo steps the shift from 0 to 105 ps, two bins, and runs both estimators at each step. The argmax stays on a staircase. The snowcap centroid follows the diagonal; at low photon counts, noise scatters it around the line, but it never locks onto a step.
Background first. Each histogram sits on a floor of dark counts and stray light. The pipeline takes the mean of the three lowest bins as that floor, subtracts it, and clips at zero. It also drops the last eight bins, where the timer's tail is noisy, before any moment is taken. Without both steps the long tail drags the mean time later and inflates the width.
Moments against the IRF. The mean time of flight is the measured curve's first moment minus the IRF's, and the tissue's added width is the difference of their variances. If the laser pulse warms up and stretches, both curves stretch together and the difference stays put.
A signed width. The width keeps its sign: the square root of the absolute variance difference, carrying the sign of the difference. A channel narrower than its own IRF is physically wrong for light that went through tissue. It usually means light leaked straight across the module, and the negative value flags it.
Every module runs a 30-minute burn-in on a station that fires its lasers and records 60 sessions. The station gives a pass or a fail. My job was to explain the fails, and to confirm the passes weren't hiding anything: reproduce the station's verdict offline, see why a module failed, and spot trends across runs before they turned into fails.
The test plan already stores its session IDs, so one read-only query fetches the list. The downloader skips anything already on disk and writes each session in the same tensor layout the station's own code reads.
Anything that computes a metric comes from the test-system package that runs on the station; the notebook only draws. At start-up it copies every spec threshold from the package and prints any it had to correct. It caught a fit-quality limit that had drifted from 0.5 to 0.7 in an old notebook copy, so the notebook had been failing fits the station passed.
A single noisy frame shouldn't fail a module, so the specs are percentages: for example, at least 90 % of a channel's width measurements must fall under the limit. Stability and degradation specs need at least 30 time points or they skip, and the analysis says so.
The station's own evaluator uploads results and can open a quality alert. The analysis path deliberately routes around it, so re-analysing an old run can never write a duplicate verdict into the factory's records.
Colleagues asked for a report rather than a notebook. One call writes a vector PDF: a cover page with the station's stored verdict next to the offline reproduction, so any disagreement shows at a glance, then one page per failing channel with its metrics, histogram overlay and temperature.
Modules come back for re-runs, so a review pass joins every test plan by serial number. The first review covered 110 modules from 10 test plans. It found 7 duplicates, 5 modules whose verdict flipped between runs and 2 that failed every time, so each of those got a closer look.
October 2025's burn-in runs, all through the same pipeline. Each run loads twelve modules into the station's twelve slots. Every cell below is one module in one run, shaded by the share of its measurements that failed any spec. Most of the grid sits in the two darkest shades. The few bright cells are the ones worth an engineer's time.
Select a cell to see that module's control chart. Tap or use arrow keys and Enter. Run labels are dates where the record has one.
Each point is the mean of one session's measurements across the module's three monitored channels. The baseline is sessions 11–40, and σ is the spread of session means inside that window. Values are in σ from the baseline; absolute values are not shown.
The textbook individuals chart estimates σ from the average jump between consecutive points. These session means drift slowly and smoothly, so consecutive jumps are tiny, and those limits came out so tight that more than a third of all points flagged. Basing σ on the spread of the steady-state window instead keeps the chart honest. Inside that window about 1 % of points cross the limits, and the flags pile up exactly where the physics says they should: warm-up and the end of the run.
Put all 166 module-runs on one axis and a common shape appears. Light output climbs for the first ten or so sessions while the lasers and detectors come up to temperature, holds flat to within a fraction of a percent through the middle of the run, then shifts again over the last dozen sessions.
That shape is why the control-chart baseline starts at session 11, and why a fixed "first five sessions" reference was dropped: it put a warm-up ramp into every module's normal state.
Before burn-in went into production, earlier Generation 2 module sets ran for days with an automated health check every 5 to 10 minutes. It logged the ASIC supply readings and any error the modules raised. The longest run logged 1,634 checks across almost 12 days without a single error.
Light output is total counts as % change from each module's own median over sessions 21–40. Mean time of flight is in σ, as in the control chart.
The metrics didn't start in a factory. They grew out of the standard phantom protocols the time-domain optics community uses to compare instruments, run by hand, one notebook per test.
BIP (basic instrument performance): responsivity, differential non-linearity of the timing bins, IRF shape and detector afterpulsing. MEDPHOT phantom matrices for absorption and scattering accuracy, and nEUROPt for depth sensitivity. Plus heat-up and cool-down studies of how the timing-bin non-linearity changes with temperature.
The BIP suite re-run on the Flow2 module.
Multi-day runs on sets of up to eleven modules, with automated health checks. This is where the warm-up and drift behaviour was first mapped.
Fourteen burn-in runs through one pipeline. GPU metrics, SPC across runs, and the cross-run review of re-tested modules.
The analysis rebuilt on the factory test-system package: thresholds synced at run time, offline reproduction of the station's verdict, and one-call PDF reports.