PeakUtils cannot find peak at the beginning/end of data
Issue #31
resolved
Hello,
I have a dataset where one of the peaks is at the beginning, and pu
won't return it. Here's an example:
import peakutils as pu
import numpy as np
from peakutils.plot import plot as pplot
import matplotlib.pyplot as plt
u = np.array([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252])
counts = np.array([11878,47,71,54,37,29,49,37,44,40,34,33,41,31,51,51,63,45,
13,11,20,20,20,12,15,18,25,27,46,40,64,71893,2,2,1,1])
indexes = pu.indexes(counts, thres=0.001)
print(indexes)
print(u[indexes])
%matplotlib inline
plt.figure(figsize=(15,9))
pplot(u, counts, indexes)
This is the actual data I have, I have removed the middle portion to reduce the testcase size:
- On the ride side, there's a peak slightly before the end, it's detected just fine
- On the left side, despite the very low threshold of 0.001, it's not found. On the full data, this low threshold detects very small variations in the middle of the data, so I know the threshold is low enough.
Looks like I encountered an edge case :)
Thanks,
Clément
Comments (3)
-
repo owner -
reporter Hi Lucas,
Fair enough - indeed in my original data 11878 is the first element, but I want to consider it a peak for my case. I've already implemented a workaround in that case.
Cheers,
Clément
-
reporter - changed status to resolved
- Log in to comment
Hi,
Values exactly at the edges are, by design, not detected as peaks. One can't say that 11878 is a peak, as the previous value is unknown / undefined. I think this is the case here, right?