Skip to content
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

Merged
merged 20 commits into from
Sep 19, 2024
Merged

Update ecg.py #39

merged 20 commits into from
Sep 19, 2024

Conversation

trueZihaoXu
Copy link

Added Pan_Tompkins_Plus_Plus, an improved Pan-Tompkins algorithm

Added Pan_Tompkins_Plus_Plus, an improved Pan-Tompkins algorithm
Added automatic beat correction algorithm
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
biosppy/signals/ecg.py Outdated Show resolved Hide resolved
th: float
Threshold.
'''
df = pd.DataFrame({"signal": np.abs(x)})
Copy link
Collaborator

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?

Copy link
Author

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?

Copy link
Collaborator

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?

Copy link
Author

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

Copy link
Collaborator

@sofia3ms sofia3ms left a 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!

trueZihaoXu and others added 9 commits May 18, 2024 12:23
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>
trueZihaoXu and others added 9 commits May 18, 2024 12:25
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
@sofia3ms sofia3ms self-requested a review September 19, 2024 13:51
@sofia3ms sofia3ms merged commit 2556e5f into scientisst:main Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants