function [ Y_label  sensitivity specificity accuracy]=pr_classification_MLDA(inputdata,inputlabel)

% *************************************************************************
% This function is used to estimate the performance of MLDA classifier by
% leave-one-out Cross validation.

% Accruracy=(TP+TN)/(TP+FN+TN+FP)
% Sensitivity=TP/(TP+FN);
% Specificity=TN/(TN+FP);
% where TP, FN, TN, and FP denoted the number of patients correctly
% predicted, the number of patients classified as normal controls, the
% number of normal controls correctly predicted and the number of normal
% controls classified as patients, respectively.

% Input:

%         inputdata:  n*m: n is the number of subjects and m is the number of features.

%         inputlabel: n*1, the label corresponding the inputdate.

% Output:

%         Y_label: predicting the label of all inputdata.

%         sensitivity:  the classification sensitivity.

%         specificity:  the classification specificity.

%         accuracy:  the classification accuracy.

% Written by Zhengjia Dai, State Key Laboratory of Cognitive Neuroscience
% and Learning, Beijing Normal University, Beijing, P.R.China, 100875. 
% Contact information:
% Zhengjia Dai: daizhengjia13@gmail.com
% Yong He : yong.h.he@gmail.com; yong.he@bnu.edu.cn
% September 24th,2011
% *************************************************************************



[num_sub num_feature]=size(inputdata);

Y_label=zeros(num_sub,1);


for j=1:num_sub

    % dividing the inputdat into taining data and testing data.
    data11=inputdata;
    label11=inputlabel;
    test_learningdata=data11(j,:);
    test_learninglabel=label11(j,1);
    data11(j,:)=[];
    label11(j)=[];
    learningdata=data11;
    learninglabel=label11;

    % feature selection
    [ select_train select_test index1 ]=pr_feature_select(learningdata, learninglabel,test_learningdata);

    % traning MLDA classifier.
    [ w_fda threshold m1_lda m2_lda Y_latent_train ]=pr_MLDA(select_train,learninglabel);

    % predicting the label of testing data
    [ TestResult Y_latent_test]=pr_test_MLDA(select_test,w_fda ,threshold, m1_lda ,m2_lda );
    Y_label(j,1)=TestResult;


end

% estimating the performance of MLDA classifier
sensitivity=size(find((Y_label==-1)&(inputlabel==-1)),1)/size(find(inputlabel==-1),1);
specificity=size(find((Y_label==1)&(inputlabel==1)),1)/size(find(inputlabel==1),1);
accuracy=size(find(Y_label==inputlabel),1)/num_sub;
