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

[Feature] PPG plots improvements #883

Merged
merged 14 commits into from
Aug 22, 2023
Merged

[Feature] PPG plots improvements #883

merged 14 commits into from
Aug 22, 2023

Conversation

DominiqueMakowski
Copy link
Member

@DominiqueMakowski DominiqueMakowski commented Aug 13, 2023

Breaking

  • ecg_plot() and ppg_plot() now require the sampling_rate to be passed (for segmentation to happen) - also simplifies the code.

Changes

  • Add ppg_peaks() master function to bring it up-to-speed with ECG
  • Add ppg_segment() to be able to segment individual peaks and nicely visualize them
  • Improve ppg_plot() by adding the individual peaks overlays to the plot (like ECG)

image

@codecov-commenter
Copy link

codecov-commenter commented Aug 13, 2023

Codecov Report

Patch coverage: 90.08% and project coverage change: +0.05% 🎉

Comparison is base (4a20e15) 55.12% compared to head (0da7bdc) 55.17%.
Report is 34 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #883      +/-   ##
==========================================
+ Coverage   55.12%   55.17%   +0.05%     
==========================================
  Files         298      301       +3     
  Lines       13956    14024      +68     
==========================================
+ Hits         7693     7738      +45     
- Misses       6263     6286      +23     
Files Changed Coverage Δ
neurokit2/ppg/ppg_findpeaks.py 98.85% <66.66%> (ø)
neurokit2/signal/signal_rate.py 82.14% <78.26%> (-17.86%) ⬇️
neurokit2/ppg/ppg_segment.py 83.33% <83.33%> (ø)
neurokit2/ecg/ecg_segment.py 90.69% <92.59%> (+24.03%) ⬆️
neurokit2/ppg/ppg_plot.py 57.14% <94.11%> (+6.16%) ⬆️
neurokit2/ecg/ecg_peaks.py 100.00% <100.00%> (ø)
neurokit2/ecg/ecg_plot.py 85.36% <100.00%> (-5.12%) ⬇️
neurokit2/hrv/hrv_rsa.py 95.05% <100.00%> (ø)
neurokit2/ppg/__init__.py 100.00% <100.00%> (ø)
neurokit2/ppg/ppg_peaks.py 100.00% <100.00%> (ø)
... and 1 more

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

# fig_beats = ecg_segment(
# ecg_signals["ECG_Clean"], peaks, sampling_rate, show="return"
# )
# ax2 = fig_beats.axes[0]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now ecg_segment(..., show="return") returns a Figure, but how can we insert that figure into the axis so that we don't have to re-plot it? 🤔 @danibene any ideas from the top of your head?

matplotlib is the worse

Copy link
Collaborator

@danibene danibene Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not off the top of my head, if I understood your question correctly it seems like it's not possible to insert axes from another figure according to the answer here: https://stackoverflow.com/questions/66369315/how-to-assign-axes-from-one-figure-to-axes-from-another-figure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks, that was helpful, went with the ax kwarg similar to other packages

@DominiqueMakowski DominiqueMakowski changed the title [Feature] PPG improvements [Feature] PPG plots improvements Aug 22, 2023
@DominiqueMakowski
Copy link
Member Author

@danibene I'm not sure how / if we can transfer that to the dynamic plots, but I'd say let's merge for now and then we'll see for the rest

@DominiqueMakowski DominiqueMakowski merged commit 8932606 into dev Aug 22, 2023
10 checks passed
@DominiqueMakowski DominiqueMakowski deleted the ppg_peaks branch August 22, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants