function label = challenge(recordName)

label = 'N';

[tm,ecg,fsOrg,siginfo]=rdmat(recordName);

td = find(tm<=1);
fsOrg = length(td)-1;
fs = 300;

% === Get ECG signal ===
[ecgSig, ecgSig_org, blsig] = getECGsig_normalized(ecg, fsOrg);
    
    blCorrected = ecgSig_org-blsig;
    blmask = BLWmask(blsig, 0.4);    
    
[Rpeaks, ann_res, res] = getECG_Rpeaks(ecgSig);

[zI_ecg, zLoc_ecg, erId_ecg, errLoc_ecg] = err_zrs(res, 5);

vid = zLoc_ecg.*errLoc_ecg;
%% Mask correction
validMask = ValidMaskGen(ecgSig, Rpeaks, vid);
VM = validMask.*zLoc_ecg.*blmask;
% %%
%% Check signal direction and morphology

lead_direction = getLeadDirection(ecgSig, ann_res);
ecgSig = lead_direction*ecgSig;

%     %% AFIB detection


%%  Other signal detection based on PVCs

if(sum(VM)<0.4*length(VM))
    label = '~'
    return
end


% %% Other signal detection based on QRS durtatioN

 RpeaksVM = Rpeaks.*VM;
 %NC = 30;
 SC = 7;
 
 if(sum(RpeaksVM)<7)
    label = '~'
    return
 end

 if(length(ecgSig)<6000)
     
    [ChunkStack] = genChunks_SeqN(ecgSig, RpeaksVM, SC);
    
        load('Itr2_CNN_params_First500_fil_10_filDim_100.mat');
             
    if(numel(ChunkStack)==0)
        label = '~';
        return
    end

    [cost, grad, preds] = cnnCost_MC(opttheta,ChunkStack,[],numClasses,...
        filterDimX,filterDimY,numFilters,poolDim,'True');
    
    testLab = mode(preds);
    
    lab = ['N', 'A', 'O', '~'];
    label = lab(testLab);
    return
 end
 
  [ChunkStack] = genChunksTest_Seq(ecgSig, RpeaksVM, SC);
    
    if(numel(ChunkStack)==0)
        label = '~';
        return
    end
    
    load('Itr1_CNN_SigAO_params_3_filDim_100.mat')
    
    [cost, grad, preds] = cnnCost_MC(opttheta,ChunkStack,[],numClasses,...
        filterDimX,filterDimY,numFilters,poolDim,'True');
    
    testLab = mode(preds);
    
    lab = ['A', 'O'];
    label = lab(testLab);
    
    if(label == 'A')
    load('CNN_SigAN_params_3_filDim_100.mat')
        
        [cost, grad, preds] = cnnCost_MC(opttheta,ChunkStack,[],numClasses,...
            filterDimX,filterDimY,numFilters,poolDim,'True');
        
        testLab = mode(preds);
        
        lab = ['A', 'N'];
        label = lab(testLab);
        if(label == 'A')
            return
        end
    end
    
    load('Itr1_CNN_SigAO_params_3_filDim_100.mat')
    
    [cost, grad, preds] = cnnCost_MC(opttheta,ChunkStack,[],numClasses,...
            filterDimX,filterDimY,numFilters,poolDim,'True');
        
        testLab = mode(preds);
        
        lab = ['A', 'N'];
        label = lab(testLab);
        if(label == 'A')
            return
        end

    load('CNN_SigNO_params_3_filDim_200')
    [cost, grad, preds] = cnnCost_MC(opttheta,ChunkStack,[],numClasses,...
            filterDimX,filterDimY,numFilters,poolDim,'True');
        
        testLab = mode(preds);
        
        lab = ['O', 'N'];
        label = lab(testLab);
    
end


