In this project first a directory is given as input to the program. The directory must contain independent 12 lead ecg data files. One such sample data is provided with the code. The first thing is to extract QRS complex from each lead.
x=[x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12];
Let x be a signal which contans N samples of all 12 leads where x1..x12 are the variables that stores N samples of independent waves.
[COEFF,SCORE] = princomp(x);
Score will be a noisy signal of peaks at possible R locations. But SCORE is a noisy data and extracting R peak information is difficult. Hence a simple logic is applied that extracts pure peaks which occurs at QRS complexes. Even though in all the peaks R locations will be almost same but they will never be at the same place. Hence from the reference of PCA signal, R peak in each lead must be obtained.
we will use a threshold of .9 to extract the R peaks
There could be more than one location par R peak. But minimum RR-interval is 500. Therefore closely obtained points are removed
Now from these reference, find R-peaks in each signal.
Here from the obtained R locations from PCA, we search 25 samples forth and back in each lead and get the maximum amplitude position. This is R-peak of that corresponding lead.
Once R Peaks are located, remaining peak detection are quite simple and I leave it on the Reader to understand the Logic.