0% found this document useful (0 votes)
35 views

QRS Detection Using PCA

This document discusses using principal component analysis (PCA) to model electrocardiogram (ECG) waveforms and detect QRS complexes. It begins by introducing PCA and its advantages for dimensionality reduction and signal processing. The document then outlines the mathematical aspects of PCA, including computing the covariance matrix and eigenvalues/eigenvectors. Next, it proposes applying PCA to ECG analysis for QRS detection by representing the ECG data in a lower-dimensional feature space defined by the principal components. Finally, it provides the modeling steps for PCA-based ECG analysis, which includes obtaining data, calculating covariance/eigenvectors, forming feature vectors, reconstructing data, and interpreting results using PCA score plots.

Uploaded by

Ifrah Alam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

QRS Detection Using PCA

This document discusses using principal component analysis (PCA) to model electrocardiogram (ECG) waveforms and detect QRS complexes. It begins by introducing PCA and its advantages for dimensionality reduction and signal processing. The document then outlines the mathematical aspects of PCA, including computing the covariance matrix and eigenvalues/eigenvectors. Next, it proposes applying PCA to ECG analysis for QRS detection by representing the ECG data in a lower-dimensional feature space defined by the principal components. Finally, it provides the modeling steps for PCA-based ECG analysis, which includes obtaining data, calculating covariance/eigenvectors, forming feature vectors, reconstructing data, and interpreting results using PCA score plots.

Uploaded by

Ifrah Alam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ECG MODELING AND QRS DETECTION USING PRINCIPAL COMPONENT ANALYSIS

M.P.S. CHAWLA , H.K.VERMA , VINOD KUMAR

Department of Electrical Engineering, Indian Institute of Technology, Roorkee 247667 (India)

[email protected], [email protected], [email protected]

Abstract : Principal Component Analysis (PCA) is from the data – for example by diagonalizing the sample
used to arrange the redundantly distributed information covariance. Third, compression and decompression are
on functional activity from several biomedical signals. easy to perform given the model parameters, and require
A modeling procedure for ECG using PCA has been only matrix multiplications [4].
suggested in this paper. Eigenvectors ar e created which
form a new orthogonal basis for finding various
segments of an ECG waveform. The simulation results
are obtained using FFT (Fast fourier transform) and
PCA. The concept of “largest variance” in PCA is
chosen so as to extract the QRS complex portion only Fig.1 Various segments of an ECG-waveform.
and to exclude P-wave and T-wave. Normalization of
the ECG data to zero mean and unit variance can 2. Mathematical Aspect of PCA
considerably improve the results of visualization of
various segments of an ECG waveform. Visualization
The PCA of a random vector looks for a linear
plots or scree plots showed that there was good
transformation that provides uncorrelated components,
segments separation of the considered ECG waveform.
i.e., with a diagonal-structure covariance matrix. The
covariance matrix describes all relationships between
Keywords: Electrocardiogram, Principal component
pairs of measurements in the considered data set. Thus
analysis, QRS complex, Covariance, Shape-space.
1
Sx = XX T
(1)
1. Introduction n −1
where, X represents the ECG data set.
Over the years, computer aided Electrocardiogram Covariance matrix is always symmetric about the main
(ECG) signal analysis is gaining momentum, with diagonal and will always be a square matrix. Hence,
tremendous amount of work being carried all over the cov(a, b) = cov(b, a) (2)
world. The origin of electrical activity measured by There are two popular methods for determining the
ECG is in the muscle fibers of different parts of the eigenvalues thresholds:-
heart. The QRS complex is the most prominent (i) Take the sum of all eigenvectors, then delete those
waveform within the ECG signal as shown in Fig.1. It eigen values that fall below some % of that sum(say
reflects the electrical activity within the heart during less than 10% are neglected).
ventricular activation. Its shape, duration and time of (ii) Plot the eigenvalues against number of principal
occurrence provides valuable information about the components and look for break points in slope of
current state of heart [5,6]. this curve (scree plot). If we use the vector b to
PCA computes the most meaningful basis to re-express represent the shape model in the PCA space and
a noisy, garbled data set and reveals the hidden vector m to represent the mean of the original shape
dynamics[1]. It is a signal processing technique that vectors X, then
allows finding an orthogonal vector basis for a data set b= T(X-m) (3)
such that the signals in the vector basis correspond to Where, = matrix whose column are the “Principal
the directions of maximum variance within the data set. Components” of covariance matrix. Since the
In PCA, diagonalization of the covariance matrix results components of are not fixed during dynamic
in computation of model parameters directly[2]. Several conditions, the time-varying features of the PCA indices
methods available for determining the number of need to be evaluated.
components to extract from PCA were tested by Zwick The “Inverse Transformation” is
& Velicer (1986) and Jackson (1993). One common rule X = m + .b (4)
is Kaiser’s ‘eigenvalue greater than 1’method (Kaiser These are used to calculate .b and another “p-
1960). A component eigenvalue of one accounts for as additions” are required to compute X. Principal
much significance as a single variable [3]. components can be ordered by their contribution to the
PCA is a widely used dimensionality reduction total variance, the first making the” largest
technique in data analysis and its popularity comes from contribution”. In many practical cases, only a few
three important properties: First, it is the optimal (in components are required to describe the majority of
terms of mean squared error) linear scheme for variance. From basic trigonometry, it is easy to show
compressing a set of high dimension vectors into a set that in two dimensions, rotation of a data point (x1,y1)
of lower dimension vectors and then reconstructing. can be achieved by multiplying the data points by sines
Second, the model parameters can be computed directly and cosines of the rotation angle( ).

