function [pred_label,pred_value,ind_value]=svm_manifold_predict(testing_com, training_com, training_label, list, sigma, gama, model) %get the number of subjects [tt_n,m,v]=size(testing_com); [tr_n,m,v]=size(training_com); %get the number of components of each individual m=length(list); %normalizing for i=1:tt_n if(m==1) tmp=(squeeze(testing_com(i,list,:))); tt_ncom(i,:)=tmp*(tmp'*tmp)^(-1/2); else tmp=(squeeze(testing_com(i,list,:)))'; tt_ncom(i,:,:)=tmp*(tmp'*tmp)^(-1/2); end end for i=1:tr_n if(m==1) tmp=(squeeze(training_com(i,list,:))); tr_ncom(i,:)=tmp*(tmp'*tmp)^(-1/2); else tmp=(squeeze(training_com(i,list,:)))'; tr_ncom(i,:,:)=tmp*(tmp'*tmp)^(-1/2); end end %size(tt_ncom) %size(tr_ncom) %computing the distance between testing and training components dist=zeros(tt_n,tr_n); for i=1:tt_n for j=1:tr_n if(m==1) s=svd(tt_ncom(i,:)*tr_ncom(j,:)'); else s=svd(squeeze(tt_ncom(i,:,:))'*squeeze(tr_ncom(j,:,:))); end dist(i,j)=sum(s(:).^2)/m; %dist(i,j)=real(sqrt(m-sum(s(:).^2))); %dist(i,j)=real(sqrt(sum(s(:).^2)/m)); end end kernel_=tanh(gama.*dist+sigma); for i=1:tt_n test_list=i; for j=1:tr_n [tpred(j), accuracy_P, dec_values_P] = svmpredict(1, [i, kernel_(test_list,:)], model{j},'-b 1'); [tmp,idx]=max(dec_values_P); tdec_values_P(j)=max(dec_values_P)*model{j}.Label(idx); end ind_value(i,:)=tdec_values_P(:)'; pred_value(i)=median(tdec_values_P); pred_label(i)=sign(pred_value(i)); if(pred_value(i)==0) pred_label(i)=1; end end pred_label=pred_label(:); pred_value=pred_value(:);