How to chop up/segment a periodic signal?

24 views (last 30 days)
I have a normal EKG signal (a periodic signal), and I 'd like to automatically chop up the signal into individual cycles (containing the P, QRS, and T waves). Could somebody please tell me how I can do that? I don't know the length of each cycle; should I calculate these precisely? Getting an approximate cycle length using autocorrelation would be good enough? The .mat file is attached.
Many thanks in advance!

Accepted Answer

Star Strider
Star Strider on 7 Sep 2022
This approach takes advantage of the fact that the Q-T interval in a normal EKG is less than one-half the previous R-R interval.
This will work for an EKG displaying regular sinus rhythm, however it might not work for atrial fibrillation (that would not then have an indentifable P-wave anyway).
LD = load(websave('ECG','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1119640/ECG.mat'))
LD = struct with fields:
ECG: [524798×1 double]
ECG = LD.ECG;
Fs = 1024;
L = numel(ECG);
t = linspace(0, L-1, L)/Fs;
[pks,locs] = findpeaks(ECG, 'MinPeakProminence',0.5)
pks = 684×1
2.5451 2.1133 1.7806 1.5151 1.2995 1.1442 1.0095 0.9103 0.8269 0.7568
locs = 684×1
251 1019 1787 2554 3323 4091 4858 5627 6394 7162
figure
plot(t, ECG)
hold on
plot(t(locs), pks, '^r')
hold off
grid
xlim([20 22.5])
for k = 1:numel(pks)-2
RR = (locs(k+1) - locs(k));
idxrng = locs(k+1) + (-fix(RR/2) : fix(RR/2));
ECGp{k} = ECG(idxrng);
end
figure
subplot(3,1,1)
plot(ECGp{20})
grid
title('Complex 20')
subplot(3,1,2)
plot(ECGp{100})
grid
title('Complex 100')
subplot(3,1,3)
plot(ECGp{200})
grid
title('Complex 200')
You could also use these to generate an ensemble average.
.
  23 Comments
Susan
Susan on 29 Nov 2022
Thank you so very much again for your help! You gave me enough hints to work on other signals and figure out a way to eliminate unwanted spikes.
Yes, these records are actual records in a noisy scenario to measure an instrument's tolerance to the environment and are not artificially corrupted.
Star Strider
Star Strider on 29 Nov 2022
As always, my pleasure!
I now get the impression that the intent here is to develop the instrumentation, and the EKG records are not the actual objective.
.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!