Skip to content

Add explicit Z slice skipping#18

Open
msayr wants to merge 4 commits into
z_alignfrom
codex/adjust-z-alignment-slice-thresholds
Open

Add explicit Z slice skipping#18
msayr wants to merge 4 commits into
z_alignfrom
codex/adjust-z-alignment-slice-thresholds

Conversation

@msayr

@msayr msayr commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Users need a way to pre-specify Z slices to skip during Z alignment and rendering and the existing code logged low-confidence SIFT estimates but did not provide a CLI to skip slices ahead of time.
  • The change implements an explicit, user-facing mechanism to mark slices as skipped in either project/global or stack-local coordinates so those slices are excluded from optical-flow computation, mesh relaxation influence and final rendering.

Description

  • Added a project-level CLI --skip-slices to emalign.align_dataset_z and propagated those global indices into each stack's config before calling align_stack_z by extending execute_alignment and align_dataset_z signatures.
  • Added stack-level CLI options --skip-slices-global and --skip-slices-local to emalign.scripts.align_stack_z and merged file/config values into the stack config.
  • Normalized requested global/local indices to local TensorStore Z indices (normalized_skip_slices) and passed that list into compute_flow_dataset (as ignore_slices) and used it during rendering to skip and log user-skipped slices.
  • Kept existing behavior for empty-slice skipping and flow cleaning; no changes were made to automatic SIFT-confidence-based skipping — SIFT valid_estimate continues to be logged while flow-cleaning thresholds remain controlled by flow_config parameters.

Testing

  • Ran python -m py_compile emalign/scripts/align_stack_z.py emalign/align_dataset_z.py which succeeded.
  • Ran git diff --check to validate whitespace/patch issues which returned clean.

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: 76624ca496

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

flow, transform, bbox_ref = compute_flow_dataset(dataset=dataset,
original_shape=original_shape,
ignore_slices=ignore_slices_flow,
ignore_slices=normalized_skip_slices,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle skipped slices at the start of flow computation

When a new skip list contains the first slice that compute_flow_dataset will process (for example --skip-slices-local <local_z_min> on a stack with first_slice/reference_path, or <local_z_min + 1> on a root stack), this passes that z into _compute_flow's ignore path before any flow has been appended. That branch constructs the placeholder from flows[-1], so flows is empty and the run raises IndexError instead of completing the requested skip; seed the placeholder independently or advance past skipped starting slices before passing them as ignore_slices.

Useful? React with 👍 / 👎.


global_z = z + z_offset - dataset.domain.inclusive_min[0]

if z in normalized_skip_slices:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip the initial reference slice before writing it

This check only runs in the rendering loop after root/disconnected stacks have already written their first non-empty slice in the first_slice is None and reference is None block and set start = z + 1. If the user requests skipping that first local/global slice, it is still rendered to the destination and used as the reference for subsequent flow, so --skip-slices* silently fails for the first slice of a root component; handle normalized_skip_slices before choosing/writing the initial reference slice.

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