Simulating ECG signal
Copyright (C) 2022 Miodrag Bolic
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details <https://www.gnu.org/licenses/>.
Acknowledgements
This notebook uses modified code ecgsyn written by Patrick McSharry & Gari Clifford based on reference [1]. In order to run the code, please download ECGSSYN_Matlab folder.
% Changing the path from main_folder to a particular chapter
main_path=fileparts(which('Main_Content.mlx'));
%addpath(append(main_path,'/Chapter2'))
cd (append(main_path,'/Chapter7/Simulator'))
addpath(append(main_path,'/Service'))
SAVE_FLAG=0; % saving the figures in a file
Simulating EGC signal
In this section, we are going to simulate ECG signal based on [1].
addpath('ESGSYN_Matlab');
[s, ipeaks,rr0] = ecgsyn(250,20,0.1,46,1,0.5,250); % sampling rate 250, number of pulses 20, noise 0.1, HR 60, LF/HF =0.5
ECG sampled at 250 Hz
Approximate number of heart beats: 20
Measurement noise amplitude: 1.000000e-01
Heart rate mean: 46 bpm
Heart rate std: 1 bpm
LF/HF ratio: 0.5
Internal sampling frequency: 250
P Q R S T
ti = [-1.14321 -0.22923 0 0.22923 1.63316] radians
ai = [1.2 -5 30 -7.5 0.75]
bi = [0.218899 0.0875595 0.0875595 0.0875595 0.350238]
Integrating dynamical system
d = 4
plot(t1(1:end1),s(1:end1))
ylabel('Amplitude (mV)');
title('Simulated ECG waveform');
annonation_save('b)',"Fig7.4b.jpg", SAVE_FLAG);
ylabel('RR interval (s)');
title('Simulated RR intervals');
annonation_save('a)',"Fig7.4a.jpg", SAVE_FLAG);
rr2 = interp(rr0-mean(rr0),10);
[p,f] = pspectrum(rr2,10);
xlabel('Frequency (Hz)');
title('LF and HF components');
References
[1] P.E. McSharry, G.D. Clifford, L. Tarassenko, and L.A. Smith, "Dynamical Model for Generating SyntheticElectrocardiogram Signals," IEEE TRANSACTIONS ON BIOMEDICAL ENGINEERING, VOL. 50, NO. 3, MARCH 2003