Skip to content

Update ecg.py#39

Merged
sofia3ms merged 20 commits intoscientisst:mainfrom
ZHX2502:trueZihaoXu-ptpp
Sep 19, 2024
Merged

Update ecg.py#39
sofia3ms merged 20 commits intoscientisst:mainfrom
ZHX2502:trueZihaoXu-ptpp

Conversation

@ZHX2502
Copy link

@ZHX2502 ZHX2502 commented Mar 15, 2024

Added Pan_Tompkins_Plus_Plus, an improved Pan-Tompkins algorithm

ZHX2502 added 2 commits March 15, 2024 14:13
Added Pan_Tompkins_Plus_Plus, an improved Pan-Tompkins algorithm
Added automatic beat correction algorithm
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!

ZHX2502 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>
ZHX2502 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