rhenanbartels / hrv

A Python package for heart rate variability analysis
BSD 3-Clause "New" or "Revised" License
198 stars 58 forks source link

Threshold filter does not work properly for values below the threshold #30

Open mnaegelin opened 1 year ago

mnaegelin commented 1 year ago

Thanks for the awesome package! One small issue I spotted: the threshold_filter function seems to only filter values where the RRI is greater than $\text{local median} + \text{threshold}$, but not where it is smaller than $\text{local median} - \text{threshold}$:

https://github.com/rhenanbartels/hrv/blob/3f813f6727ff693daccf2fd1a939a30a966f56e1/hrv/filters.py#L216

Only for the values in the very first local window, the filtering happens in both directions: https://github.com/rhenanbartels/hrv/blob/3f813f6727ff693daccf2fd1a939a30a966f56e1/hrv/filters.py#L222