SlideShare a Scribd company logo
1 of 13
Download to read offline
ECG SIMULATION USING
MATLAB
Principle of Fourier Series
Presented by
R. KARTHIK
B.E. (E.C.E), 6TH
Semester
College of Engineering, Guindy,
Anna University,
Chennai – 600025
e-mail: may_62003@yahoo.co.in
Introduction:
The aim of the ECG simulator is to produce the typical ECG waveforms of different
leads and as many arrhythmias as possible. My ECG simulator is a matlab based
simulator and is able to produce normal lead II ECG waveform.
The use of a simulator has many advantages in the simulation of ECG waveforms.
First one is saving of time and another one is removing the difficulties of taking real
ECG signals with invasive and noninvasive methods. The ECG simulator enables us
to analyze and study normal and abnormal ECG waveforms without actually using
the ECG machine. One can simulate any given ECG waveform using the ECG
simulator.
Significant features of ECG waveform:
A typical scalar electrocardiographic lead is shown in Fig. 1, where the significant
features of the waveform are the P, Q, R, S, and T waves, the duration of each wave,
and certain time intervals such as the P-R, S-T, and Q-T intervals.
fig 1.Typical ECG signal
Main features of this simulator:
• Any value of heart beat can be set
• Any value of intervals between the peaks (ex-PR interval) can be set
• Any value of amplitude can be set for each of the peaks
• Fibrillation can be simulated
• Noise due to the electrodes can be simulated
• Heart pulse of the particular ECG wave form can be represented in a separate
graph
Principle:
Fourier series
Any periodic functions which satisfy dirichlet’s condition can be expressed as a
series of scaled magnitudes of sin and cos terms of frequencies which occur as a
multiple of fundamental frequency.
∞ ∞
f (x) = (a /2) + Σ ao n cos (nπx / l) + Σ bn sin (nπx / l),
n=1 n=1
a = (1/ l ) ∫ f (x) dx , T = 2l -- (1)o
T
a = (1/ l ) ∫ f (x) cos (nπx / l) dx , n = 1,2,3…. -- (2)n
T
b = (1/ l ) ∫ f (x) sin (nπx / l) dx , n = 1,2,3…. -- (3)n
T
ECG signal is periodic with fundamental frequency determined by the heart beat. It
also satisfies the dirichlet’s conditions:
• Single valued and finite in the given interval
• Absolutely integrable
• Finite number of maxima and minima between finite intervals
• It has finite number of discontinuities
Hence fourier series can be used for representing ECG signal.
Calculations:
If we observe figure1, we may notice that a single period of a ECG signal is a
mixture of triangular and sinusoidal wave forms. Each significant feature of ECG
signal can be represented by shifted and scaled versions one of these waveforms as
shown below.
• QRS, Q and S portions of ECG signal can be represented by triangular
waveforms
• P, T and U portions can be represented by triangular waveforms
Once we generate each of these portions, they can be added finally to get the ECG
signal.
Lets take QRS waveform as the centre one and all shiftings takes place with respect
to this part of the signal.
How do we generate periodic QRS portion of ECG signal
Fig 2. generating QRS waveform
From equation (1), we have
f(x) = (–bax/l) + a 0 < x < ( l/b )
= ( bax/l) + a (– l/b)< x < 0
a = (1/ l ) ∫ f (x) dxo
T
= (a/b) * (2 – b )
a = (1/ l ) ∫ f (x) cos (nπx / l) dxn
T
= ( 2ba / (n2
π2
)) * ( 1 – cos (nπ/b))
b = (1/ l ) ∫ f (x) sin (nπx / l) dxn
T
= 0 ( because the waveform is a even function)
∞
f (x) = (a /2) + Σ an cos (nπx / l)o
n=1
How do we generate periodic p-wave portion of ECG signal
Fig 3. generation of p-wave
f(x) = cos ((πbx) /(2l)) (–l/b)< x < (l/b)
a = (1/ l ) ∫ cos ((πbx) / (2l)) dxo
T
= (a/(2b))(2-b)
a = (1/ l ) ∫ cos ((πbx) / (2l)) cos (nπx / l) dxn
T
= (((2ba)/(i2
π2
)) (1-cos((nπ)/b))) cos((nπx)/l)
b = (1/ l ) ∫ cos ((πbx) / (2l)) sin (nπx / l) dxn
T
= 0 ( because the waveform is a even function)
∞
f (x) = (a /2) + Σ ao n cos (nπx / l)
n=1
Implementation in MATLAB:
Code:
Save the below file as complete.m
x=0.01:0.01:2;
default=input('Press 1 if u want default ecg signal else press 2:n');
if(default==1)
li=30/72;
a_pwav=0.25;
d_pwav=0.09;
t_pwav=0.16;
a_qwav=0.025;
d_qwav=0.066;
t_qwav=0.166;
a_qrswav=1.6;
d_qrswav=0.11;
a_swav=0.25;
d_swav=0.066;
t_swav=0.09;
a_twav=0.35;
d_twav=0.142;
t_twav=0.2;
a_uwav=0.035;
d_uwav=0.0476;
t_uwav=0.433;
else
rate=input('nnenter the heart beat rate :');
li=30/rate;
%p wave specifications
fprintf('nnp wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
a_pwav=0.25;
d_pwav=0.09;
t_pwav=0.16;
else
a_pwav=input('amplitude = ');
d_pwav=input('duration = ');
t_pwav=input('p-r interval = ');
d=0;
end
%q wave specifications
fprintf('nnq wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
a_qwav=0.025;
d_qwav=0.066;
t_qwav=0.166;
else
a_qwav=input('amplitude = ');
d_qwav=input('duration = ');
t_qwav=0.1;
d=0;
end
%qrs wave specifications
fprintf('nnqrs wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
a_qrswav=1.6;
d_qrswav=0.11;
else
a_qrswav=input('amplitude = ');
d_qrswav=input('duration = ');
d=0;
end
%s wave specifications
fprintf('nns wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
a_swav=0.25;
d_swav=0.066;
t_swav=0.125;
else
a_swav=input('amplitude = ');
d_swav=input('duration = ');
t_swav=0.125;
d=0;
end
%t wave specifications
fprintf('nnt wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
a_twav=0.35;
d_twav=0.142;
t_twav=0.18;
else
a_twav=input('amplitude = ');
d_twav=input('duration = ');
t_twav=input('s-t interval = ');
d=0;
end
%u wave specifications
fprintf('nnu wave specificationsn');
d=input('Enter 1 for default specification else press 2: n');
if(d==1)
a_uwav=0.035;
d_uwav=0.0476;
t_uwav=0.433;
else
a_uwav=input('amplitude = ');
d_uwav=input('duration = ');
t_uwav=0.433;
d=0;
end
end
pwav=p_wav(x,a_pwav,d_pwav,t_pwav,li);
%qwav output
qwav=q_wav(x,a_qwav,d_qwav,t_qwav,li);
%qrswav output
qrswav=qrs_wav(x,a_qrswav,d_qrswav,li);
%swav output
swav=s_wav(x,a_swav,d_swav,t_swav,li);
%twav output
twav=t_wav(x,a_twav,d_twav,t_twav,li);
%uwav output
uwav=u_wav(x,a_uwav,d_uwav,t_uwav,li);
%ecg output
ecg=pwav+qrswav+twav+swav+qwav+uwav;
figure(1)
plot(x,ecg);
Save the below file as p_wav.m
function [pwav]=p_wav(x)
l=1;
a=0.25
x=x+(1/1.8);
b=3;
n=100;
p1=1/l
p2=0
for i = 1:n
harm1=(((sin((pi/(2*b))*(b-(2*i))))/(b-
(2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l);
p2=p2+harm1
end
pwav1=p1+p2;
pwav=a*pwav1;
Save the below file as q_wav.m
function [qwav]=q_wav(x)
l=1;
x=x+l/6
a=0.025;
b=15;
n=100;
q1=(a/(2*b))*(2-b);
q2=0
for i = 1:n
harm5=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l);
q2=q2+harm5;
end
qwav=-1*(q1+q2);
Save the below file as qrs_wav.m
function [qrswav]=qrs_wav(x)
l=1;
a=1;
b=5;
n=100;
qrs1=(a/(2*b))*(2-b);
qrs2=0
for i = 1:n
harm=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l);
qrs2=qrs2+harm;
end
qrswav=qrs1+qrs2;
Save the below file as s_wav.m
function [swav]=s_wav(x)
l=1;
x=x-l/6
a=0.25;
b=15;
n=100;
s1=(a/(2*b))*(2-b);
s2=0
for i = 1:n
harm3=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l);
s2=s2+harm3;
end
swav=-1*(s1+s2);
Save the below file as t_wav.m
function [twav]=t_wav(x)
l=1;
a=0.35
x=x-(1/1.8);
b=7;
n=20;
t1=1/l
t2=0
for i = 1:n
harm2=(((sin((pi/(2*b))*(b-(2*i))))/(b-
(2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l);
t2=t2+harm2
end
twav1=t1+t2;
twav=a*twav1;
Save the below file as u_wav.m
function [uwav]=u_wav(x)
l=1;
a=0.03;
x=x-(1/1.1);
b=21;
n=100;
u1=1/l;
u2=0;
for i = 1:n
harm4=(((sin((pi/(2*b))*(b-(2*i))))/(b-
(2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l);
u2=u2+harm4;
end
uwav1=u1+u2;
uwav=a*uwav1;
precautions:
• All the files have to be saved in the same folder
• Save the files in the names mentioned above the code
• While entering the specification, give the amplitude in mV and duration in
seconds
Output waveform:
Default Specification
• Heart beat :72
• Amplitude:
P wave 25mV
R wave 1.60mV
Q wave 0.025mV
T wave 0.35mV
• Duration:
P-R interval 0.16s
S-T interval 0.18s
P interval 0.09s
QRS interval 0.11s
Not all the default values are specified here. They can be obtained from the code of
the simulator from the file complete.m. The user can enter their desired values of
specifications too. Other concepts of the code are simple and are self explanatory.
A typical output for the above specification will be like this:
References:
• R.S. Khandpur, Handbook of Biomedical Instrumentation
• Leslie Cromwell, Biomedical Instrumentation and Measurements, Prentice
Hall of India.
• MATLAB The Language of Technical Computing, The Mathworks.

More Related Content

What's hot

ECG DENOISING USING NN.pp
ECG DENOISING USING NN.ppECG DENOISING USING NN.pp
ECG DENOISING USING NN.ppbobbydm
 
Ecg compression using fft
Ecg compression using fftEcg compression using fft
Ecg compression using fftcjsupreme
 
DENOISING OF ECG SIGNAL USING FILTERS AND WAVELET TRANSFORM
DENOISING OF ECG SIGNAL USING FILTERS AND WAVELET TRANSFORMDENOISING OF ECG SIGNAL USING FILTERS AND WAVELET TRANSFORM
DENOISING OF ECG SIGNAL USING FILTERS AND WAVELET TRANSFORMIJEEE
 
Intelligent Heart Disease Recognition using Neural Networks
Intelligent Heart Disease Recognition using Neural NetworksIntelligent Heart Disease Recognition using Neural Networks
Intelligent Heart Disease Recognition using Neural NetworksIEEEP Karachi
 
Noise removal using_ecg
Noise removal using_ecgNoise removal using_ecg
Noise removal using_ecgLora Sahoo
 
Automatic Detection of Heart Disease Using Discreet Wavelet Transform and Art...
Automatic Detection of Heart Disease Using Discreet Wavelet Transform and Art...Automatic Detection of Heart Disease Using Discreet Wavelet Transform and Art...
Automatic Detection of Heart Disease Using Discreet Wavelet Transform and Art...Editor IJMTER
 
P-Wave Related Disease Detection Using DWT
P-Wave Related Disease Detection Using DWTP-Wave Related Disease Detection Using DWT
P-Wave Related Disease Detection Using DWTIOSRJVSP
 
Biomedical signal processing
Biomedical signal processingBiomedical signal processing
Biomedical signal processingAbdul Kader
 
FPGA based Heart Arrhythmia’s Detection Algorithm
FPGA based Heart Arrhythmia’s Detection AlgorithmFPGA based Heart Arrhythmia’s Detection Algorithm
FPGA based Heart Arrhythmia’s Detection AlgorithmIDES Editor
 
Digital signal processing appliations ecg
Digital signal processing appliations   ecgDigital signal processing appliations   ecg
Digital signal processing appliations ecgAbhiramAnne
 
Sleep 2008 Electronicsv.3
Sleep 2008 Electronicsv.3Sleep 2008 Electronicsv.3
Sleep 2008 Electronicsv.3weckhardt
 
P-QRS-T peak detection of ECG signal by MATLAB
P-QRS-T peak detection of ECG signal by MATLABP-QRS-T peak detection of ECG signal by MATLAB
P-QRS-T peak detection of ECG signal by MATLABDiptaRoy2
 
Oscilloscope Fundamentals, Hands-On Course at EELive 2014
Oscilloscope Fundamentals, Hands-On Course at EELive 2014Oscilloscope Fundamentals, Hands-On Course at EELive 2014
Oscilloscope Fundamentals, Hands-On Course at EELive 2014Rohde & Schwarz North America
 
What is transducer?Where are they used and what for?
What is transducer?Where are they used and what for?What is transducer?Where are they used and what for?
What is transducer?Where are they used and what for?AL- AMIN
 

What's hot (20)

ECG DENOISING USING NN.pp
ECG DENOISING USING NN.ppECG DENOISING USING NN.pp
ECG DENOISING USING NN.pp
 
Ecg compression using fft
Ecg compression using fftEcg compression using fft
Ecg compression using fft
 
DENOISING OF ECG SIGNAL USING FILTERS AND WAVELET TRANSFORM
DENOISING OF ECG SIGNAL USING FILTERS AND WAVELET TRANSFORMDENOISING OF ECG SIGNAL USING FILTERS AND WAVELET TRANSFORM
DENOISING OF ECG SIGNAL USING FILTERS AND WAVELET TRANSFORM
 
Intelligent Heart Disease Recognition using Neural Networks
Intelligent Heart Disease Recognition using Neural NetworksIntelligent Heart Disease Recognition using Neural Networks
Intelligent Heart Disease Recognition using Neural Networks
 
ECG
ECGECG
ECG
 
ECG BASED REPORT.
ECG BASED REPORT.ECG BASED REPORT.
ECG BASED REPORT.
 
Noise removal using_ecg
Noise removal using_ecgNoise removal using_ecg
Noise removal using_ecg
 
ECG
ECGECG
ECG
 
Automatic Detection of Heart Disease Using Discreet Wavelet Transform and Art...
Automatic Detection of Heart Disease Using Discreet Wavelet Transform and Art...Automatic Detection of Heart Disease Using Discreet Wavelet Transform and Art...
Automatic Detection of Heart Disease Using Discreet Wavelet Transform and Art...
 
P-Wave Related Disease Detection Using DWT
P-Wave Related Disease Detection Using DWTP-Wave Related Disease Detection Using DWT
P-Wave Related Disease Detection Using DWT
 
Biomedical signal processing
Biomedical signal processingBiomedical signal processing
Biomedical signal processing
 
M010417478
M010417478M010417478
M010417478
 
FPGA based Heart Arrhythmia’s Detection Algorithm
FPGA based Heart Arrhythmia’s Detection AlgorithmFPGA based Heart Arrhythmia’s Detection Algorithm
FPGA based Heart Arrhythmia’s Detection Algorithm
 
Digital signal processing appliations ecg
Digital signal processing appliations   ecgDigital signal processing appliations   ecg
Digital signal processing appliations ecg
 
Sleep 2008 Electronicsv.3
Sleep 2008 Electronicsv.3Sleep 2008 Electronicsv.3
Sleep 2008 Electronicsv.3
 
P-QRS-T peak detection of ECG signal by MATLAB
P-QRS-T peak detection of ECG signal by MATLABP-QRS-T peak detection of ECG signal by MATLAB
P-QRS-T peak detection of ECG signal by MATLAB
 
Oscilloscope Fundamentals, Hands-On Course at EELive 2014
Oscilloscope Fundamentals, Hands-On Course at EELive 2014Oscilloscope Fundamentals, Hands-On Course at EELive 2014
Oscilloscope Fundamentals, Hands-On Course at EELive 2014
 
Eeg machine calibration
Eeg machine calibrationEeg machine calibration
Eeg machine calibration
 
What is transducer?Where are they used and what for?
What is transducer?Where are they used and what for?What is transducer?Where are they used and what for?
What is transducer?Where are they used and what for?
 
Eeg machine filters
Eeg machine  filtersEeg machine  filters
Eeg machine filters
 

Similar to Ecg

signal and system Lecture 1
signal and system Lecture 1signal and system Lecture 1
signal and system Lecture 1iqbal ahmad
 
On The Fundamental Aspects of Demodulation
On The Fundamental Aspects of DemodulationOn The Fundamental Aspects of Demodulation
On The Fundamental Aspects of DemodulationCSCJournals
 
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGAnalyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGtheijes
 
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGAnalyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGtheijes
 
Module1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptxModule1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptxrealme6igamerr
 
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptxPPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptxidrissaeed
 
EC8553 Discrete time signal processing
EC8553 Discrete time signal processing EC8553 Discrete time signal processing
EC8553 Discrete time signal processing ssuser2797e4
 
Wideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfWideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfArijitDhali
 
signal and system Lecture 2
signal and system Lecture 2signal and system Lecture 2
signal and system Lecture 2iqbal ahmad
 
Basic simulation lab manual1
Basic simulation lab manual1Basic simulation lab manual1
Basic simulation lab manual1Janardhana Raju M
 
Signals and Systems-Unit 1 & 2.pptx
Signals and Systems-Unit 1 & 2.pptxSignals and Systems-Unit 1 & 2.pptx
Signals and Systems-Unit 1 & 2.pptxSelamawitHadush1
 
Signal classification of signal
Signal classification of signalSignal classification of signal
Signal classification of signal001Abhishek1
 
02_signals.pdf
02_signals.pdf02_signals.pdf
02_signals.pdfMituBaral2
 
Matlab 2
Matlab 2Matlab 2
Matlab 2asguna
 
Ch7 noise variation of different modulation scheme pg 63
Ch7 noise variation of different modulation scheme pg 63Ch7 noise variation of different modulation scheme pg 63
Ch7 noise variation of different modulation scheme pg 63Prateek Omer
 
Noise reduction in ECG signals for bio-telemetry
Noise reduction in ECG signals for bio-telemetryNoise reduction in ECG signals for bio-telemetry
Noise reduction in ECG signals for bio-telemetryIJECEIAES
 

Similar to Ecg (20)

Ecg programa simulado
Ecg programa simuladoEcg programa simulado
Ecg programa simulado
 
Dsp Lab Record
Dsp Lab RecordDsp Lab Record
Dsp Lab Record
 
signal and system Lecture 1
signal and system Lecture 1signal and system Lecture 1
signal and system Lecture 1
 
On The Fundamental Aspects of Demodulation
On The Fundamental Aspects of DemodulationOn The Fundamental Aspects of Demodulation
On The Fundamental Aspects of Demodulation
 
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGAnalyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
 
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECGAnalyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
Analyzing of an ECG Signal Mathematically By Generating Synthetic-ECG
 
Module1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptxModule1_dsffffffffffffffffffffgggpa.pptx
Module1_dsffffffffffffffffffffgggpa.pptx
 
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptxPPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
PPT Chapter-1-V1.pptx__26715_1_1539251776000.pptx.pptx
 
EC8553 Discrete time signal processing
EC8553 Discrete time signal processing EC8553 Discrete time signal processing
EC8553 Discrete time signal processing
 
Dsp manual
Dsp manualDsp manual
Dsp manual
 
Wideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfWideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdf
 
signal and system Lecture 2
signal and system Lecture 2signal and system Lecture 2
signal and system Lecture 2
 
Basic simulation lab manual1
Basic simulation lab manual1Basic simulation lab manual1
Basic simulation lab manual1
 
Signals and Systems-Unit 1 & 2.pptx
Signals and Systems-Unit 1 & 2.pptxSignals and Systems-Unit 1 & 2.pptx
Signals and Systems-Unit 1 & 2.pptx
 
Signal classification of signal
Signal classification of signalSignal classification of signal
Signal classification of signal
 
02_signals.pdf
02_signals.pdf02_signals.pdf
02_signals.pdf
 
Multidimensional Approaches for Noise Cancellation of ECG signal
Multidimensional Approaches for Noise Cancellation of ECG signalMultidimensional Approaches for Noise Cancellation of ECG signal
Multidimensional Approaches for Noise Cancellation of ECG signal
 
Matlab 2
Matlab 2Matlab 2
Matlab 2
 
Ch7 noise variation of different modulation scheme pg 63
Ch7 noise variation of different modulation scheme pg 63Ch7 noise variation of different modulation scheme pg 63
Ch7 noise variation of different modulation scheme pg 63
 
Noise reduction in ECG signals for bio-telemetry
Noise reduction in ECG signals for bio-telemetryNoise reduction in ECG signals for bio-telemetry
Noise reduction in ECG signals for bio-telemetry
 

Recently uploaded

Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 

Ecg

  • 1. ECG SIMULATION USING MATLAB Principle of Fourier Series Presented by R. KARTHIK B.E. (E.C.E), 6TH Semester College of Engineering, Guindy, Anna University, Chennai – 600025 e-mail: may_62003@yahoo.co.in
  • 2. Introduction: The aim of the ECG simulator is to produce the typical ECG waveforms of different leads and as many arrhythmias as possible. My ECG simulator is a matlab based simulator and is able to produce normal lead II ECG waveform. The use of a simulator has many advantages in the simulation of ECG waveforms. First one is saving of time and another one is removing the difficulties of taking real ECG signals with invasive and noninvasive methods. The ECG simulator enables us to analyze and study normal and abnormal ECG waveforms without actually using the ECG machine. One can simulate any given ECG waveform using the ECG simulator. Significant features of ECG waveform: A typical scalar electrocardiographic lead is shown in Fig. 1, where the significant features of the waveform are the P, Q, R, S, and T waves, the duration of each wave, and certain time intervals such as the P-R, S-T, and Q-T intervals. fig 1.Typical ECG signal
  • 3. Main features of this simulator: • Any value of heart beat can be set • Any value of intervals between the peaks (ex-PR interval) can be set • Any value of amplitude can be set for each of the peaks • Fibrillation can be simulated • Noise due to the electrodes can be simulated • Heart pulse of the particular ECG wave form can be represented in a separate graph Principle: Fourier series Any periodic functions which satisfy dirichlet’s condition can be expressed as a series of scaled magnitudes of sin and cos terms of frequencies which occur as a multiple of fundamental frequency. ∞ ∞ f (x) = (a /2) + Σ ao n cos (nπx / l) + Σ bn sin (nπx / l), n=1 n=1 a = (1/ l ) ∫ f (x) dx , T = 2l -- (1)o T a = (1/ l ) ∫ f (x) cos (nπx / l) dx , n = 1,2,3…. -- (2)n T b = (1/ l ) ∫ f (x) sin (nπx / l) dx , n = 1,2,3…. -- (3)n T ECG signal is periodic with fundamental frequency determined by the heart beat. It also satisfies the dirichlet’s conditions: • Single valued and finite in the given interval • Absolutely integrable • Finite number of maxima and minima between finite intervals • It has finite number of discontinuities
  • 4. Hence fourier series can be used for representing ECG signal. Calculations: If we observe figure1, we may notice that a single period of a ECG signal is a mixture of triangular and sinusoidal wave forms. Each significant feature of ECG signal can be represented by shifted and scaled versions one of these waveforms as shown below. • QRS, Q and S portions of ECG signal can be represented by triangular waveforms • P, T and U portions can be represented by triangular waveforms Once we generate each of these portions, they can be added finally to get the ECG signal. Lets take QRS waveform as the centre one and all shiftings takes place with respect to this part of the signal. How do we generate periodic QRS portion of ECG signal Fig 2. generating QRS waveform
  • 5. From equation (1), we have f(x) = (–bax/l) + a 0 < x < ( l/b ) = ( bax/l) + a (– l/b)< x < 0 a = (1/ l ) ∫ f (x) dxo T = (a/b) * (2 – b ) a = (1/ l ) ∫ f (x) cos (nπx / l) dxn T = ( 2ba / (n2 π2 )) * ( 1 – cos (nπ/b)) b = (1/ l ) ∫ f (x) sin (nπx / l) dxn T = 0 ( because the waveform is a even function) ∞ f (x) = (a /2) + Σ an cos (nπx / l)o n=1 How do we generate periodic p-wave portion of ECG signal Fig 3. generation of p-wave
  • 6. f(x) = cos ((πbx) /(2l)) (–l/b)< x < (l/b) a = (1/ l ) ∫ cos ((πbx) / (2l)) dxo T = (a/(2b))(2-b) a = (1/ l ) ∫ cos ((πbx) / (2l)) cos (nπx / l) dxn T = (((2ba)/(i2 π2 )) (1-cos((nπ)/b))) cos((nπx)/l) b = (1/ l ) ∫ cos ((πbx) / (2l)) sin (nπx / l) dxn T = 0 ( because the waveform is a even function) ∞ f (x) = (a /2) + Σ ao n cos (nπx / l) n=1 Implementation in MATLAB: Code: Save the below file as complete.m x=0.01:0.01:2; default=input('Press 1 if u want default ecg signal else press 2:n'); if(default==1) li=30/72; a_pwav=0.25; d_pwav=0.09; t_pwav=0.16; a_qwav=0.025; d_qwav=0.066; t_qwav=0.166; a_qrswav=1.6; d_qrswav=0.11; a_swav=0.25; d_swav=0.066;
  • 7. t_swav=0.09; a_twav=0.35; d_twav=0.142; t_twav=0.2; a_uwav=0.035; d_uwav=0.0476; t_uwav=0.433; else rate=input('nnenter the heart beat rate :'); li=30/rate; %p wave specifications fprintf('nnp wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_pwav=0.25; d_pwav=0.09; t_pwav=0.16; else a_pwav=input('amplitude = '); d_pwav=input('duration = '); t_pwav=input('p-r interval = '); d=0; end %q wave specifications fprintf('nnq wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_qwav=0.025; d_qwav=0.066; t_qwav=0.166; else a_qwav=input('amplitude = '); d_qwav=input('duration = '); t_qwav=0.1; d=0; end %qrs wave specifications
  • 8. fprintf('nnqrs wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_qrswav=1.6; d_qrswav=0.11; else a_qrswav=input('amplitude = '); d_qrswav=input('duration = '); d=0; end %s wave specifications fprintf('nns wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_swav=0.25; d_swav=0.066; t_swav=0.125; else a_swav=input('amplitude = '); d_swav=input('duration = '); t_swav=0.125; d=0; end %t wave specifications fprintf('nnt wave specificationsn'); d=input('Enter 1 for default specification else press 2: n'); if(d==1) a_twav=0.35; d_twav=0.142; t_twav=0.18; else a_twav=input('amplitude = '); d_twav=input('duration = '); t_twav=input('s-t interval = '); d=0; end %u wave specifications fprintf('nnu wave specificationsn'); d=input('Enter 1 for default specification else press 2: n');
  • 9. if(d==1) a_uwav=0.035; d_uwav=0.0476; t_uwav=0.433; else a_uwav=input('amplitude = '); d_uwav=input('duration = '); t_uwav=0.433; d=0; end end pwav=p_wav(x,a_pwav,d_pwav,t_pwav,li); %qwav output qwav=q_wav(x,a_qwav,d_qwav,t_qwav,li); %qrswav output qrswav=qrs_wav(x,a_qrswav,d_qrswav,li); %swav output swav=s_wav(x,a_swav,d_swav,t_swav,li); %twav output twav=t_wav(x,a_twav,d_twav,t_twav,li); %uwav output uwav=u_wav(x,a_uwav,d_uwav,t_uwav,li); %ecg output ecg=pwav+qrswav+twav+swav+qwav+uwav; figure(1) plot(x,ecg);
  • 10. Save the below file as p_wav.m function [pwav]=p_wav(x) l=1; a=0.25 x=x+(1/1.8); b=3; n=100; p1=1/l p2=0 for i = 1:n harm1=(((sin((pi/(2*b))*(b-(2*i))))/(b- (2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l); p2=p2+harm1 end pwav1=p1+p2; pwav=a*pwav1; Save the below file as q_wav.m function [qwav]=q_wav(x) l=1; x=x+l/6 a=0.025; b=15; n=100; q1=(a/(2*b))*(2-b); q2=0 for i = 1:n harm5=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l); q2=q2+harm5; end qwav=-1*(q1+q2); Save the below file as qrs_wav.m function [qrswav]=qrs_wav(x) l=1; a=1; b=5; n=100; qrs1=(a/(2*b))*(2-b);
  • 11. qrs2=0 for i = 1:n harm=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l); qrs2=qrs2+harm; end qrswav=qrs1+qrs2; Save the below file as s_wav.m function [swav]=s_wav(x) l=1; x=x-l/6 a=0.25; b=15; n=100; s1=(a/(2*b))*(2-b); s2=0 for i = 1:n harm3=(((2*b*a)/(i*i*pi*pi))*(1-cos((i*pi)/b)))*cos((i*pi*x)/l); s2=s2+harm3; end swav=-1*(s1+s2); Save the below file as t_wav.m function [twav]=t_wav(x) l=1; a=0.35 x=x-(1/1.8); b=7; n=20; t1=1/l t2=0 for i = 1:n harm2=(((sin((pi/(2*b))*(b-(2*i))))/(b- (2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l); t2=t2+harm2 end twav1=t1+t2; twav=a*twav1;
  • 12. Save the below file as u_wav.m function [uwav]=u_wav(x) l=1; a=0.03; x=x-(1/1.1); b=21; n=100; u1=1/l; u2=0; for i = 1:n harm4=(((sin((pi/(2*b))*(b-(2*i))))/(b- (2*i))+(sin((pi/(2*b))*(b+(2*i))))/(b+(2*i)))*(2/pi))*cos((i*pi*x)/l); u2=u2+harm4; end uwav1=u1+u2; uwav=a*uwav1; precautions: • All the files have to be saved in the same folder • Save the files in the names mentioned above the code • While entering the specification, give the amplitude in mV and duration in seconds Output waveform: Default Specification • Heart beat :72 • Amplitude: P wave 25mV R wave 1.60mV Q wave 0.025mV T wave 0.35mV • Duration: P-R interval 0.16s S-T interval 0.18s
  • 13. P interval 0.09s QRS interval 0.11s Not all the default values are specified here. They can be obtained from the code of the simulator from the file complete.m. The user can enter their desired values of specifications too. Other concepts of the code are simple and are self explanatory. A typical output for the above specification will be like this: References: • R.S. Khandpur, Handbook of Biomedical Instrumentation • Leslie Cromwell, Biomedical Instrumentation and Measurements, Prentice Hall of India. • MATLAB The Language of Technical Computing, The Mathworks.