-
Notifications
You must be signed in to change notification settings - Fork 22
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
Update ecg.py #39
Update ecg.py #39
Conversation
Added Pan_Tompkins_Plus_Plus, an improved Pan-Tompkins algorithm
Added automatic beat correction algorithm
biosppy/signals/ecg.py
Outdated
th: float | ||
Threshold. | ||
''' | ||
df = pd.DataFrame({"signal": np.abs(x)}) |
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.
Biosppy currently does not support data frames. Would it be possible to change this function to use only numpy?
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.
maybe convert dataframe to numpy array using pandas.DataFrame.to_numpy?
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.
For now we don't support pandas in biosppy, so anything that requires a pandas import will not work. Is it possible to estimate the threshold without any pandas function?
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 modification should work, i have tested and it worked:
def estimate_th(x, alpha, ww):
from scipy.ndimage import filters
x_abs = np.abs(x)
q1 = filters.percentile_filter(x_abs, 25, size=ww, mode='reflect')
q3 = filters.percentile_filter(x_abs, 75, size=ww, mode='reflect')
th = alpha * ((q3 - q1) / 2)
return th
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.
Hello Zihao, and thank you for your contribution! I suggested some changes that need to be addressed before testing the code with the rest of Biosppy. They are mainly related with imports and consistency with the rest of the library. Let me know if you agree with them!
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Co-authored-by: Sofia Monteiro <81264130+sofia3ms@users.noreply.github.com>
Add PR changes and correct bugs
Added Pan_Tompkins_Plus_Plus, an improved Pan-Tompkins algorithm