Electrocardiogram – parametrization of waves Introduction Electrophysiological process in the health heart generates ECG signals, that reflects the summation of action potentials in individual hearth structures dependent on a heart cycle. The cycle starts by the atriums depolarization (P-wave), ventricles depolarization (QRS complex) and repolarization ventricles (T-wave). Although signal waveform variability is relatively high between individual persons, the time- dependent sequence of the waves, their polarity and amplitudes are strictly defined, that reflects the heart condition. A valid interpretation of ECG can be carried out only by the experienced cardiologist, however, the modern ECG system allows automatic parametrization and classification of the waveforms to time-saving. The parametrization is fixed to the strongest R-peaks detection; subsequent measuring of weak waves is performed between two cycles called R-R interval. Professional ECG systems contain algorithm, which combines signals from all 12 leads for robust parametrisation also pathological ECG. The main goal of this exercise is the basic measuring of normal ECG in the II. lead. Aims: 1. Record ECG (I. and II. leads) 30 seconds in relax 2. Detect all R-peaks 3. Detect P, Q, S, T maximum in each R-R interval 4. Use triangle-detector to find the onset of P, Q, T waves and end of P, Q, S(J), T 5. Implement the function with outputs of the onsets, maxima, ends of waves 6. Automatically parametrise ECG signal: intervals P, PQ (PR), Q, QRS, QT amplitudes of maxima P, R, T, and ST segment 7. Compute electrical heart-axes using (I, aVf) leads for P, R, T waves 8. Show (I, II, III, aVR, aVL, aVF) leads in normalised grid and results of automatic parametrisation 9. Compare automatic and manual measurement of ECG
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Electrocardiogram – parametrization of waves
Introduction
Electrophysiological process in the health heart generates ECG signals, that reflects the summation of
action potentials in individual hearth structures dependent on a heart cycle. The cycle starts by the
atriums depolarization (P-wave), ventricles depolarization (QRS complex) and repolarization ventricles
(T-wave). Although signal waveform variability is relatively high between individual persons, the time-
dependent sequence of the waves, their polarity and amplitudes are strictly defined, that reflects the
heart condition. A valid interpretation of ECG can be carried out only by the experienced cardiologist,
however, the modern ECG system allows automatic parametrization and classification of the
waveforms to time-saving. The parametrization is fixed to the strongest R-peaks detection; subsequent
measuring of weak waves is performed between two cycles called R-R interval. Professional ECG
systems contain algorithm, which combines signals from all 12 leads for robust parametrisation also
pathological ECG. The main goal of this exercise is the basic measuring of normal ECG in the II. lead.
Aims:
1. Record ECG (I. and II. leads) 30 seconds in relax 2. Detect all R-peaks 3. Detect P, Q, S, T maximum in each R-R interval 4. Use triangle-detector to find the onset of P, Q, T waves and end of P, Q, S(J), T 5. Implement the function with outputs of the onsets, maxima, ends of waves 6. Automatically parametrise ECG signal:
intervals P, PQ (PR), Q, QRS, QT
amplitudes of maxima P, R, T, and ST segment 7. Compute electrical heart-axes using (I, aVf) leads for P, R, T waves 8. Show (I, II, III, aVR, aVL, aVF) leads in normalised grid and results of automatic parametrisation 9. Compare automatic and manual measurement of ECG
Recording of ECG: I. lead:
- white (-): right hand
- red (+): left hand - black (ref): right leg
II. lead:
- white (-): right hand
- red (+): left leg - black (ref): right leg
Thirty seconds ECG is recorded in sit, without talking, in a relaxed position, with normal breathing. Minimize the induction loop to minimize main hum noise. Note: You can use the first 30 seconds of signals from the previous exercise. Data structure: fs=500 Hz
for i=1:length(start) seg=fII(start(i):stop(i)); % ECG 0,5-40 Hz [~,pos]=max(seg); % index of maximum Rm(i)=start(i)+pos-1; % index after segment start end
2) Detect P, Q, S, T waves in each R-R interval. Implement of triangle-detector function and use it
to detect onsets and ends of the waves. Encapsulate the final function for all waves
parametrisation. Use it in a future exercise. 1) Make the triangle-detectro function (triangle_detector.m)
function [bx_max,S]=triangle_detector(segment)
ax=1; % x-position of vertex A ay=segment(ax); % y-position of vertex A cx=length(segment); % x-position of vertex C cy=segment(cx); % y-position of vertex C
% triangle area S=f(B) S=zeros(length(segment),1); for k=1:length(segment) % from A to C bx=k; % x-position of vertex B by=segment(k); % y-position of vertex B S(k)=0.5*abs((cx-ax)*(by-ay)-(cy-ay)*(bx-ax)); % area end [~,bx_max]=max(S); % x-position of vertex B correspond to the maximal area
2) In for-cycle test R-R intervals and parametrise all waves
for i=1:length(Rm)-1 seg=fII(Rm(i):Rm(i+1)-1); % R-R segment II 0,5-40 Hz % 1. derivation (local extreme=0 for continuous signal)
df=diff([seg(1); seg]); % decrease to increase change (local minimum for digital signals) sgn=sign(df); % wave S, Q
S=find(diff(sgn)>0,1); % first local minimum Q=find(diff(sgn)>0,1,'last'); % last local minimum
S Q
% wave T, P [~,T]=max(seg(S:floor(end/2))); % maximum between S and (R-R)/2 T=T+S-1; [~,P]=max(seg(floor(end/2):Q)); % maximum between (R-R)/2 and Q P=P+floor(length(seg)/2)-1;
% end of T-wave: find foot of wave using triangle-detector between
% onset of T-wave: find foot of wave using triangle-detector between % double of R-S interval (2*S) and T-maximum Tstart=triangle_detector(seg(2*S:T)); Tstart=Tstart+2*S-1;
% onset of P-wave: find a foot of wave using triangle-detector between
% half of R-R interval and P-maximum Pstart=...
% enf of P-wave: find foot of wave using triangle-detector between
% P-maximum and double Q-R interval before end of segment (end-2QR)
QR=length(seg)-Q;
Pend=triangle_detector(seg(P:end-2*QR)); Pend=...
% onset of Q-wave: find a foot of wave using
% triangle-detector between the end of P-wave and
% Q-maximum
Qstart=... % end of Q-wave: find the index of first crossing the
% amplitude of Q-onset
Qend=... % end of S-wave: find a foot of wave using triangle-
% detector between S-maximum and T-onset
Send=...
% Save the detection in indexes from start of ECG signal
Qe(i)=Qend+Rm(i)-1; Ts(i)=Tstart+Rm(i)-1; Tm(i)=T+Rm(i)-1; Te(i)=Tend+Rm(i)-1; Ps(i)=Pstart+Rm(i)-1; Pm(i)=P+Rm(i)-1; Pe(i)=Pend+Rm(i)-1; end
P T
Qstrat
Q
Qend
R
II (
mV
)
time (s)
Send
Sm Ts
Tm
Te
Pm
Ps Pe
Qm
Qs
Se (J)
× Qe
3) Show all detection in ECG signal (II. lead) plot(t,fII); axis tight; hold on plot(t(Rm),fII(Rm),'or') plot(t(Sm),fII(Sm),'^r') plot(t(Se),fII(Se),'xr') ...
4) Encapsulate algorithm to function for future using! function [Ps,Pm,Pe,Qs,Qm,Qe,Rm,Sm,Se,Ts,Tm,Te]=my_ecg_fun(II,fs) ...
3) Use indexes for measuring ECG parameters. Remember, the order of detection in R-R interval
is R, S, T, P, Q, but interval measurement requires the heart cycle as P, Q, R, S, T. 1) Measure intervals and amplitudes
HR – heart rate per minute (BPM)
P – P-wave duration
PQ –P-Q interval, from P-onset to Q-onset
Q – Q-wave duration
QRSD – QRS complex duration, from Q-onset to S-end
QT –Q-T interval, from Q-onset to T-end
QTc – corrected QT by the HR, Bazett’s formula 𝑄𝑇𝑐𝐵 =𝑄𝑇
√𝑅𝑅⁄ ; where RR is R-R interval in
seconds
Amplitudes: P, R, T, and ST segment (S-end to T-onset) P_amp=median(fII(Pm)-fII(Ps));
...
ST_amp(i)=mean(fII(Se(i):Ts(i)));
2) Compute electrical heart exes for P, R, T waves.
Remember filter the I. and II. leads. fIII=fII-fI; faVf=(fII+fIII)/2; faVr=-(fI+fII)/2; faVl=(fI-fIII)/2;
% P-maximum can be under zero line in I. lead. Compute