function [ TTalpha, PTP, Lambda,D] = Sparsityreg( NL_mat, Self_arr, Sigma_arr, Pat_g_hat, Par, Pat_f ,Lambda)

        TTalpha = zeros(size(Pat_g_hat));
        
        PTP    = zeros(size(Pat_g_hat));
        J=length(Self_arr);
        D=zeros(Par.patsize*Par.patsize,J);
        for  j      =  1 : J                               % For each patch group
            Pjg_hat    =   Pat_g_hat(:, NL_mat(1:Par.patnum,j));                  % P^{j}g_hat       
            Pjf= Pat_f(:, NL_mat(1:Par.patnum,j));
            muj=Par.coe*Par.patnum*Sigma_arr(Self_arr(j))^2*(1+Par.eta);
            Thresh=sqrt(2*muj/(1+Par.eta));
            [TTalpha_j,alpha_j,Tjf,TTLambda_j,D(:,j)]=   LocalSVD( Pjg_hat,Thresh,Pjf,Lambda(:,:,j),Par); 
            TTalpha(:,NL_mat(1:Par.patnum,j))  = TTalpha(:,NL_mat(1:Par.patnum,j))+TTalpha_j-TTLambda_j;      
            PTP(:,NL_mat(1:Par.patnum,j))     = PTP(:,NL_mat(1:Par.patnum,j))+ones(Par.patsize*Par.patsize,size(NL_mat(1:Par.patnum,j),1));
             Lambda(:,:,j)     = Lambda(:,:,j) +Par.delta*(Tjf-alpha_j);   % updating lambda_j
        end


