-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
[Fix + Improvement] Faster _ecg_findpeaks_hamilton and bug-fix #947
Conversation
Signed-off-by: Stavros Avramidis <[email protected]>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev #947 +/- ##
==========================================
- Coverage 54.60% 54.60% -0.01%
==========================================
Files 304 304
Lines 14332 14326 -6
==========================================
- Hits 7826 7822 -4
+ Misses 6506 6504 -2 ☔ View full report in Codecov by Sentry. |
Hi @purpl3F0x , thank you for this! Could you explain what kind of "buggy" behavior you saw that motivated fix 1? It would be ideal if you could add a test https://github.com/neuropsychology/NeuroKit/tree/master/tests demonstrating that your fix works |
Hello, the controversial code is pretty small. On this line NeuroKit/neurokit2/ecg/ecg_findpeaks.py Line 372 in 3d004b4
There is a check for the length of the EDIT:
|
I see, would you mind opening an issue on the original repository then too? I see that someone already opened an issue about the code at the end of the loop you removed berndporr/py-ecg-detectors#23 Until it's fixed, I think you could just add comments stating that the implementation differs slightly from the original code |
I will also open an issue on the original repo. (berndporr/py-ecg-detectors#24) If I'm not mistaken the way this "works", now is with |
The issue has been confirmed and fixed on the original repo as of berndporr/py-ecg-detectors@f5d949d |
Thanks guys. I've applied the fix also to my repo. I had to apply it manually from the diff as you have linted your version but should be in syn now again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, thanks @purpl3F0x & @berndporr !
Description
This PR aims to improve performanc of
_ecg_findpeaks_hamilton
and fix some probable bugsProposed Changes
Bug Fixes:
n_pks
iflen(n_pks) > 8
, it should probably belen(n_pks)
i += 1
at the end of the loopImprovements:
insort
instead of appending& sorting in an already sorted array (tested about x300-500 times faster on arrays of 50 elements)Checklist
Here are some things to check before creating the PR. If you encounter any issues, do let us know :)