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

Missed peaks #6

Open
wesambachir opened this issue Oct 31, 2022 · 7 comments
Open

Missed peaks #6

wesambachir opened this issue Oct 31, 2022 · 7 comments

Comments

@wesambachir
Copy link

I have missed peaks (using the provided sample data) for all the beat detectors in the toolbox. Although you pointed out this in your video clip, however I could not find out how to resolve this issue. Could you please explain that.

@peterhcharlton
Copy link
Owner

Thanks for your query. Might you be able to provide the process to replicate this issue (e.g. specify which sample data you used, and the code you used)?

Please note that in the 'PPG beat detection tutorial', it appears that all the peaks were correctly detected by the 'IMS' beat detection algorithm when using this sample data. Perhaps you have been using one of the other sample data files which do result in missed beats?

Many thanks

@wesambachir
Copy link
Author

Thank you,
In fact I used the sample data file "MIMIC_PERform_1_min_normal.mat" (https://zenodo.org/record/6967256/files/MIMIC_PERform_1_min_normal.mat?download=1)
I used the following MATLAB code located on the webpage
https://ppg-beats.readthedocs.io/en/latest/tutorials/ppg_beat_detection/
S = data.ppg; % extract PPG data
beat_detector = 'IMS'; % Select Incremental-Merge Segmentation beat detector
[peaks, onsets, mid_amps] = detect_ppg_beats(S, beat_detector); % detect beats in PPG

figure('Position', [20,20,1000,350]) % Setup figure
subplot('Position', [0.05,0.17,0.92,0.82])
t = [0:length(S.v)-1]/S.fs; % Make time vector
plot(t, S.v, 'b'), hold on, % Plot PPG signal
plot(t(peaks), S.v(peaks), 'or'), % Plot detected beats
ftsize = 20; % Tidy up plot
set(gca, 'FontSize', ftsize, 'YTick', [], 'Box', 'off');
ylabel('PPG', 'FontSize', ftsize),
xlabel('Time (s)', 'FontSize', ftsize)

Missed peaks.pdf

@peterhcharlton
Copy link
Owner

Thanks very much indeed for highlighting this. I was mistaken when I said "it appears that all the peaks were correctly detected" - as you highlighted in your PDF, they weren't.

I've had a brief look and it appears that the problem is in the definition of a 'local maximum' (and 'local minimum') in the tidy_peaks_and_onsets function within detect_ppg_beats.m. The current definitions assume that these consist of a single sample at either a maximum (or minimum). In the sample data there are instances of local minima consisting of multiple consecutive samples at the same amplitude, which means they are not identified as local minima.

I'll work on adjusting this.

@wesambachir
Copy link
Author

Thank you Dr. Peter for your reply. I'll be looking forward for the corrected code.

@MitsurugiMeiya
Copy link

I've had a brief look and it appears that the problem is in the definition of a 'local maximum' (and 'local minimum') in the tidy_peaks_and_onsets function within detect_ppg_beats.m. The current definitions assume that these consist of a single sample at either a maximum (or minimum). In the sample data there are instances of local minima consisting of multiple consecutive samples at the same amplitude, which means they are not identified as local minima.

Hi Dr.Peter, I have the same issue, but when I try to use the sample data file "MIMIC_PERform_1_min_normal.mat" on the performance assessment tutorial
(https://ppg-beats.readthedocs.io/en/latest/tutorials/performance_assessment/)

Could you explain if there is a problem in a function within detect_ppg_beats.m , why access_beat_detectors.m ,which have also use the functions in _detect_ppg_beats.m , will return 100 F1 score in some beat detectors?

res noQual txt

By the way, I have another question, is it possible to get the heart rate data plot beside a PPG signal(ex. 70beats/min)?

I'm not quite understand how these procedures work, I had a brief look on your paper which had mentioned time alignment, it seems that I cannot simply treat every peak in a PPG signal as a correct beat, but there is no tutorial explain how to do time alignment with PPG and ECG on your webpage(https://ppg-beats.readthedocs.io/en/latest/tutorials/time_alignment/), I have tried to read the functions in access_beat_detectors.m but it is way too hard for me to understand.
So I wonder if there is a simple way to plot the beats data along beside the PPG signal without modify access_beat_detectors.m?

@peterhcharlton
Copy link
Owner

Thanks once again @wesambachir . I think I've now resolved this problem with commit df24b4d .

@peterhcharlton
Copy link
Owner

peterhcharlton commented Nov 29, 2022

@MitsurugiMeiya my apologies, I haven't fully understood your question. However:

  • It is possible for an algorithm to achieve an F1-score of 100% if it correctly identifies all the beats and doesn't produce any false beat detections.
  • I don't think there is a simple way to use the toolbox at the moment to plot heart rate and the PPG signal.

Does that help?

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

No branches or pull requests

3 participants