Isai Olvera
Work / Kernel, 2019–2026

From photon-timing histograms to a burn-in verdict

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.

RoleAnalysis pipeline, burn-in analysis and SPC, 2020–2026
Scale840 burn-in sessions · 568,020 measurements
Corpus~490 sessions · ~38 GB of tensors
ToolsPython · CuPy on an RTX 3090 · SciPy · pandas · Jupyter
1 · The measurement

A clock for every photon

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.

time · frames×128 bins · 52.5 ps×channels · pairs×2 wavelengths

One session, one tensor. The IRF arrives as a matching tensor indexed by source.

2 · The metrics

Computing histogram metrics on the GPU

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.

Illustrative · synthetic curves, not measured data

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.

Separation
Photons
Scale
Mean time of flight, IRF-corrected–
Width added by tissue (signed)–
Shift you set–
Shift recovered by cross-correlation–

Finding a shift smaller than a bin

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.

Sweep: set shift against recovered shift

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.

Why the corrections matter

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.

# condensed sketch: one channel, all frames at once (frames × bins) n, i = gpu(dtof[:, :120]), gpu(irf[:, :120]) # drop the noisy tail bins n -= sort(n)[:, :3].mean(axis=1); n = max(n, 0) # background: 3 lowest bins i -= sort(i)[:, :3].mean(axis=1); i = max(i, 0) m1 = moment1(n) - moment1(i) # mean time of flight, IRF-corrected dv = var(n) - var(i) width = sign(dv) * sqrt(abs(dv)) # negative = narrower than the IRF drift = snowcap_centroid(xcorr(n, i, lowpass=0.1)) # sub-bin timing drift
3 · Burn-in

From a test plan to a verdict anyone can read

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.

  1. Downloading sessions from the test plan

    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.

    ~3 s per sessionabout 0.8 MB each
  2. One source of truth for metrics

    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.

    Thresholds synced at run timenever hand-edited
  3. Why the specs use percentages

    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.

    ≥ 90 % of measurementsper channel and wavelength
  4. A read-only analysis path

    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.

    Zero writesto the system of record
  5. A report people actually open

    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.

    0.11 MBagainst 173 MB for the old slide export
  6. Reviewing modules across re-runs

    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.

    110 modules10 test plans, one table
4 · Statistical process control

Failure share for every module in every run

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.

14burn-in runs
840sessions
568,020measurements
97.4 %pass every spec

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.

Metric

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.

Choosing the limits

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.

5 · Stability

The common shape of a burn-in 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.

Long runs

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.

~3,900health checks, Feb–Jun 2025
1,634in the longest run
0errors logged

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.

6 · Where it started

From phantom protocols to a factory pipeline

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.

  1. 2020–2021

    Generation 1 (Flow 50): the standard protocols

    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.

  2. 2023

    Generation 2 (Flow2): repeating the standard protocols

    The BIP suite re-run on the Flow2 module.

  3. Feb–Jun 2025

    Long-run stability

    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.

  4. Oct 2025

    Burn-in at volume

    Fourteen burn-in runs through one pipeline. GPU metrics, SPC across runs, and the cross-run review of re-tested modules.

  5. 2026

    Rebuilt on the factory test package

    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.