Write the two-colour channel registration, fiducial drift correction and same-molecule pairing step of a microscopy core's single-molecule pipeline from registration-bead stacks and localisation tables, under a time limit; it is run on further movies with known channel mapping and drift.
harbor run -t reactive-labs/smt-channel-registrationharbor download reactive-labs/smt-channel-registrationYou are Samir Haddad, staff scientist for image analysis in the Light Microscopy Core of the Tarnwell Institute for
Cell Biology. The core runs TIRF-2, the single-molecule TIRF set-up that the Castellanos lab (Halo-EGFR, and EGFR
with SNAP-Grb2 in two colours through the Duet-2 image splitter) and the Okonkwo lab (GPI-anchored Halo probe) use
for tracking. Today is Monday 14 December 2026. Ingrid Valtonen, head of the core, has asked you for the program
that takes each movie's localisation table to one coordinate system: the two Duet-2 channels registered onto each
other, stage drift measured from the fiducial beads, and the EGFR spots that carry a Grb2 spot in the same frame.
Her mail is in /app/inputs/mail/.
You have 60 minutes. Whatever is in /app/output when the time is up is graded, so keep a working program saved as
you go.
In /app/inputs:
localisations/: the core's localisation tables (SOP-031 section 8 format) of the eleven movies of the current
projects that contain beads or two colours, one CSV per movie, named like the movie.acquisitions/: the movies of the current projects, one folder each with the Halde Acquire record (.ini) and,
except for the newest, the raw frames (.raw), and manifest.csv.calibration/: registration-bead stacks of the two-colour days (registration/), PSF z-stacks, dark references,
EM gain checks and the camera's defect map.docs/: LMC-SOP-031 rev C, the grid calibration reports, the camera documents, the vendor's service report and
the TIRF-2 logbook export.legacy/: the scripts used so far, register_beads_v1.py among them, and their author's handover notes./app/output/smt_register.py, run as
python3 /app/output/smt_register.py <record.ini> <localisations.csv> <registration_dir> <out_dir>
<record.ini> is the movie's Halde Acquire record, <localisations.csv> its localisation table, and
<registration_dir> a folder holding the registration-bead stacks (one sub-folder per stack with its record and
raw frames, as in calibration/registration/) of the most recent two-colour day on or before the movie. The
program writes two files into <out_dir>:
registered.csv, with a header line row,x_nm,y_nm,partner and one line per row of the localisation table:
row the 0-based index of the table's data row; x_nm, y_nm the spot's position in the coordinates of
channel 1 of the same movie (the table's channel-1 coordinates, nm from the outer corner of the first pixel of
the channel-1 region), in the same frame, without drift correction. Channel-1 rows and rows of single-colour
movies keep their table position. partner is, for a molecule spot, the row of the spot in the other channel
of the same frame that is the same molecule, and -1 otherwise (always -1 in single-colour movies and for beads).drift.csv, with a header line frame,dx_nm,dy_nm and one line per light frame of the movie (frame numbers
as in the table; dark frames have no line): the displacement of the sample in nm along the channel-1 (or
direct-path) x and y axes, relative to the first light frame. A static object on the glass sits at its
first-frame position plus the drift. For a movie without beads write zeros.The program runs with Python 3.12, numpy, scipy and pandas, on one CPU core with 2 GB of memory and no network,
and must finish each movie within 10 seconds. Movies have up to 3000 frames. It is run as another user from a
copy of /app/output: it may load helper files that you put in /app/output (found relative to __file__),
but /app/inputs is not there when it runs.
/app/output/results/<movie>/registered.csv and /app/output/results/<movie>/drift.csv for each of the eleven
movies in localisations/, made with the registration stacks of the right day.
Rafael Domingues, the core's facility engineer, runs the program on the core's validation set: 30 further TIRF-2 movies, each given as record, localisation table and registration folder, that the core generates with its model of the instrument, so the true channel mapping of each movie, the true stage drift and which spots are the same molecule are known. Twelve re-image cells and fields of the movies in hand in other sessions; eighteen use settings, dates, samples and labelling densities that SOP-031, the calibration reports and the groups' plans allow, some of which the movies in hand show once or not at all. The eleven result sets in hand are compared with their known values in the same way.
Per movie, each quantity's error is compared with the error of the core's reference analysis on the same movie (allowance: the larger of the reference's error and the floor below):
| Quantity | Error | Floor | Full credit up to | No credit at |
|---|---|---|---|---|
| registration (two-colour movies) | RMS over the channel-2 rows of real spots of the distance between x_nm, y_nm and the channel-1 position that the spot's reported channel-2 position truly corresponds to (each distance capped at 500 nm) |
2 nm | allowance + 2 nm | allowance + 6 nm |
| drift (movies with beads) | RMS over light frames of the distance between dx_nm, dy_nm and the true drift, after removing the mean difference |
1 nm | allowance + 1 nm | allowance + 3 nm |
| partners (two-colour movies) | F1 of the channel-1 rows' partners against the true same-molecule pairs (rows of beads ignored), shortfall against the reference | 0.03 below | 0.09 below |
Credit falls linearly between the last two columns. Movie score = weighted mean of the credits of the quantities graded on it (registration 0.40, drift 0.25, partners 0.35). In the means, a two-colour movie with beads counts three times, a two-colour movie without beads twice and a single-colour movie once. A crash, a time-out, a missing or unreadable file scores zero for that movie; a missing line counts as a wrong value. The final score is 80 % the weighted mean over the 30 validation movies and 20 % the weighted mean over the eleven movies in hand.