replacespikeenvelope#
[xDespiked, Indx] = replacespikeenvelope(x, lowbound, upbound, nrpeat, interpMethod, dispout)
Description#
Remove spikes in the time series that are outside a defined envelope
Inputs#
- x
Input data
- lowbound
Lower boundary of the data, all data points should be larger than that
- upbound
Upper boundary of the data, all data points should be smaller than that
- nrpeat=1;
Number of time despiking procedure is repeating
- interpMethod=’linear’;
- Interpolation method for replacing spike points:Matlab/Octave: ‘linear’, ‘nearest’, ‘next’, ‘previous’, ‘pchip’, ‘cubic’, ‘spline’Python/Scipy : ‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’
- dispout=’no’;
Define to display outputs or not (‘yes’: display, ‘no’: not display)
Outputs#
- xDespiked
Dispiked data
- Indx
Index of despiked points
Examples#
fs=128;
t(:,1)=linspace(0,9.5,10*fs);
x(:,1)=sin(2*pi*0.3*t)+0.1*sin(2*pi*4*t);
x(220:225,1)=1.5;
x=x+5;
[xDespiked,Indx]=replacespikeenvelope(x,3.9,6.1,1,'linear','yes');
fs=2;
t(:,1)=linspace(0,1023.5,1024*fs);
x(:,1)=detrend(0.5.*cos(2*pi*0.2*t)+(-0.1+(0.1-(-0.1))).*rand(1024*fs,1));
spikeloc(:,1)=[10:100:length(t(:,1))];
x(spikeloc+round(2*randn(length(spikeloc(:,1)),1)),1)=sign(randn(length(spikeloc(:,1)),1));
[xDespiked,Indx]=replacespikeenvelope(x,-0.6,0.6,1,'linear','yes');