Tuesday, February 16, 2016

Matlab code to import the date in the file “MyocInfarcECG_9_6” and plot the signals



BIOM 480A: Biomedical Signal and ImageProcessing
Colorado State University
Student: Minh Anh Nguyen
Email: minhanhnguyen@q.com

Problem 9.6: Import the date in the file “MyocInfarcECG_9_6” and plot the signals. This file contains fifteen-electrode recording of the ECG for a case of myocardial infarction with apparent ST elevation.  Use signal II or II for your analysis.
1.  do the following steps:
a a.Determine the PP interval and the RR interval for both signals.

 

PP interval = (401 – 152) * 4ms = 996ms
RR interval = (441– 191) * 4ms = 1s
a.       Use DFT to describe the signal in the frequency. Determine the heart rate.


The dominant frequency is 1.038 Hz. The atrial rate is 1.038s-1.  The heart rate is (1.038/s * 60s/min) = 62.28/min = 63 beat/min
 
c   Isolate one typical period of the signal, i.e. one cycle containing P-QRST. Calculate the duration of P,T and QRS Waves.


P wave = (112 – 90) * 4ms = 88ms
T wave = (229 – 175) * 4ms = 216ms
QRS wave = (144 – 125) * 4ms = 76ms
PT distance = (229 – 90) * 4ms = 556ms
2.       Compare a single period with one period of the signal in the problem 9.1 (baseline ECG) and comment on the differences.

PP interval = (846 – 550) *4ms = 1.184s
RR interval = (888 – 589) *4ms = 1.196s
 


P wave = (34 – 15) * 4ms = 76ms
T wave = (146 – 99) * 4ms = 188ms
QRS wave = (65 -48) * 4ms = 68ms
PT distance = (146 – 15) *4ms = 524ms





The dominant frequency is 0.8545 Hz. The atrial rate is 0.8545s-1.  The heart rate is (0.8545/s * 60s/min) = 51.27 beat/min = 52 beat/min.
Based on the ECG simulation results above, the patient with myocardial infarction condition would have heart rate faster than the patient with base line.  The PP interval and RR interval are shorter for the patient with myocardial infarction condition when compare to the patient with base line.    However, the patient with myocardial infarction condition would have longer P wave, T wave, QRS wave than the patient with base line.
1.       Is the amplitude the only discriminating factor in the diagnosis of this patient’s ECG?
No. on the ECG, the duration of T wave, QRS wave and P wave are influenced factor in the diagnosis.  Because if both ventricular depolarization (Q waves) and repolarization (ST-T wave) change will affect the myocardial infarction condition.   T wave is flatted.  




Matlab code:
BIOM 480A: Biomedical Signal and ImageProcessing
Colorado State University
Student: Minh Anh Nguyen
Email: minhanhnguyen@q.com


% problem 9.6
problem9_6data=xlsread('I:\BIOM480A3\HW 2\MyocInfarcECG_9_6.xls');
x = problem9_6data(:, 1);
y1 = problem9_6data (:, 2);
y2 = problem9_6data(:, 3);
figure; %subplot(1,2,1);
    hold on;
    %plot(x, y1,'b');
    plot(y1,'b');
    %plot(x,y2, 'g');  
title ('plot of the  MyoInfarc ECG signal')
xlabel ('time (4 msec)')
ylabel ('Amplitute MLII (mv)')
grid on;
T = 0.004 % period between each sample
% find the sampling rate or frequency
fs = 1/T;% sampling rate or frequency
% find the length of the data per second
N = length(y1);
ls = size(y1);
 % find the sampling rate or frequency
fs2 = 1/ N;
%t = (0 : N-1) / fs;
t = (0 : N-1) *T;
%t = (0:1:length(y1)-1)/fs; % sampling period
%% find PP interval
%% heart rate analysis
% count the dominant peak
beat_count =0;
for k = 2 : length(y1)-1
    %the peak has to be greater than 1 and greater than the value before it and greater then the value after it.
    if(y1(k)> y1(k-1) && y1(k) > y1(k+1) && y1(k)> 1)
        k
        disp('dominant peaks');
         beat_count = beat_count +1;
    end       
end
%% divide the peak count by the duration in minute
duration_in_sec = N/fs;
duration_in_minute = duration_in_sec/60;
BPM = beat_count/duration_in_minute;
%%% Create a period
figure;
y1new = y1(2000:2500);
hold off
plot (y1new);
title ('plot one typical period of the signal amplitude spectrume of the  MyocInfarc ECG signal')
xlabel ('time (4msec)')
ylabel ('Amplitute MLII (mv)')
grid on;
%%%  DFT to describe the signal in the frequency
NFFT = 2 ^ nextpow2(N);
Y = fft(y1, NFFT) / N;
f = (fs / 2 * linspace(0, 1, NFFT / 2+1))'; % Vector containing frequencies in Hz
amp = ( 2 * abs(Y(1: NFFT / 2+1))); % Vector containing corresponding amplitudes
figure;
plot (f, amp);
title ('plot single-sided amplitude spectrume of the MyocInfarc ECG signal')
xlabel ('frequency (Hz)')
ylabel ('|y(f)|')
grid on;
%%data=xlsread('J:\BIOM480A3\HW 2\AtrFlutterECG_9_2a.xls');
problem9_1data=xlsread('I:\BIOM480A3\HW 2\baselineECG_9_6.xls');
x1 = problem9_1data(:, 1);
y11 = problem9_1data (:, 2);
y22 = problem9_1data(:, 3);

figure; %subplot(1,2,1);
    hold on;
    %plot(x, y1,'b');
    plot(y11,'b');
   
    %plot(x,y2, 'g');  
title ('plot of the  Baseline ECG signal')
xlabel ('time (4msec)')
ylabel ('Amplitute MLII (mv)')
grid on;
%%% Create a period
figure;
y1new = y11(2000:2500);
hold off
plot (y1new);
title ('plot one typical period of the signal amplitude spectrume of the  Baseline ECG signal')
xlabel ('time (4msec)')
ylabel ('Amplitute MLII (mv)')
grid on;
N1 = length(y11);
NFFT = 2 ^ nextpow2(N1);
Y2 = fft(y11, NFFT) / N1;
f1 = (fs / 2 * linspace(0, 1, NFFT / 2+1))'; % Vector containing frequencies in Hz
amp1 = ( 2 * abs(Y2(1: NFFT / 2+1))); % Vector containing corresponding amplitudes
figure;
plot (f1, amp1);
title ('plot single-sided amplitude spectrume of the Baseline ECG signal')
xlabel ('frequency (Hz)')
ylabel ('|y(f)|')
grid on;
  Reference:



No comments:

Post a Comment