Skip to content

fix(peaks): peak marks follow chemical-shift reference edits - #76

Merged
nmrtist merged 1 commit into
nmrtist:mainfrom
Limdongcheng:up/peaks-follow-reference
Aug 29, 2026
Merged

fix(peaks): peak marks follow chemical-shift reference edits#76
nmrtist merged 1 commit into
nmrtist:mainfrom
Limdongcheng:up/peaks-follow-reference

Conversation

@Limdongcheng

Copy link
Copy Markdown
Contributor

Summary

PeakMark stored its x as a finished-spectrum snapshot, so editing a Reference step shifted the whole ppm axis while every existing mark stayed at the old coordinate — visibly detached from its peak.

Marks now store the uncalibrated position (finished x minus the pipeline's reference offset at pick time) and every reader adds the current offset back through PeakSet::resolve(offset), fed by the new Dataset::peak_reference_offset_ppm() — the pipeline's single semantic outlet chemical_shift_reference_offset_ppm, previously used only by CRAFT. The calibration lives once, in the pipeline, so marks follow any Reference edit — including undo/redo — without being rewritten. Both write paths (manual picks and detection) subtract the current offset symmetrically; de-duplication compares in uncalibrated space. Persisted mark coordinates change meaning; the format stays v1 with no compatibility reader, per repository policy. y deliberately remains a pick-time intensity snapshot: reference edits never change intensities.

Validation

  • cargo pr-check passes on current main (fmt, source sizes, dependency policy, default-frontends build, clippy -D warnings, reference-backend test suite).
  • Regression tests: mark → reference edit → resolved ppm follows the shifted trace and its default label; picks on an already-referenced spectrum round-trip through the uncalibrated store.

PeakMark stored its x as a finished-spectrum snapshot, so editing a
Reference step shifted the whole ppm axis while every existing mark
stayed at the old coordinate — visibly detached from its peak.

Marks now store the *uncalibrated* position (finished x minus the
pipeline's reference offset at pick time) and every reader adds the
current offset back through `PeakSet::resolve(offset)`, fed by the new
`Dataset::peak_reference_offset_ppm()` (the pipeline's single semantic
outlet `chemical_shift_reference_offset_ppm`, previously used only by
CRAFT; tables calibrate by zero). This is the lifecycle-copy option:
the calibration lives once, in the pipeline, and marks follow any
Reference edit — including undo/redo of the processing step — without
being rewritten, so no mark-translation action or migration exists.
Both write paths (manual picks and detection on the finished trace)
subtract the current offset symmetrically; de-duplication compares in
uncalibrated space. Persisted mark coordinates change meaning; the
format stays v1 with no compatibility reader, per repository policy.

`y` deliberately remains a pick-time intensity snapshot: reference
edits never change intensities, and refreshing y after re-phasing or
normalization is an orthogonal concern.

Regression tests: mark → reference edit → resolved ppm follows the
shifted trace and its default label; picks on an already-referenced
spectrum round-trip through the uncalibrated store.
@nmrtist
nmrtist merged commit 0c7efe6 into nmrtist:main Aug 29, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants