function featVec=challenge_features_0(recordName)

featVec = zeros(1,20);

[~,signal,Fs,~]=rdmat(recordName);

[QRS,~,~] = qrs_detect2(signal',0.25,0.6,Fs);

tmp = 0;
cnt = 0;

for i=1:size(QRS,2)
    try 
        tmp = tmp + signal(QRS(i)-60:QRS(i)+200);
        cnt = cnt + 1;
    catch
    end
end
lindec = [ones(1,160) (100:-1:0)./100];
%featVec_raw = tmp.*lindec'./(cnt + eps);
featVec_raw = tmp.*lindec'./(rms(tmp) + eps);

load('SVD_data','U','DATA_MEAN');

featVecSVD = (featVec_raw'-DATA_MEAN) * U(:,1:20);


%featVec(1,19)  = size(QRS,2)./size(signal,1);   
featVec(1,19)  = mean(diff(QRS));
featVec(1,20)  = std(diff(QRS));
if isnan(featVec(1,19))
    featVec(1,19) = 300;
end
if isnan(featVec(1,20))
    featVec(1,20) = 150;
end

signal(isnan(signal)) = 0;

sig_std  = std(diff(zscore(signal)));
sig_kurt = kurtosis(diff(zscore(signal)));

% Resample signal to 100Hz
Fs=Fs(1);
if Fs~=100
    signal=resample(signal,100,Fs);
    Fs=100;
end

hopsize = 8;

%Define interval search window
win = 0.3*Fs:2.0*Fs;

%Filter with [0.5 30] Hz band-pass
[b,a] = butter(2,[1 30]/(Fs/2));
signal = filtfilt(b, a, signal);

%Apply zscore to each channel
signal = zscore(signal);

indx = 1;
%prob_arr    = zeros(length(win(end)+1:hopsize:size(signal,1)-win(end)),size(win,2));
interv_arr  = zeros(length(win(end)+1:hopsize:size(signal,1)-win(end)),1);
quality_arr = zeros(length(win(end)+1:hopsize:size(signal,1)-win(end)),1);

for l = win(end)+1:hopsize:size(signal,1)-win(end)
     win_sig = signal((l-win(end)):(l+win(end)),:);
     %prob_arr(indx,:) = prod(prob_estimator(win_sig, win),1);     
     [est_len, quality]  = single_interval_estimator(win_sig, win);
     interv_arr(indx,1)  = est_len(1);
     quality_arr(indx,1) = quality(1);
     indx = indx + 1;
end

%interv_arr = medfilt1(interv_arr,5);



tmp = hist(interv_arr,30:20:180);
tmp = tmp ./ mean(tmp);
featVec(1,1:8) = tmp;

featVec(1, 9)  = mean(quality_arr);    
featVec(1,10)  = median(quality_arr);    
featVec(1,11)  = std(quality_arr);

featVec(1,12)  = mean(interv_arr);    
featVec(1,13)  = std(interv_arr);
featVec(1,14)  = mean(abs(diff(interv_arr)));
featVec(1,15)  = kurtosis(interv_arr);    
featVec(1,16)  = std(diff(interv_arr));

featVec(1,17)  = sig_std;    
featVec(1,18)  = sig_kurt;

featVec = [featVec featVecSVD];

end
