function [ID] = JCRDF (BlkD,Proj,Y_task, X_task,group_index_task,weight,tau)

trls     = group_index_task{1};
uni_trls = unique(trls);
for bi = 1:size(X_task,1)
    os(:,bi) = BlkD(bi).P*Y_task{bi};
end 
for bi = 1:size(X_task,1)
    s(:,bi) = os(:,bi)+tau*weight(bi)/sum(weight)*Proj(bi).P*(os*weight');
end

gap = zeros(1,size(uni_trls,2));
for w_tem = 1:size(X_task,1)
    for ind  =  1:size(uni_trls,2)
        sc        =  s(:,w_tem);
        indClass  =  uni_trls(ind);
        temp_s    =  sc(indClass==trls);
        zz        =  Y_task{bi}-X_task{bi}(:,indClass==trls)*temp_s;
        gap(ind)  =  gap(ind)+weight(w_tem)*zz(:)'*zz(:);      
    end
 end
    
 index = find(gap==min(gap));
 ID    = uni_trls(index(1));