Repository navigation
Fix correct_peaks for peaks near the start of the signal - #613
Merged
Merged
Conversation
TheNetherWatcher
force-pushed
the
correct-peaks-early
branch
2 times, most recently
from
October 31, 2026 18:43
7649c3f to
6334ec4
Compare
shift_peaks sliced sig[ind - r : min(ind + r, sig_len - 1)], which leaves out ind + r and the last sample of the signal. A peak exactly search_radius samples after the original index, or on the last sample, could not be found.
For peaks closer to the start than search_radius, the search window starts at 0, so argmax already gives the absolute index. The offset was subtracted instead of added, moving these peaks to the wrong place, often before the start of the signal.
TheNetherWatcher
force-pushed
the
correct-peaks-early
branch
from
October 31, 2026 18:50
6334ec4 to
c68ff13
Compare
tompollard
approved these changes
Oct 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by @tompollard while reviewing #611.
For a peak closer to the start than
search_radius, the search window starts at 0 instead ofind - search_radius, soargmaxalready gives the absolute index. The "adjust early values" loop then subtractedsearch_radius - indwhen it should have added it, moving the peak to the wrong place, often before the start of the signal:The fix flips the sign. Peaks further than
search_radiusfrom the start are unaffected.This is based on #611, since both add tests in the same place. Only the last commit is new here; I'll rebase once #611 is merged.
Tests: a peak near the start at four positions, upward and downward. All 8 cases fail on
main.pytest -m "not network"passes (108 tests), and the docs build passes.