low-pass filtering a signal within a range determined by signal amplitude
1 view (last 30 days)
I have this problem (see the picture attached). The baseline is noisy, so I have applied a lowpass filter (1 Hz, y=lowpass(I_P,1,6250). The data looks amazing but the spikes are smaller (of course, because I applied a low-pass filter).
So, in short, I want to apply the same low-pass filter (1Hz) exclusively to the baseline, i.e. from -10 pA to + 50 pA, so that the data baseline is improved signal-wise, and the spike amplitude remains untouchable (keeping the real amplitude).
The signal inside the green box is the data I want to filter. The signal inside the red box is the data I do not want to filter.
Mathieu NOE on 15 Dec 2020
so this is a little code snipset, it uses a windowing technique as low pass filter
the peaks are left as original
you can leave the peks very sharp (one point) or wider if you leave the following line active :
hope it helps !!
%% signal generation
signal = 10*randn(1,samples); % noise
% add some peaks (must NOT be filtered)
signal(100) = 400;
signal(200) = 300;
signal(300) = 200;
signal = myslidingavg(signal, 5); % just a trick to make the peaks a bit wider (optionnal)
%% main code
% sliding avg method
threshold = max(abs(signal))/4;
ind = find(signal< threshold);
out = myslidingavg(signal(ind), 100);
signal_out = signal;
signal_out(ind) = out;