Repository navigation
[FIX] Chromatogram extraction: count the first and last peak of a spectrum exactly once - #10673
Conversation
…ctrum exactly once ChromatogramExtractorAlgorithm::extract_value_tophat (with and without ion mobility) summed the peaks inside the m/z window incorrectly at the edges of a spectrum: - The first peak was dropped when the walk to the left reached it after more than one step: the loop stopped at mz_start without adding it, and the special case for the first peak only covered a single step. - When the target m/z lay beyond the last peak, the last peak was added twice: once as the current peak and once more by the walk to the left. The walk to the left now visits every peak down to and including the first one, and the current peak is only added if the target is not past the end of the spectrum. Four existing test expectations encoded the first bug: the first peak (400.0, intensity 8) lies inside those windows, so the sums are 8408/4108/9008, not 8400/4100/9000. None of the chromatograms written by the OpenSWATH and MRM TOPP tests change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Change: Bug fix Merge Risk: ⚪ Minimal · up to
|
…ctrum exactly once (OpenMS#10673) ChromatogramExtractorAlgorithm::extract_value_tophat (with and without ion mobility) summed the peaks inside the m/z window incorrectly at the edges of a spectrum: - The first peak was dropped when the walk to the left reached it after more than one step: the loop stopped at mz_start without adding it, and the special case for the first peak only covered a single step. - When the target m/z lay beyond the last peak, the last peak was added twice: once as the current peak and once more by the walk to the left. The walk to the left now visits every peak down to and including the first one, and the current peak is only added if the target is not past the end of the spectrum. Four existing test expectations encoded the first bug: the first peak (400.0, intensity 8) lies inside those windows, so the sums are 8408/4108/9008, not 8400/4100/9000. None of the chromatograms written by the OpenSWATH and MRM TOPP tests change. Co-authored-by: Claude Opus 5.5 <[email protected]>
Description
ChromatogramExtractorAlgorithm::extract_value_tophat(both the plain and the ion mobility overload) summed the peaks inside the m/z window incorrectly at the edges of a spectrum. This is the shared OpenSWATH extractor used by OpenSwathWorkflow, OpenDIA and OpenSwathChromatogramExtractor. The first-centroid case is the one noted in the OpenDIA plan (#10661); the double count at the end of the spectrum is new.mz_startwithout adding it. The special case for the first peak only covered a single step.mz_it == mz_end. The last peak was added as the current peak and again by the walk to the left.One spectrum, window 1 Th (±0.5), same result for both overloads:
The walk to the left now visits every peak down to and including the first one. The current peak is only added if the target is not past the end of the spectrum. The walk to the right is unchanged.
Both cases only occur at the first or last peak of a spectrum, so the effect on real data should be small. The extracted values are still a change in behaviour and now match the documented sum over the window.
Tests
[EXTRA]section inChromatogramExtractorAlgorithm_testcovering the cases above for both overloads. It failed before the fix (1110, 210, 10) and passes now.ctestpasses: 2,987/2,987 tests, built with GUI and Thermo RAW off andLP_SOLVER=COIN.Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests