Repository navigation
Anchor overlap-DCT illumination fit in un-overlapped tile interiors - #178
Conversation
Tile overlaps only observe the margins of each camera frame, so the overlap-DCT correction was unconstrained in the tile interior and extrapolated there, making every channel's flat field too peaked. On a 49-tile, 5-channel ND2 this left tile centres 2.5-6.4% darker than tile edges after correction - most visible as a reversed grid in low-contrast background channels such as YFP when display contrast is stretched. Add a fixed quadratic prior that pulls the DCT correction toward zero at pixels no used overlap observes, so the fit stays at the log-median base field where there is no overlap evidence. The prior is passed to robust_ridge separately from the observations so Huber IRLS never reweights it. On the same dataset this brings the centre/edge residual to within +/-0.2% in all channels with unchanged seam agreement. Bump worker to 1.1.0 and record coverage/anchor diagnostics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BTfgrwBPb5wjNxG2W5XeEK
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BTfgrwBPb5wjNxG2W5XeEK
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
End-to-end check: I ran the real worker locally on the 49-tile ND2 dataset with v1.0.3 and with v1.1.0 ( Comparing the two output pyramids at Z index 4, with the same tight 1–99% contrast on both:
Codex review finished with no findings (👍). (Before/after images were shared outside GitHub; 🤖 Generated with Claude Code |
Problem
A user reported that Stitch Refinement + Illumination Correction left a visible illumination pattern in the YFP channel and asked whether the worker corrects every channel. It does: one model is fitted and applied per channel. The leftover pattern is a systematic over-correction that affects every channel. It only shows up clearly in low-contrast background channels like YFP once display contrast is stretched.
Cause: the overlap-DCT step is fitted only from tile-overlap pixels, and overlaps only cover the tile margins (about 38% of each 128×128 model tile on a 49-tile, ~10%-overlap grid). Nothing constrains the low-order DCT correction in the tile interior, so it extrapolates there and makes the flat field too peaked. The log-median base field alone is flat (about +0.3% center vs edge). The DCT step takes it to −2.5 to −6.4%: tile centers darker than edges after correction. Photobleaching in overlaps was also measured (later tile is 1.3% dimmer in YFP and 2.9% in A594), but it isn't the main driver: DAPI over-corrects with no measurable bleaching.
Change
fit_overlap_dctbuilds a coverage mask from the pairs that actually contributed overlap rows. It adds a fixed quadratic prior (anchorᵀ·anchor) that pulls the DCT correction toward zero at uncovered pixels, so the field stays at the log-median base where there's no overlap evidence.robust_ridgethrough a newprior=argument, separate from the observations, so Huber IRLS never reweights it and the residual diagnostics stay overlap-only. (My first version appended zero-response rows; IRLS down-weighted them in a data-dependent way. I caught that in self-review and changed it before opening this PR.)INTERIOR_ANCHOR_WEIGHT = 0.3× the overlap sample count, evaluated on at most 4,096 interior pixels.overlap_coverage_fraction,interior_anchor_weight,interior_anchor_samples.Results (49-tile, 7-Z, 5-channel ND2; center/edge residual of the median normalized corrected tile, plus median overlap seam mismatch)
Weights from 0.03 to 0.3 all give a center/edge residual within ±0.8%, so the result isn't sensitive to the exact weight.
Tests
test_overlap_dct_does_not_overcorrect_unobserved_tile_interior: a 5×5 grid with ~10% overlaps and a known flat field. It fails with the anchor disabled (field 7–9% too peaked) and passes with it../build_workers.sh --build-and-run-tests illumination_correction: 24 passed.🤖 Generated with Claude Code
https://claude.ai/code/session_01BTfgrwBPb5wjNxG2W5XeEK