Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

peak detection edge window is off by one resulting in wrong peaks identified #88

Open
christianschneebeli opened this issue Nov 30, 2021 · 0 comments

Comments

@christianschneebeli
Copy link

In detect_peaks() from peakdetection.py the edges are calculated as

    peakedges = np.concatenate((np.array([0]),
                             (np.where(np.diff(peaksx) > 1)[0]),
                             np.array([len(peaksx)])))

As a result, each edge (except the first) start one index too early and finish one index to early. cf:
peaksy[peakedges[i]:peakedges[i+1]].tolist()
Thus if for example the last y_value from the first edge is larger than all the y values in the second edge, it is detected as the peak from the second edge.
This would be the correct indices to slice the edges.

    peakedges = np.concatenate((np.array([0]),
                                (np.where(np.diff(peaksx) > 1)[0]+1),
                                np.array([len(peaksx)+1])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant