I have tried the BEADS technique we have developed for the separation of
- sparse signals, possibly positive, with sparse derivatives,
- a trend (low frequency),
- random noise.
I have played with one signal for about two minutes, and here is one outcome:
It is called BEADS, for "Baseline Estimation And Denoising with Sparsity". The Matlab BEADS code is at MatlabCentral, the paper is Chromatogram baseline estimation and denoising using sparsity (BEADS). It was initially meant for chromatographic signals, but is also used for EEG/ECG and several other spectral signal, see the BEADS page .
One nice feature is that you directly see the noise (and how uncorrelated it can be) and the shape of the trend, then tweak the parameters. Mine (probably not optimal) are:
addpath('C:\Users\duvall\Documents\MATLAB\toolbox\2014_BEADS_Baseline\');
% load('s0010_rem.mat')
data = val(1,:)';
% Filter parameters
fc = 0.004; % fc : cut-off frequency (cycles/sample)
d = 1; % d : filter order parameter (d = 1 or 2)
% Positivity bias (peaks are mostly symmetric)
r = 1; % r : asymmetry parameter
% Regularization parameters
amp = 0.8;
lam0 = 0.5*amp;
lam1 = 5*amp;
lam2 = 4*amp;
[x1, f1, cost] = beads(data, d, fc, r, lam0, lam1, lam2);
figure(2);
subplot(4,1,1)
h=plot([data]);axis tight;grid on;set(h,'LineWidth',2);
subplot(4,1,2)
h=plot([x1]);axis tight;grid on;set(h,'LineWidth',2);
subplot(4,1,3)
h=plot([f1]);axis tight;grid on;set(h,'LineWidth',2);
subplot(4,1,4)
h=plot([data-x1-f1]);axis tight;grid on;set(h,'LineWidth',2);
Basically, it took me 10-times more to download and load the signal than to tune the parameters (90 seconds approximately), but I know the code :)