how to contaminate ecg signal with noise

I am working on the project namely "FALSE ALARM REDUCTION IN ATRIAL FIBRILLATION DETCTION USING DEEP BELIEF NETWORKS".
In this i need to download two databases, namely 07910m.mat{MIT_BIH ATRIAL FIBRILLATION DATABASE} which is attached here,and also the 'em' recording {MIT_BIH NOISE STRESS TEST DATABASE} is attached.
The afib database has Fs=250Hz and 10h in length,and 'em' recording is 30 min and has Fs=360Hz
now i need to make the 'em' recording 10h in length
in the paper its told that i can be done using auto regressive model,iam not knowing how to do it
can anyone suggest me the coding for thisscreenshot.png

11 Kommentare

Daniel M
Daniel M am 16 Nov. 2019
I think the easiest way would just be to spectrally add the two signals together. Resample em to be 250 Hz, take the fft of both signals, add them together in some linear combination of your choosing, and take the inverse fft. Might have to check stuff with the phase so it isn't a bit wonky, but shouldn't be too difficult altogether. 10 lines of code max.
sai lakshmi
sai lakshmi am 17 Nov. 2019
For adding both...the 'em' signal must be of the same length as the ecg main database..how do I need to do it
Image Analyst
Image Analyst am 17 Nov. 2019
Try resample() or interp1().
sai lakshmi
sai lakshmi am 17 Nov. 2019
does changing frequency changes the length of the signal
main datbase is around 10h and noise database is 30 min
Image Analyst
Image Analyst am 17 Nov. 2019
Changing the sampling rate will change the length of the signal.
You can certainly change the 30 minute noise signal vectors to span as many elements as the main signal database vectors.
The frequency is determined by what real world units your x axis has. Like what is the time difference between two elements in your main signal? Rescaling the noise along more elements has the effect of lowering the frequency if both noise and signal had the same delta t between elements. If you don't want that then you should probably just stitch (replicate) your noise signal out to as long as your other main signal.
sai lakshmi
sai lakshmi am 18 Nov. 2019
thanks,i will try it
sai lakshmi
sai lakshmi am 19 Nov. 2019
could you please tell me how to write the equation given in the picture in matlab?
Daniel M
Daniel M am 19 Nov. 2019
Can you list the known and unknowns and the dimensions of the signals and if any are complex?
sai lakshmi
sai lakshmi am 20 Nov. 2019
Known epsilon(n) (1*1000000)which is a white noise defined earlier,also psi(I) is also defined earlier which are AR coefficients.now I need to execute the summation inside a for loop of finding x(n)
Daniel M
Daniel M am 20 Nov. 2019
Well you know there will be a loop involved. Can you show me the code you currently have? I can help you get there.
sai lakshmi
sai lakshmi am 20 Nov. 2019
load('07910m.mat');
x1=(val(1,:))/200;
n=length(x1);
fs=250;
t=0:1/fs:(n-1)/fs;
%plot(t,x1);
%[qrs_amp_raw,qrs_i_raw,delay]=pan_tompkin(x1,fs,0);
load('emm.mat');
x2=(val(1,:));
Fs=360;
x3=resample(x2,25,36);
figure(1);
subplot(2,1,1);
plot(x2);
subplot(2,1,2);
plot(x3);
[d1,p1,rc] = aryule(x3,20);
for c=1:20
psi(c)=d1(c+1);
end
zmwn=randn(size(x1));
z=double.empty(0,1000000);
for i=1:length(x1)
z(i)=(-1.8909*z(i-1)+1.2973*z(i-2)-0.7229*z(i-3)+0.4524*z(i-4)-0.2636*z(i-5)+0.2620*z(i-6)-0.2307*z(i-7)+0.2164*z(i-8)-0.8175*z(i-9)+0.1536*z(i-10)-0.1285*z(i-11)+0.0878*z(i-12)-0.0736*z(i-13)+0.0682*z(i-14)-0.0679*z(i-15)+0.0487*z(i-16)-0.0268*z(i-17)+0.0249*z(i-18)-0.0153*z(i-19)+0.0026*z(i-20))+zmwn(b);
end
I am getting an error "subscript indices must be either of positive values or logicals"
I understood the occurence for error,but am not recognizing of how to simulate the noise signal in this.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Daniel M
Daniel M am 20 Nov. 2019
Bearbeitet: Daniel M am 21 Nov. 2019

0 Stimmen

I obviously cannot run this code because I don't have the data nor any of the associated functions. By the way, you are getting an error because you are trying to access z at negative index locations.
Here is an example of how you would plot the equation. Keep in mind the assumptions I've made, which I've tried to comment.
clearvars
clc
sz = [1 1000];
e = randn(sz); % epsilon
X = nan(sz); % preallocate
X(1) = 0; % set first value. Don't know what this should be.
c = 1; % a constant, don't know what this should be
p = 5; % set the order of the model. Don't know what this should be.
% note that p cannot be greater than the iterating variable of the loop
% otherwise, it would try to access negative index locations
% So, either initialize your loop index at a value greater than 2 (and have the starting values of X)
% or do it this way, using increasing values of p, up to n-1
phi = rand(1,p); % your values of phi
for n = 2:sz(2)
ii = 1:min(p,n-1); % see the note above
sigma = dot(phi(ii), X(n-ii)); % sum of the products of the elements
X(n) = c + sigma + e(n);
end

7 Kommentare

sai lakshmi
sai lakshmi am 21 Nov. 2019
thank you ,
this was quite helpful.
but i need the product of psi(i) andx(n-i) not psi(i) andx(i)
could you please help me with it.
Daniel M
Daniel M am 21 Nov. 2019
Bearbeitet: Daniel M am 21 Nov. 2019
My bad. I edited X(ii) to X(n-ii). By the way, it is the greek symbol phi, not psi.
sai lakshmi
sai lakshmi am 21 Nov. 2019
Thank u I executed the same program by replacing 1000 in sz[1,1000] with 1000000 and p=5 with 20 I am getting sigma value 'inf' if I do so...can I know why?
Daniel M
Daniel M am 21 Nov. 2019
Bearbeitet: Daniel M am 21 Nov. 2019
Likely because you're not using the correct values for phi. I don't know what they should be. You cut off the description of the equation. It's likely described in the paper. I get a signal that does not blow up if I set
phi = 0.1 * rand(1,p);
All the values I used in my example were just arbitrarily chosen. You need to figure out the correct usage. Also, you need to decide on the correct implementation when p is greater than n. I chose to incrementally increase p. But the other option, if p = 20, is you start the loop at n = 21, and you have preloaded X with the first 20 elements.
Please consider accepting this answer.
Daniel M
Daniel M am 22 Nov. 2019
Sai I noticed you unaccepted the answer citing it did not work for you. What is not working? This is the code for how to implement that equation. Just because you don't know how to use it does not mean the answer is incorrect.
sai lakshmi
sai lakshmi am 23 Nov. 2019
the values of X are recorded as infinity!
so thought it wouldn't work.
Daniel M
Daniel M am 23 Nov. 2019
Did you not see my response that phi must be << than 1? Did you even try it? It works.

Melden Sie sich an, um zu kommentieren.

sai lakshmi
sai lakshmi am 21 Nov. 2019

0 Stimmen

I have provided the databases at the top of the question as links,please check it once and provide me with the required coding.

Kategorien

Mehr zu Signal Generation, Analysis, and Preprocessing finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 16 Nov. 2019

Kommentiert:

am 23 Nov. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by