from scipy.signal import find_peaks
a=[2,3,4,1]
b=find_peaks(a)
print(b)
I am getting the indices. But I want the values. How can I get the values of the list?
You can use the indices on the original vector to return the value of the peak like this:
a = np.array([2, 3, 4, 1])
peaks, properties = find_peaks(a)
a[peaks]
The easiest way is to convert a
to a numpy array then index it.
a = np.array([2, 3, 4, 1, 5, 0], dtype=np.float32)
idx, props = find_peaks(a)
val = a[idx]
print(idx) # this outputs [2 4]
print(val) # this outputs [4. 5.]