Probe-alignment pipeline

Making the IBL ephys-alignment workflow correct at AIND

After recording, each probe’s electrophysiological landmarks are aligned to its traced track in atlas space, using AIND’s branch of the International Brain Laboratory’s alignment GUI. Every analysis that assigns a unit to a brain region inherits that alignment. Several errors in the preprocessing and the GUI produced plots that looked plausible and were wrong.

Errors that could misplace recording sites

  • Registration. A resample target was given in µm against image spacing in mm, a 1000× error. The canonical rotation was transposed, because the ANTs affine maps template to light-sheet space rather than the reverse.
  • Multi-shank geometry. The preprocessing and the GUI each derived channel-to-shank-to-depth geometry, by different rules, and disagreed on four-shank probes. Geometry is now derived once, stored with the data, and read by channel-table row.
  • Depth scale. One affine spanned recording blocks with different contact densities, so on one probe the main block was drawn over 0–4,320 µm instead of its true 0–2,865 µm: up to 1.4 mm of depth error on the plot used for alignment. Each block now gets its own affine.
  • Channel tables. A deduplication key that changed type doubled a 384-channel probe’s correlation matrix to 768 × 768, contacts sharing a depth sorted arbitrarily, and RMS values landed on the wrong channels past the main block.

The alignment GUI

I’ve written over 300 commits on AIND’s branch of the GUI. I ported it to PyQt6 and added multi-session and multi-shank support, caching, and surface and interference overlays. Session, probe and shank are now chosen from dropdowns, edits persist while moving between probes, and one save writes every alignment for a mouse into a single package, with autosave and checkpoint recovery behind it.

The preprocessing pipeline

I rebuilt the preprocessing that feeds the GUI as one Code Ocean capsule run in four stages: discover, histology, ephys (one per stream, in parallel) and pack. A trigger finds a session’s raw, sorted and light-sheet assets itself and registers the output. A mouse-level datapackage.json, published as a JSON Schema and validated by both the pipeline and the GUI, is the contract between them.

  • On a 13-stream session, the histology stage dropped from 65 to 10 min (6.3×) and the full chain from 75 to 26 min (2.8×).
  • Each ephys worker reads about 30 GB instead of staging 1.1 TB, so its first log line appears after seconds rather than 41 minutes.

The histology stage registers each brain to the CCF through my iDISCO template.