Skip to content

[FIX,TEST] Fix auto-percentile signal-to-noise estimation - #10583

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
kg290:codex/fix-10521-percentile-binning
Oct 15, 2026
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
kg290:codex/fix-10521-percentile-binning

Conversation

@kg290

@kg290 kg290 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix automatic percentile binning for low-intensity spectra and select the actual maximum intensity.
  • Scan histogram bins through the requested percentile in both estimators.
  • Add regression coverage and document the fix in the changelog.

Validation

  • Built SignalToNoiseEstimatorMeanIterative_test and SignalToNoiseEstimatorMedian_test in the focused Ninja build.
  • Ran both test executables successfully, including the new regression cases.

Fixes #10521

Summary by CodeRabbit

  • Bug Fixes
    • Corrected automatic percentile-based signal-to-noise thresholds for low-intensity and all-zero spectra.
    • Improved handling of empty spectra and ensured percentile estimates stay within valid bounds.

Correct automatic histogram binning for low intensities, use the maximum scan intensity, and scan the histogram through the selected percentile. Add regression tests for the affected estimators.

Fixes OpenMS#10521
Copilot AI balanced review requested due to automatic review settings October 15, 2026 09:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a9427e5-7894-4d69-b0ac-208d223f2bff
📥 Commits

Reviewing files that changed from the base of the PR and between 9c45d21 and 74e2a5d.

📒 Files selected for processing: 5
  • CHANGELOG
  • src/openms/include/OpenMS/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMeanIterative.h
  • src/openms/include/OpenMS/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedian.h
  • src/tests/class_tests/openms/source/SignalToNoiseEstimatorMeanIterative_test.cpp
  • src/tests/class_tests/openms/source/SignalToNoiseEstimatorMedian_test.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Both estimators change automatic percentile binning to remove the absolute intensity offset. MeanIterative also corrects maximum selection and handles empty and all-zero spectra. Tests cover the updated estimates and signal-to-noise values.

Changes: Automatic percentile binning

Layer / File(s) Summary
Estimator percentile calculations
src/openms/include/OpenMS/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedian.h, src/openms/include/OpenMS/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMeanIterative.h, CHANGELOG
Both estimators use floating-point bin sizing and bounded histogram accumulation. MeanIterative handles empty input, selects the actual maximum, and uses a fallback bin width for nonpositive maxima. The changelog records these changes.
Percentile behavior tests
src/tests/class_tests/openms/source/SignalToNoiseEstimatorMedian_test.cpp, src/tests/class_tests/openms/source/SignalToNoiseEstimatorMeanIterative_test.cpp
Tests check estimated maxima and signal-to-noise values for small and all-zero spectra. MeanIterative tests also check empty input.

Suggested reviewers: timosachsenberg

Priority: ⬇️ Low

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 74e2a

This change fixes automatic percentile binning for low-intensity spectra and adds regression tests. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: fixing automatic percentile signal-to-noise estimation and adding tests.
Linked Issues check Passed Issue #10521 coding requirements are met. Both estimators use floating-point percentile bin widths and no absolute -1 offset. Both scan histogram bins until the requested percentile. MeanIterative…
Out of Scope Changes check Passed The changes stay within issue #10521. The estimator fixes, regression tests, and CHANGELOG entry directly support the requested percentile binning and maximum-intensity corrections. No unrelated chang…
Full details: Docstring Coverage

Explanation

Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the bins at dawn
Small peaks hop where offsets are gone
Zero rests in the first bin
The maximum finds its place within
Tests keep watch as numbers run

Comment @coderabbitai help to get the list of available commands.

@timosachsenberg timosachsenberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed against #10521; all acceptance criteria are met.

  • The absolute - 1 offset is gone in both estimators. The bin index is clamped to [0, 99], so the maximum and NaN intensities stay in range.
  • MeanIterative's max_element comparator now finds the maximum. Before, it found the minimum, so a zero minimum gave bin_size == 0, and the unclamped bin index could point outside the histogram. The new c.empty() guard removes the dereference of end().
  • The percentile scan is now bounded by the 100 histogram bins. Before, it was bounded by the peak count, which could read past histogram_auto when there were more than 100 peaks.
  • std::max(1, ...) keeps the estimate from going negative for very small percentiles or spectra.
  • The new tests check hand-computed values for a spectrum with maxInt = 1. With the old binning, all five peaks fall into bin 0 (max_intensity 0.005); with the fix the estimate is 0.755, so the tests tell the old and new code apart. The updated comment in the existing Median test (1.5 instead of 0.5) is also correct, and the expected noise does not change.
  • The full Linux suite passes (3151/3151, TOPP tests included), so no reference outputs changed.

Optional: TEST_EQUAL(empty.size(), 0) in the MeanIterative test is always true. That part of the test only checks that init() on an empty spectrum does not crash. That is fine, but a comment saying so would make it clearer.


Generated by Claude Code

@timosachsenberg
timosachsenberg merged commit b52192b into OpenMS:develop Oct 15, 2026
32 checks passed
timosachsenberg pushed a commit that referenced this pull request Oct 15, 2026
…ersion, #10583, #10492, #10525, #10524, #10346, #9782)

Conflicts in ConversionHelper and its test: develop removes
MapConversion::convert(PeakMap -> ConsensusMap) and moves its peak
selection tests to MapAlignmentAlgorithmPoseClustering_test; this branch
keeps the identification data handling of the remaining conversions
(convertIdentifications() and its test section). FileConverter: develop's
comment about OMS input is dropped, as this branch removes .oms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
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.

SignalToNoiseEstimatorMedian/MeanIterative: absolute "- 1" intensity offset in histogram binning and max_element comparator bug

3 participants