The detection of peaks using the min_dist parameter does not always produce correct results
Hi Lucas
First of all, very nice functions. There is a problem with the peak.indexes function: the detection of peaks using the min_dist parameter does not always produce correct results. For instance:
y = np.array([0, 1, 0, 2, 0, 3, 0, 2, 0, 1, 0])
peakutils.indexes(y, thres=0, min_dist=2)
Returns:
array([5, 9], dtype=int64)
But the correct is:
array([3, 5, 9], dtype=int64)
The problem is the comparison (of peak at 3) with a larger peak (at 5) which later will be removed after a comparison with an even larger peak (at 9). I solved this problem inspired on the matlab findpeaks function, see Detection of peaks in data
I hope this helps. Marcos
Comments (6)
-
repo owner -
repo owner - changed status to wontfix
-
repo owner - changed status to open
Closed the issue by mistake.
-
repo owner - changed status to resolved
Fixed! (note: the correct peak indexes are 1,5, and 9).
-
repo owner Fixed issue
#1, where indexes would ommit some peaks.→ <<cset 6fe6f8ee9889>>
-
reporter Great. And good that the function detects 1, 5, and 9 and not 3, 5, and 9! (unintentional mistake).
- Log in to comment
Hello Marcos,
Thanks for the report and for the proposed solution! I will study your implementation and think about the problem a little more. By the way, thanks for publishing your implementation, it served as inspiration for the indexes function.
Thanks,
Lucas.