function featuresMeans2=calculateFeaturesMean(cecg,QRSTrain)
stepp=75;
partECG=zeros(length(QRSTrain),stepp*2+1);
for kq=1:length(QRSTrain)
    remLeft=[];
    if QRSTrain(kq)<=stepp
        remLeft=zeros(1,abs(QRSTrain(kq)-stepp)+1);
    end
    
    remRight=[];
    if QRSTrain(kq)+stepp>length(cecg)
        remRight=zeros(1,QRSTrain(kq)+stepp-length(cecg));
    end
    pp=cecg(max(1,QRSTrain(kq)-stepp):min(QRSTrain(kq)+stepp,end));pp=pp(:)';
    partECG(kq,:)=[remLeft,pp,remRight];
end
for kq=1:length(QRSTrain)
    partECG(kq,:)=partECG(kq,:)-mean(partECG(kq,:));
    if cecg(QRSTrain(kq))<=cecg(max(1,QRSTrain(kq)-1)) && cecg(QRSTrain(kq))<=cecg(min(end,QRSTrain(kq)+1))
        partECG(kq,:)=-partECG(kq,:);
    end
end

featuresMeans=median(partECG(:,:));
lbpCounts=computeLBPsignal(featuresMeans);

[pev,pel]=findpeaks(featuresMeans(1:70));
if isempty(pev)
    pev=0;pel=0;
end
featuresMeansPPl=[length(pel),mean(pel),mean(pev),max(pev)-min(pev)];
[pev1,pel1]=findpeaks(featuresMeans(80:151));
if isempty(pev1)
    pev1=0;pel1=0;
end
featuresMeansPPr=[length(pel1),mean(pel1),mean(pev1),max(pev1)-min(pev1),max(pev)-max(pev1)];
[pev,pel]=findpeaks(-featuresMeans(1:70));
if isempty(pev)
    pev=0;pel=0;
end
featuresMeansNPl=[length(pel),mean(pel),mean(pev),max(pev)-min(pev)];
[pev1,pel1]=findpeaks(-featuresMeans(80:151));
if isempty(pev1)
    pev1=0;pel1=0;
end
featuresMeansNPr=[length(pel1),mean(pel1),mean(pev1),max(pev1)-min(pev1),max(pev)-max(pev1)];
[pev,pel]=findpeaks(featuresMeans(61:90));
if isempty(pev)
    pev=0;pel=0;
end
featuresMeansNPm=[length(pel),mean(pel),mean(pev),max(pev)-min(pev)];
[pev1,pel1]=findpeaks(-featuresMeans(61:90));
if isempty(pev1)
    pev1=0;pel1=0;
end
featuresMeans2=[featuresMeans,lbpCounts,featuresMeansPPl,featuresMeansNPl,featuresMeansPPr,featuresMeansNPr];
