0% found this document useful (0 votes)
16 views14 pages

Report OFDM

Uploaded by

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

Report OFDM

Uploaded by

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

ELL 720

ADVANCED DIGITAL SIGNAL PROCESSING

DESIGN PROBLEM-3

“ECG Signal Analysis”

SUBMITTED TO:

Prof. SESAN SRIRANGARAJAN

Submitted By:

VAIBHAV MANI TRIPATHI -2022JTM2399


Brief Description

Here we are given with two ECG signal data in text file format from which we
are supposed to develop an algorithm ( in MATLAB environment ) to
estimate:-

1) Heart Rate (from R-R intervals) in BPM (beat-by-beat)

2) The beat-by-beat QRS interval

The data given has 65000 samples with sampling rate 360 HZ.

fileID = fopen('ecg_1.txt','r');

formatSpec = '%f';

A = fscanf(fileID,formatSpec);
t=(0:1:(650000-1))/360;

figure(1)
plot(t(:),A(:))
xlabel('time(seconds)')
ylabel('Amplitude')
grid on
axis tight
title('ECG-1signal full plot')

ECG-1 signal full plot

Figure(a)

fileID = fopen('ecg_2.txt','r');
formatSpec = '%f';

B = fscanf(fileID,formatSpec);
t=(0:1:(650000-1))/360;

figure(1)
plot(t(:),B(:))
xlabel('time(seconds)')
ylabel('Amplitude')
grid on
axis tight
title('ECG-2 signal full plot')

ECG-2 signal full plot

Figure(b)

To better understand the signals see them in small interval of 1000 samples.

fileID = fopen('ecg_1.txt','r');

formatSpec = '%f';

A = fscanf(fileID,formatSpec);
t=(0:1:(650000-1))/360;

figure(1)
plot(t(1:1000),A(1:1000))
xlabel('time(seconds)')
ylabel('Amplitude')
grid on
axis tight
title('ECG-1 signal for 1000 samples')
Figure-1

fileID = fopen('ecg_2.txt','r');

formatSpec = '%f';

A = fscanf(fileID,formatSpec);
t=(0:1:(650000-1))/360;

figure(1)
plot(t(1:1000),A(1:1000))
xlabel('time(seconds)')
ylabel('Amplitude')
grid on
axis tight
title('ECG-2 signal for 1000 samples')

Figure-2
In order to understand data better, we need to know terms associated with different points in
individual ECG cycle, figure -3 shows all the points marked clearly namely the P, Q, R, S, T
and U points.
Peak point in the cycle is called R point, time difference between consecutive cycles can be
estimated by finding out time between two R points which is also called as R-R Interval.

Figure-3

Once R-R interval is determined we can calculate heart rate in beats per minute or BPM using
the formula mentioned below :-

Heart Rate = 1 /(R − R interval )∗ 60


Algorithm for heart Rate Detection

In order to determine heart rate, we need to determine R-R Interval,


Implementation is based on the fact
that square of double derivative shows a sharp peak around the R point
[2-5]. Steps involved in the
algorithm are as follows:
1. Take first difference of samples: diff(ecg[n]) = decg[n]
2. Take second difference: diff(decg[n]) = d2ecg[n]
3. Take square of double difference samples : (d2ecg[n])2
4. Normalize and determine appropriate threshold
5. Find index of peaks above threshold
6. Determine corresponding R-R interval, hence Heart Rate

Figure 4 shows first, difference and square of second difference for first
few samples of ecg1 and ecg2, we can see there are sharp peaks near R
peaks
Fig 4. Implementation of Algorithm in both the signals

We can clearly observe sharp peaks in squared double difference data, at R points, in order to
normalize the peaks, a novel method have been employed. We normalize first peak setting up
a suitable window and dividing it by max value, and then we assume a window of roughly
200 samples and divide by max value in that window, window is kept small so that, two ecg
cycles do not occur in a single window, to avoid false peaks being amplified, due to division
by max value, we keep a threshold, if max value in that window is less than that threshold, we
divide by a threshold value, so that false value is not amplified but rather suppressed, this way
we can normalize all correct squared double difference values to 1 or a value greater than one.
This threshold is chosen to be a value much greater than noise floor, but smaller than visually
observed squared double difference peak values. For ecg1 it was chosen to be 500 and 200 for
ecg2 upon observation. After this while looking for R index, in order to make exact detection,
upon finding a value greater than 0.98, max was searched in a window of 40 samples, to make
exact assumption. Fig. 5 shows implementation of this novel method for first 6500 samples of
both the ecg signals.
Fig 5. Normalized peaks of squared double difference

After determining R index corresponding to normalized value peaks, we have calculated R-R
interval and hence heart rates in beats per minute using formula stated before. We have
assumed that heart rates greater than 120 BPM and less than are 40BPM are false detection,
so have put a additional constraint to remove those.

Heart Rates

Using the methods stated above, we have determined the heart rates beat by beat for both ecg
files as shown in figure 6. We can see, ecg 1 has heart rates which vary slowly with some
abnormality at some points, which may be due to false detection or data itself, whereas we
observe heartrates are quite abnormal for ecg2 and vary quite abnormally beat by beat. We
have also shown change in heart rate beat by beat, which can be seen to be in a certain range
for most beats in ecg1, but not so in ecg2
Fig 6. Heart Rates and Heart Rate change for ecg1 and ecg2

Histograms, clustering heart rate into 50 bins for both signals have been shown in figure 7,
figure 8 shows histogram of heart rate change for both signals.
Fig 7. Histogram of Heart Rates for ecg1 and ecg2

We can observe that most common heart rate for ecg1 is between 74-75 BPS, and distribution
is even around it, with very few values of too high or too low heart rates, whereas in ecg2
most common heart-rate is as low as 50-51 BPS but significant mount of times its quite high
as well, and has a big distribution at different values suggesting very un-even heart beats.
Fig 8. Histogram of Heart Rates Changes for ecg1 and ecg2

QRS Interval Detection Algorithm

In order to determine QRS interval, we first need to know exact indices of


the sample at which R peaks occur, for this purpose we have used visual
method indices, we may miss some peaks, but in general most of R peaks
will be detected. If we observe the first difference for few ECG cycles of
ecg1 in figure-9, we can observe that, since QRS cycle is increasing
before peak, we see positive value in first difference indicating positive
slope and similarly, after R peak, we see decreasing values, leading to
negative values of first difference which is an indicator of the slope.
Fig 9. Algorithm description for QRS detection

Fig 10. First difference of few samples of ecg2

We can observe that at the exact point of R-Peak, first difference is slightly negative or
slightly positive, and it remains negative till QRS envelope value is decreasing after R peak,
then again it becomes positive, after QRS interval ends, and similarly on the left side of peak,
value of first difference is positive for the duration of QRS envelope then it becomes
negative, so we have employed this observation to find QRS intervals.
After reaching index of the peak, we iterate after leaving two samples on either side till we
find negative values to right of the peak and, positive values to the left of the peak, then add
total no of samples, say total is m samples. So QRS interval will be given as

QRS = (1/Fs)*m
So using this method, QRS intervals are calculated and plotted in figure 11 for both the
signals.
QRS Intervals

Fig 11. QRS Estimated beat by beat for ecg1 and ecg2

we can observe that values, are quite uniform in ecg1, except for 2 discontinuities, which may
be due to wrong detection of index, i.e. algorithm is counting derivative of noise instead of
QRS. For ecg2 data we observe quite abnormality, and values fluctuating very frequently,
with many beats having too high or too low values.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy