Skip to content

Add SBEM stage-position XY alignment option#14

Open
msayr wants to merge 1 commit into
sbem_imagefrom
codex/add-alignment-feature-for-sbem_image-mode
Open

Add SBEM stage-position XY alignment option#14
msayr wants to merge 1 commit into
sbem_imagefrom
codex/add-alignment-feature-for-sbem_image-mode

Conversation

@msayr

@msayr msayr commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Improve coarse XY tile placement when SBEM Image stage coordinates are available because filename-based grid inference can place tiles far from their true positions. The new option uses stage x,y origins to stabilize initial tile positions before elastic alignment.

Description

  • Add a --use-sbem-stage-positions prep-config flag (persisted to main_config.json) and validate it is only used with --mode sbem_image in prep_config_xy.py.
  • Parse raw SBEM Image stage origins from imagelist_*.txt, expose get_stage_origin_from_name and get_stage_origins in emalign.io.sbem_image.
  • Extend get_coarse_offset in emalign.align_xy.stitch_ongrid to accept tile_origins and apply them via _apply_tile_origin_offsets to convert stage-origin deltas into SOFIMA neighbor offsets.
  • Wire the feature into stack alignment: align_stack_xy computes pixel-space tile_origins from stage origins when use_stage_positions is enabled and only allows this in sbem_image mode.
  • Add tests: a stage-origin lookup test in tests/test_sbem_image.py and a conversion test tests/test_sbem_stage_offsets.py for _apply_tile_origin_offsets.

Testing

  • Ran unit tests with PYTHONPATH=. pytest -q tests/test_sbem_image.py tests/test_sbem_stage_offsets.py and all tests passed (8 passed).
  • Performed syntax/compile checks with PYTHONPATH=. python -m py_compile emalign/io/sbem_image.py emalign/align_xy/stitch_ongrid.py emalign/scripts/align_stack_xy.py emalign/align_dataset_xy.py emalign/prep_config_xy.py, which succeeded.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdfceee626

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment on lines +62 to +63
for (x, y), (origin_y, origin_x) in tile_origins.items():
right = (x + 1, y)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fix stage-offset axes for SBEM tile keys

When this option is used through sbem_image, tile_origins is keyed by parse_yx_pos_from_name, which returns (row, col) (for example the SBEM tests expect an upper-right tile at (0, 1)). This loop unpacks those keys as (x, y), so a real right neighbor at (0, 1) is treated as down and its horizontal stage delta is written into cy instead of cx, producing a transposed/incorrect coarse mesh for SBEM rows with more than one tile. Convert the SBEM keys to the internal (x, y) convention before applying stage offsets, or unpack/index them consistently as (y, x) here.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant