function [classifyResult,QRS,ecg,AFEv,RR,qrs_amp_raw,QRSa,ATEv,OrgIdx,OriginCount,IrrEv,PACEv] = challengeECG(ecg)
classifyResult = 0; % default output normal rhythm
fs=300;
% [QRS,sign,en_thres] = qrs_detect2(ecg',0.25,0.6,fs);
% [~,QRS] = pt(ecg',fs);
% QRS=findBestQRSnewPD(ecg);
QRS=findBestQRSnewPD(ecg);
QRS=QRS(:)';

% QRS11=findBestQRSnew(ecg);
% QRS11
qrs_amp_raw=ecg(QRS);
QRSa=QRS;
AFEv=0;OriginCount=0;IrrEv=0;PACEv=0;
ATEv=0;OrgIdx=0;

if length(QRS)<6
    RR=diff(QRS')/fs;
    AFEv =0;ATEv=0;OrgIdx=0;
    IrrEv=0;PACEv=0;OriginCount=0;
else
    RR=diff(QRS')/fs;
    [AFEv,ATEv,OrgIdx,OriginCount,IrrEv,PACEv] = comput_AFEv(RR);
    if AFEv>1
        classifyResult = 1;
    end
end