Skip to content

feat: propagate align-by-correlation across a range#98

Open
dustenhubbard wants to merge 2 commits into
SynapseWeb:mainfrom
dustenhubbard:contrib/corr-align-propagate
Open

feat: propagate align-by-correlation across a range#98
dustenhubbard wants to merge 2 commits into
SynapseWeb:mainfrom
dustenhubbard:contrib/corr-align-propagate

Conversation

@dustenhubbard

Copy link
Copy Markdown
Member

Summary

Align by correlation (Ctrl+\) aligns the current section to the previously viewed one, but the shift it computes cannot be reapplied across a range, so aligning a stack means repeating the correlation section by section. This lets the correlation alignment record its computed shift and propagate it across a chosen range of sections, the same way a manual transform can be propagated.

Approach

  • corrAlign now routes its computed FFT shift through the existing propagation-recording path (setPropagationMode / stored_tform / propagateTo, via changeTform) instead of applying it only to the current section.

Correctness fixes included

  • corrAlign composes the shift as tform * shift_tform (the field-space shift applied after the existing transform), not shift_tform * tform. Pure translations commute, so this was invisible for translation-only sections but produced wrong alignment for sections with rotation or scale.
  • propagateTo now skips align-locked sections (honoring its own confirmation dialog, which states locked sections will not be modified) and records undo state for the sections it does modify. Both are pre-existing behaviors in propagateTo.
  • Tests: tests/test_corr_align_propagate.py, tests/test_propagate_locked_undo.py.

Closes #95

Route align-by-correlation through changeTform so the resulting shift is
recorded when propagation mode is active. A single correlation alignment
can then be propagated to the rest of the series like a manual transform,
instead of only affecting the current section.

This also corrects the transform composition order. The correlation
shift is measured in field space and must be applied after the section's
own transform (tform * shift_tform), not before. The previous order
applied the shift in section-local space, so the result was wrong
whenever the section transform was not the identity.
propagateTo told the user "Locked sections will not be modified" but
then set and saved the tform on every section in range, silently
overwriting locked alignments. Locked sections are now excluded from
the modify loop (matching changeTform's align_locked early return), so
their transforms and on-disk files are left untouched.

The propagation loop also only logged the change; it now records a
series-wide undo state plus per-section states (the same SeriesStates
pattern SeriesIterator uses), so a series undo restores the prior
transforms of every section the propagation modified.

Includes a regression test confirming the corrAlign composition order
(tform * shift_tform, field-space shift after the existing transform)
against a rotated/scaled transform where the reversed composition
visibly differs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let "Align by correlation" record its shift and propagate across a range of sections

1 participant