function nf =getNoiseFeatures(ecg)

% vector of noise features
nf=0;

%% wavelet based features
% first we are going to estimate the noise level with wavelets
numscales=6;
[C,L]=wavedec(ecg,numscales,'db3');
% first global noise levels from finest details
nf(1)=mad(C(sum(L(1:numscales))+1:sum(L(1:numscales+1))),1);
% and coarser levels
nf(2)=mad(C(sum(L(1:numscales-1))+1:sum(L(1:numscales))),1);
nf(3)=mad(C(sum(L(1:numscales-2))+1:sum(L(1:numscales-1))),1);
nf(4)=mad(C(sum(L(1:numscales-3))+1:sum(L(1:numscales-2))),1);
nf(5)=mad(C(sum(L(1:numscales-4))+1:sum(L(1:numscales-3))),1);
nf(6)=mad(C(sum(L(1:numscales-5))+1:sum(L(1:numscales-4))),1);

[dh,h,cp] = dwtleader(ecg);

nf(7)=cp(1);
nf(8)=cp(2);
nf(9)=cp(3);

%% autocorrelation features
% if the data is not noisy it should exhibit some repetative structure,
% though for arrythmia this repetativeness might be significantly lower
ac=autocorr(ecg,200); % we assume a hearth rythm below 200
nf(10)=max(ac);
nf(11)=quantile(ac,0.95);
nf(12)=quantile(ac,0.9);
acs=sort(ac,'descend');
nf(13)=mean(acs(1:10));

%% Generic features
nf(14)=mad(ecg,1);
nf(15)=var(ecg);

