paulvangentcom / heartrate_analysis_python

Python Heart Rate Analysis Package, for both PPG and ECG signals
MIT License
930 stars 321 forks source link

Rolling mean offsetter #84

Open meierman1 opened 2 years ago

meierman1 commented 2 years ago

Fix #80 by offsetting the rolling mean by a percentage of the standard deviation of the signal, making it DC-component-independent.

Independently, I added negative offsets. Various data that I have tested with suggest that sometimes it is more reliable to detect peaks based on the low points which is essentially what we are doing by moving the rolling average down. This makes the library a bit slower (not too much but I did not measure). If we want to compensate, we can remove any offset above 70% as this corresponds to an average only 0.3% of all samples lie above.

I chose the base value as 4*std as this seemed to be the closest to the rolling mean for the included data, making the results (especially the best value) in that case nearly identical.