# Reintroducing Noise to a Spliced Signal

2 visualizaciones (últimos 30 días)
Manash Sahoo el 1 de Dic. de 2020
Hi everyone! I'm running into an issue and I can't figure it out for the life of me.
Some background: I am trying to analyze some ECG data. I've got a binary matrix in which the 1s represent detected heartbeats. I convolve through this binary matrix with a gaussian filter to find the heart-rate.
However, there's some noise in the data. We would just replace the noise with NaN's in the binary matrix, but that would produce edge effects (since no data is flowing during NaN segments).
So our new plan is to completely cut out the noisy segments, and run the convolution on that truncated binary matrix, and then reintroduce the noise. However, I'm unsure on how to reintroduce the noise to the array, as the indices of the noise change since the signal is now smaller.
Apologies if the explanation is vague. Let me know if i can clarify. However, here is the code (somewhat messy):
pcs=[];
hrpcs=[];
c=1;
for seg=1:floor(sesLen/5)
pcs(seg,:) = dum(c:c+750);
hrpcs(seg,:) = fHrt(c:c+750);
tpcs(seg,:) = rFTim(c:c+750);
c=c+750;
end
testt = rFTim; %this is the time-values for the time series
testhrt = fHrt; % these are the Y axis values for the ECG data
nandummy = zeros(size(rFTim,2),1);
dum2 = dum; % dum is the original binary matrix with heartbeats as 1
slct_intv = [];
slct_intv_t = [];
fixhrt = fHrt;
fixt = rFTim;
%display a 5 sec piece of data
f = figure;
for seg = 1:size(pcs,1)
hold on
l = tpcs(seg,:);
p = plot(tpcs(seg,:),hrpcs(seg,:));
pk = plot(l(logical(pcs(seg,:))),zeros(size(l(logical(pcs(seg,:))),2),1),'ro');
%wait for button press, if mouseclick then go to ginput(), if keyboard
w = waitforbuttonpress;
if w == 1
elseif w==0
%get cursor coords
[x1,y1] = ginput(1);
[x2,y2] = ginput(1);
%get nearest value
[m1,i1] = min(abs(rFTim - x1));
[m2,i2] = min(abs(rFTim - x2));
%Get next nearest heartbeat
for i = i2:size(rFTim,2)
if dum(i) == 1
lstbeat = i;
break
end
end
%reset i to lower limit
i = i1;
% get last nearest heartbeat
while i >= 1
if dum(i) == 1
frstbeat = i;
break
end
i = i - 1;
end
% edit dummy data
nandummy(frstbeat+1:lstbeat) = NaN;
lstbeat_time = testt(lstbeat);
frstbeat_time = testt(frstbeat);
slct_intv = vertcat(slct_intv,[frstbeat lstbeat]);
slct_intv_t = vertcat(slct_intv_t,[frstbeat_time lstbeat_time]);
% Remove selected data
testt(frstbeat+1:end) = testt(frstbeat+1:end) - (lstbeat_time - frstbeat_time);
testhrt(frstbeat+1:lstbeat) = [];
testt(frstbeat+1:lstbeat) = [];
dum2(frstbeat+1:lstbeat) = [];
end
cla(f);
end
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Spectral Estimation en Help Center y File Exchange.

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by