[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #63987] [octave forge] (signal) findpeaks mish
From: |
John Donoghue |
Subject: |
[Octave-bug-tracker] [bug #63987] [octave forge] (signal) findpeaks mishandling flat valleys |
Date: |
Tue, 27 Jun 2023 09:25:04 -0400 (EDT) |
Follow-up Comment #4, bug #63987 (project octave):
The flat valley gets pulled in with:
## <= in 1st derivative includes the case of oversampled signals.
idx = find (df1.*[df1(2:end); 0] <= 0 & [df2(2:end); 0] < 0);
But changing the <= to < then causes the oversampled test to fail
If I add a check later on where it loops through each peak, and filter it
out:
diff -r 31c4a47822c1 inst/findpeaks.m
--- a/inst/findpeaks.m Mon Jun 05 08:33:32 2023 -0400
+++ b/inst/findpeaks.m Tue Jun 27 09:20:05 2023 -0400
@@ -266,7 +266,11 @@
ceil (min(idx(i)+minD/2,np))).';
pp = zeros (1,3);
# If current peak is not local maxima, then fit parabola to neighbor
- if any (data(ind) > data(idx(i)))
+ if any (data(idx(i)-1) == data(idx(i)))
+ # sample on left same as peak
+ xm = 0;
+ pp = ones (1,3);
+ elseif any (data(ind) > data(idx(i)))
pp = polyfit (ind, data(ind), 2);
xm = -pp(2)^2 / (2*pp(1)); # position of extrema
H = polyval (pp, xm); # value at extrema
It passes the current tests as well as the fail of this bug
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?63987>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #63987] [octave forge] (signal) findpeaks mishandling flat valleys,
John Donoghue <=