[SciPy-Dev] Peak handling with plateaus

Todd toddrjen@gmail....
Wed Mar 27 05:06:43 CDT 2013


Currently the scipy peak-finding algorithms work for something like this:

a=np.array(1,2,3,4,5,4,3,2,1])

However, they fail for something like this:

a=np.array(1,2,3,4,5,5,5,5,4,3,2,1])

I've come across a recursive algorithm that can handle these situations (I
implemented it in python before).  It works in two stages, and is not that
difficult to implement.

Assuming we are looking for the maximum, the algorithm goes like this:

1. Strip out all value from the beginning where diff > 0 and all values
from the end where diff < 0

2: Find the miminum value

3. If the minimum value is equal to the maximum value, return the center
index of the array (or the floor of the center index if there are an even
number of elements)

4. Otherwise, split the array into sub-arrays around each instance of the
minimum value and re-run the function on those sub-arrays.

This can be followed up with a diff test around each maxima/minima to make
sure the peaks are above a certain SNR or absolute amplitude.

This method is probably not as fast as the existing implementation, but it
has the advantage that it can handle unusual corner-cases better while
still handling ordinary peaks just fine.

Would anymore be interested in having this sort of algorithm in scipy?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-dev/attachments/20130327/cda22c9c/attachment.html 


More information about the SciPy-Dev mailing list