Superimposing/Overlaying Points on a Graph

18 visualizaciones (últimos 30 días)
N. Alfred
N. Alfred el 16 de Jun. de 2022
Comentada: William Rose el 17 de Jun. de 2022
Hi,
I am tryiing to make ecg cycles overlap in a plot. I have an ecg with multiple cycles (P-QRS-T) and i'd like them to overlap each other and appear as though the was just one.
I would be very greatful for any help i can get.
load('f3.mat');
P= 60/120800;
zeit=0:P:60-P;
E=data;
plot(zeit,E);
ylabel('Potential(mV)');
xlabel('Zeit(s)');
grid minor;
that is my code to plot the data.
now i'd like the peaks to overlap each other.
my data is included below.

Respuesta aceptada

William Rose
William Rose el 16 de Jun. de 2022
@N. Alfred, to make the plots "appear as though there was just one", we should identify identiy the R-waves, use those to chop th signal into separate beats, and rescale the time axis to make each peak be at the same time in the recscaled time ais. Then we rescale the vertical axis so the peak heights also match, and so that the baseline matches. Define the baseline by the "isoelectric line" which is the level of the T-to-P segment.
  4 comentarios
William Rose
William Rose el 16 de Jun. de 2022
@N. Alfred, Here is code that reads in the data, keeps every other point (see comment above), filters the data to deal with the glitch at 39 seconds, and detects the height and time of every R wave in the filtered data. The high pass cutoff frequency of 0.5 Hz was chosen because it results in all R wave peaks being higher than the glitches. A cutoff frequency of 0.2 Hz would alter the signal less, but with a 0.2 Hz high pass cutoff, at least one R wave peak was missed. The drawback of highpass filtering is that it can mask or alter certain features that are clinically significant, such as S-T segment elevation. See comments in the code for more details.
Then the script plots the raw data and the filtered data, and it marks the R waves in the filtered data. I renamed your .mat file ekgExample.mat. The plot made by the script is below. In the scond screenshot below, I have zoomed in on the region of the glitch around 39 seconds.
Now that you have the height and location of each R-wave, you are well-positioned to chop the signal into separate beats and superimpose the beats. I recommend chopping halfway between each R wave. Slide the time axis for each beat, so that each R-wave peak occurs at the same time. Try plotting the chopped signal without any horizontal or vertical rescaling, to see how good the overlap is, if you don't do any special rescaling. Then you can try the ideas I expressed in my initial answer.
William Rose
William Rose el 17 de Jun. de 2022
@N. Alfred, The attached code plots the EKGs of all beats, superimposed, using the approach I suggested. This plot also includes the mean EKG, in red. It also plots the EKGs of the first 6 beats only, so that you can see the details of how different beats differ. The variation from beat to beat means that It is impossible to make all these EKGs look like one beat, as you requested in your original posting. They differ in their start and end times, min and max of QRS complex, P waves, T waves, etc.
The plots generated by the script are shown below.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Signal Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by