Authorized licensed use limited to: VIT University. Downloaded on September 09,2020 at 23:16:14 UTC from IEEE Xplore. Restrictions apply.
y2=y1cos( )+x1sin( ) (5a) W = matrix for ECG data set obtained after recording
x2=y1(-sin( ))+x1cos( ) (5b) from a specimen or can be obtained from a standard
where, is the angle through which the data set is data base(MIT/BIH/CSE). W can be chosen via PCA,
rotated in radians. such that N% of the variability is explained by the first
p-eigenvalues.
Using matrix notation, this operation can be performed
by multiplying the data matrix by a “rotation 3. Modeling Steps for PCA
matrix(R)”.
For instance, the first principal component PC1 in a data The following simplified steps are required in modeling
set of observed variables Xj, j =1,2,…..,p can be written PCA based systems:-
as, Step 1: Getting Data
PC1=W11X1+W12X2+…+W1pXp (6) Step 2: Subtract the mean
where the weights W11, W12, ……..,W1p which Step3: Calculate Covariance Matrix
are chosen to maximize the ratio of variance of Step4: Calculate eigenvectors/eigenvalues of
PC1 to the total variation, subject to the constraint covariance Matrix.
p 2 Step5: Choosing components and forming
Wij =1 (7)
feature vectors.
j =1
Feature Vector v = (eig1 eig2 eig3 ----eigp).
3. Proposed ECG Analysis using PCA for QRS Step 6: Deriving the new data set , Final Data=Row
Detection Feature vector × Row data adjust
Step 7: Getting the old data back i.e. Reconstruction of
A suitable analysis of the Electrocardiogram gives a data. Here, we reconstruct the original dimensionality of
non-invasive and low expensive mean of diagnosis of the data.
several pathological situations that disturb the normal
electrical function of the referred system. Once the QRS 4. Simulation Procedure for PCA
complex has been identified, a more detailed
examination of ECG signal can be performed. The PCA score plots plots can be used to interpret
differences and similarities among the data samples. If
only two variables are involved, the rotation performed
could be done by trial and error. The important point to
be taken care of is
PC1 Residuals = PC2 Projections
PC2 Residuals = PC1 Projections
Fig.2 PCA based scheme for QRS detection
The procedure is simply rotate the data until the
Fig.2 shows PCA based measurement model for ECG- covariance or correlation is zero. Eigen values
QRS detection. The PCA transformation gives features representing noise should not change much in value and
of the corresponding de-correlated feature set of hence will plot as a flatter response when plotted against
principal components. The QRS portion detection is not eigenvalue number. If the eigenvalues are used to
a simple task, due to the varying morphologies of measure the variance in the rotated principal
normal and abnormal complexes and because the ECG components they also need to be scaled by number of
signal experiences several different types of points.
disturbances with complex origin. In instantaneous
frequency signal, base-line is to be completely removed. Scaled Eigen Value = (EigenValue)/N
The governing equation for PCA based ECG analysis is
Q=Q0+Vim i (8) where, N = Number of points
Where, Vi = the i-th eigenvector
i is the i-th eigenvalue, which represents the sample Eigen Value = [diag(covariance matrix)]2
variance of X. Scaled eigenvalues are now eigen values with equal %
m = a scalar varying between certain limits. variances.
Q = original or actual shape of ECG wave.
Q0 = mean shape of ECG wave. 6. Simulation Results
The information in the recorded ECG signal is
processed in 4 steps:- The mathematical and graphical results using PCA for
1. Recording of ECG signal ECG analysis and QRS detection are shown below in
2. Artifact removal various figures.
3. QRS detection using PCA
4. Processed ECG (a) Mathematical Results:
The shape-space model for ECG Interpretation is Covariance Matrix, Cov = 0.1891 0.1242
Q = WX + Q0 (9) 0.1242 0.1007
where, X= shape-space vector over time.

