Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.