How to add baseline drift to an ECG signal

조회 수: 11 (최근 30일)
Sabaudian
Sabaudian 2022년 2월 19일
편집: Image Analyst 2022년 2월 19일
I am at the beginning of the study of ECG signal processing and I am at the start of learning MATLAB. I cannot tell if I am doing the correct operations.
the image presented above presents the operations to be performed to add the baseline drift to the starting signal.
I don't know if it is wrong or not. But when I plot the signal with the addition of the baseline drift, it seems almost unchanged.
To perform these operations I used the signal found in this database (name of the file: 100m.mat)
(to download the file in the .mat version follow the link: https://archive.physionet.org/cgi-bin/atm/ATM to download the .mat version file follow the link: https://archive.physionet.org/cgi-bin/atm/ATM and select the database called "MIT-BIH Arrhythmia Database (mitdb) and select 100 as Record, than Toolbox and selcet export as .mat")
The one below is the code I wrote:
%% Original ECG Signal
load('100m.mat');
original_signal = val(1,:);
fs = 360; % Hz
% T = 1/fs;
L = length(original_signal);
t = (0 : L - 1)/fs;
plot(t, original_signal);
title('plot of the original ECG signal');
xlabel ('time [sec]');
ylabel ('ECG Amplitute [mV]');
grid on
%% Add Noise to the ECG signal
Noise = awgn(original_signal, 20, 'measured');
plot(t, Noise, 'b');
grid on
xlabel('time [sec]');
ylabel('ECG Amplitute [mV]');
title('ECG signal with added noise');
%% Add Baseline drift to ECG signal
x = linspace(0,2*pi,L);
A = 0.8;
N = 60;
BaselineDrift = A*cos(x./N);
subplot(2,1,1)
plot(t, Noise); % Noise is the original signal with noise add to it
xlabel('time [sec]');
ylabel('ECG Amplitute [mV]');
title("Noisy ECG Signal");
subplot(2,1,2)
Dirty_Signal = Noise + BaselineDrift;
plot(t, Dirty_Signal)
xlabel('time [sec]');
ylabel('ECG Amplitute [mV]');
title("Corrupted ECG Signal (Noise + Baseline Drift)");
Thanks in advance for the help

채택된 답변

Image Analyst
Image Analyst 2022년 2월 19일
That's not all the code. Where do you define L, t, and Noise?
Try
minDriftOffset = 0; % Whatever
maxDriftOffset = 10; % Whatever.
BaselineDrift = linspace(minDriftOffset, maxDriftOffset, length(Noise));
Dirty_Signal = Noise + BaselineDrift;
  댓글 수: 5
Image Analyst
Image Analyst 2022년 2월 19일
편집: Image Analyst 2022년 2월 19일
Sorry I couldn't run it. awgn() requires the Communications Toolbox. But did you try my suggestion? If not, why not?
My code had the drift be a linear ramp while
BaselineDrift = A*cos(x./N);
has the drift be a cosine shape. You could combine both with
minDriftOffset = 0; % Whatever
maxDriftOffset = 10; % Whatever.
BaselineDrift = A * cos(x ./ length(Noise)) + linspace(minDriftOffset, maxDriftOffset, length(Noise));
Dirty_Signal = Noise + BaselineDrift;
Sabaudian
Sabaudian 2022년 2월 19일
I try it and it works thank. I hope it is consistent with what is presented in the document I plot above.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Single-Rate Filters에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by