Authorized licensed use limited to: VIT University. Downloaded on September 09,2020 at 23:16:14 UTC from IEEE Xplore. Restrictions apply.
PC = Principal Components
1.5
0.5765 -0.8171
-0.8171 -0.5765
1

eigenvalues = 0.2767 0.0130


0.5

Eigen values
fvector = Feature vector
0
-0.8171 0.5765
-0.5765 -0.8171 -0.5

-1
(b) Graphical results: The scree test uses the
eigenvalues from principal components -1.5
-1.5 -1 -0.5 0 0.5 1 1.5
analysis, drawing a straight line through the Principal components

lowest eigenvalues. Fig.5 Scree or score plot

1.3

1.2 1.2
1.1
1
1
Amplitude of ECG wave
0.9
0.8
s1

0.8
0.6
0.7

0.6
0.4

0.5
0.2
0.4
0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000
no of points 0
0 1000 2000 3000 4000 5000
Fig.3 ECG waveform for data (1AF.DIG' no of points

-CSE-data base) Fig.6 IFFT of ECG waveform

0.5

0
A m p litu d e o f E C G W a v e

-0.5

-1

-1.5

-2

-2.5
1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2
no of points
Fig.4 FFT of an ECG waveform Fig.7 PC’S on top of data

Authorized licensed use limited to: VIT University. Downloaded on September 09,2020 at 23:16:14 UTC from IEEE Xplore. Restrictions apply.
0.58 7. Conclusion
Because of its specific shape, the QRS complex serves
as an entry point for almost all automated ECG analysis
0.56 algorithms. The QRS Complex has been recovered from
A m plitude of E CG Wav e in m v

original ECG data using PCA. The original ECG data


was considered with base-line wander. The simulation
results are obtained using FFT and PCA. The concept of
0.54 “largest variance” in PCA is chosen so as to extract the
QRS complex portion only and to exclude P and T-
waves.
0.52
Acknowledgments
The authors are thankful to the Department of Electrical
Engineering, Indian Institute of Technology, Roorkee,
0.5 for providing the facilities. M.P.S. Chawla is also
5 10 15 20 25 grateful to G.S. Institute of technology & science,
no of points=616(28x22)
Fig. 8 Recovered QRS Complex Indore (M.P) India for sponsoring to doctoral research
work.

References
0.8
1. M.P.S. Chawla, H.K.Verma and Vinod Kumar.
(2006): “A new approach to ECG modeling using
0.75
principal component analysis”, NCCCB-06, National
conference held at Engineering College, Kota
0.7
(India), during March 08-10, 2006, paper. no BM-4.
0.65
2. Jackson, J. E. (1991): “A user'
s guide to principal
components”, John Wiley & Sons, New York.
0.6

3. Jolliffe, I. T. (2002): “Principal component


0.55
analysis”.Springer-Verlag , second edition, New
0.5
York.
0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8

4. Manley, B. F. J. (1994): “Multivariate statistical


Fig.9 Transformation back to original data methods: a primer”, Chapman & Hall, Bury, St.
Edmonds, Suffolk.
Original data
0.55 5. Kwatny E et al. (1970): “An application of signal
processing techniques to the study of myoelectric
signals”, IEEE Trans Biomed Eng; 17:303-313.
Y v a lu e

6. Standing P, Dent M, Craig A, Glenville B. (2001


): “Changes in referral patterns to cardiac out-
patient clinics with ambulatory ECG monitoring in
0.5 general practice”, Brit J. Cardiol ; 6: pp. 394–398.
0.5 0.52 0.54 0.56 0.58
Xvalue
Data after PCA
0.56

0.54
Y v a lu e

0.52

0.5
0.5 0.52 0.54 0.56 0.58
Xvalue
Fig.10 Status of data before/after application
of PCA

Authorized licensed use limited to: VIT University. Downloaded on September 09,2020 at 23:16:14 UTC from IEEE Xplore. Restrictions apply.

You might also like