Borrar filtros
Borrar filtros

How to manually edit located peaks using findpeaks function?

50 visualizaciones (últimos 30 días)
Daniel Jeronimo González Sánchez
Daniel Jeronimo González Sánchez el 11 de Jul. de 2024 a las 1:14
Comentada: Umar el 17 de Jul. de 2024 a las 17:45
I'm trying to use findpeaks to localize R peaks from electrocardiogram signal. I'm getting good results but there are some missing and false positive peaks. So, I would like to know if there is an option to manually edit the located peaks. If it is not possible to manually edit the data I would be glad reciving any other suggestion. Thanks.
  2 comentarios
Umar
Umar el 11 de Jul. de 2024 a las 3:26
Hi Daniel,
One approach is to visualize the ECG signal with the detected peaks overlaid and then interactively adjust or remove erroneous peaks. You can achieve this by plotting the signal and the detected peaks using plot and hold on, allowing you to manually inspect and modify the peak locations.
Another suggestion is to explore different peak detection algorithms or adjust the parameters of findpeaks to improve the accuracy of peak localization. Experimenting with the MinPeakHeight, MinPeakDistance, and other parameters might help reduce false positives and identify missing peaks more effectively. Additionally, consider filtering the signal or applying signal processing techniques before peak detection to enhance the quality of the results.
Please let me know if you have any further questions.
KSSV
KSSV el 11 de Jul. de 2024 a las 3:28
You can put threshold to avoid finding peaks lower than the threshold. If you want to edit, you have the locations/ indices of the peakswith which you can change the values.

Iniciar sesión para comentar.

Respuestas (3)

Star Strider
Star Strider el 12 de Jul. de 2024 a las 3:31
I (almost) always use the 'MinPeakProminence' name-value pair for this sort of problem. Only in the case of significant hyperkalaemia (high T-deflection amplitude) will that fail to define only the R-deflection in a Lead II EKG. In other leads (for example Lead III where the lead itself can be orthogonal to the cardiac axis), detecting only the R-deflection may be more difficult.
  1 comentario
Star Strider
Star Strider el 17 de Jul. de 2024 a las 10:12
Thank you for your help, I've already filtered the data and overlaid the peaks, also I proved editing the peaks and locs variables and it also worked out removing dots from the graphics and editing directly the variables, but I'm still strugling with adding dots on the graphics, have you any advice?
I am not certain what you are referring to. It would help if you provide code (and data, if necesary) to illusltrate the problem you are having.

Iniciar sesión para comentar.


Daniel Jeronimo González Sánchez
Daniel Jeronimo González Sánchez el 17 de Jul. de 2024 a las 2:58
Thank you for your help, I've already filtered the data and overlaid the peaks, also I proved editing the peaks and locs variables and it also worked out removing dots from the graphics and editing directly the variables, but I'm still strugling with adding dots on the graphics, have you any advice?
  1 comentario
Umar
Umar el 17 de Jul. de 2024 a las 3:20

Hi Daniel,

Is this what you are looking for plot(x, y, 'o'), this will create a plot with dots at the data points. You can customize the appearance of the dots by adjusting the marker properties. Please see attached.

Iniciar sesión para comentar.


Daniel Jeronimo González Sánchez
Daniel Jeronimo González Sánchez el 17 de Jul. de 2024 a las 17:10
Here I provide more context. I'm using this code to find peaks and overlaid them on the data (already filtered and denoised):
% Umbrals
um_y = 0.08;;
um_x = 0.3*Fs;
[R_pks, R_locs] = findpeaks(ecg_stop60, 'MinPeakHeight', um_y, 'MinPeakDistance', um_x);
% Plot peaks
figure;
hold on;
plot(t,ecg_stop60);
scatter(t(R_locs), R_pks);
xlabel('Tiempo (s)');
ylabel('Amplitud (mV)');
title('Picos R');
xlim([130 140])
hold off
I get good results, here is the plot:
But I still get some portions of the data with false positive and false negative dots, for instance:
I already figured out how to edit the dots directly on the peaks and locs variables. Also I have used brush tool to eliminate erroneous dots directly on the graphics window and I've seen that it's possible to modify dots using the brush tool, but I would like to know if there is a tool which allow to add dots using the graphics window because it would be useful in some especific cases.
  2 comentarios
Star Strider
Star Strider el 17 de Jul. de 2024 a las 17:18
If you provide the data, I might be able to help with this. I cannot do anything with only the images of it. It might benefit from lowpass filtering, however I am not certain how much of an improvement that would be.
Umar
Umar el 17 de Jul. de 2024 a las 17:45
Hi Daniel,
Sorry to intervene. Perhaps, I could be wrong but if you utilize datacursormode function, it will enable you to add data tips interactively to a plot. So, by clicking on a data point, you can add a data tip that displays the coordinates of that point. This feature allows for easy identification and manipulation of specific data points on a plot.To enable data cursor mode, you can use the following code snippet:
dcm_obj = datacursormode(gcf); set(dcm_obj,'UpdateFcn',@your_custom_function);
In the your_custom_function, you can define the behavior when a data point is clicked. This function can be customized to add, edit, or remove data points based on your interaction. For more information on this function, please refer to https://www.mathworks.com/help/matlab/ref/matlab.graphics.shape.internal.datacursormanager.html
I will still follow @Star Strider lead on this one.

Iniciar sesión para comentar.

Productos


Versión

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by