merge(zarr3): expose fast-merge config levers + TPS warp + optimal-site seeding#228
Merged
Conversation
…e config params
Parameterize the formerly-hardcoded fast-merge knobs so they can be tuned per screen:
- evaluate_match: threshold_triangle, threshold_point, threshold_region, ransac_kwargs
- initial_alignment / multistep_alignment: evaluate_kwargs (+ batch_size)
- refine_local_warp: degree, iterations, min_correspondences via warp_kwargs,
threaded through merge_triangle_hash / merge_sbs_phenotype
Wired through scripts/merge/{fast_alignment,fast_merge}.py and rules/merge.smk
(all config.get default None -> lib literal). Defaults unchanged => existing
screens byte-identical.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SAWdQnZAy3WU6bdxy41EgP
Adds two validated two-scope merge levers, both backward-compatible (defaults
off -> byte-identical to the affine path already on this branch):
- TPS warp: `local_refinement` now doubles as the warp-model selector
("polynomial" | "thin_plate_spline"); wire `warp_smoothing` /
`warp_max_correspondences` through scripts/merge/fast_merge.py + merge.smk.
On two-scope OPS merges TPS roughly halves the median residual vs polynomial
while staying stable. String selector is byte-identical to an explicit
warp_kwargs["model"]; a bare truthy keeps the polynomial default.
- find-optimal-site (`seed_optimize`, `seed_topk`): the stage-nearest phenotype
tile is not always the best real overlap when the two scopes have a
metadata-alignment residual. When on, evaluate the top-K nearest tiles per SBS
seed and keep the highest-scoring one per site. Default off = nearest-tile,
unchanged.
Verified: default (local_refinement=None, seed_optimize=False) path untouched;
polynomial selector == explicit model kwarg; TPS routes end-to-end and both
warps recover matches an affine drops on distorted data.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SAWdQnZAy3WU6bdxy41EgP
Cleanup of the merge fast-path (no behavioral change; smoke test identical): - Collapse multiline block comments to single lines across fast_merge.py and fast_alignment.py. - Reorder lib/merge/fast_merge.py high-level -> low-level: merge_triangle_hash, merge_sbs_phenotype, then helpers build_linear_model, refine_local_warp. - Trim refine_local_warp docstring to the file's density; ruff format + check clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SAWdQnZAy3WU6bdxy41EgP
…nobs Per review of the merge autoresearch results, keep as config-exposed only the levers with measured impact (threshold_triangle, ransac_random_state, local_refinement, warp_degree/iterations/smoothing, seed_optimize/seed_topk). Revert the inert knobs to hardcoded literals in the lib (threshold_point=2, threshold_region=50, batch_size=180, warp min/max_correspondences=30/700). Defaults unchanged => byte-identical. TPS + find-optimal-site kept (validated on Vaishnavi: median 0.08px). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
plot_merge_example / fast_merge_example gain local_refinement + warp_kwargs and apply refine_local_warp to the affine prediction, so the notebook match preview reflects the levers an operator sets. Notebook-only helper; defaults None => unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ports the fast-merge levers onto the zarr3 line (companion to #227 which lands the same change on
main). Same 3 backward-compatible commits, adapted to zarr3's merge code + house style:feat(merge): expose hardcoded fast-merge levers as backward-compatible config paramsfeat(merge): thin-plate-spline warp + find-optimal-site seeding (gated)style(merge): single-line comments, lib high->low order, ruff formatAll levers default to unset ⇒
config.get(...)→None→ lib literal ⇒ existing zarr3 screens byte-identical.Scope
5 merge-path files only:
workflow/lib/merge/{fast_merge,hash}.py,workflow/scripts/merge/{fast_alignment,fast_merge}.py,workflow/rules/merge.smk. No test files.zarr3-specific notes
config.get("merge", {}).get(...)param style used throughout zarr3'smerge.smk(main usesconfig["merge"].get(...)), and preserved zarr3's optionaldet_range/score/thresholdsemantics.threshold_region = 50inevaluate_matchthat was shadowing the (now parameterized)threshold_regionargument.ruff format --check+ruff checkclean; merge modules compile.🤖 Generated with Claude Code