Threshold normalization for function indexes

Issue #8 resolved
Shiyu Li created an issue

Hi, thank you for your excellent work.

When I was using the function peak.indexes, I was confused by the parameter "threshold" for a while until I read the source code. Currently, the threshold is normalized by

thres_normalized = thres / (max(y) - min(y))

but not every possible value of threshold could be represented between 0 and 1 in this way. For example:

y = [90, 95, 100]

if I want a threshold equal to 98, my parameter should be 9.8

Maybe the normalization should be like this:

thres_normalized = (thres - min(y)) / (max(y) - min(y))

So in the implementation of the function, it's like

def indexes(y, thres=0.3, min_dist=1):
    ...
    thres = thres * (np.max(y) - np.min(y)) +  np.min(y)
    ...

Shiyu

Comments (2)

  1. Log in to comment