classdef TFCEobjT.TFCE; NegCount=NegCount+squeeze(T.STFCE(:,:,k))T.TFCE; NegCount=NegCount+squeeze(T.STFCE(:,:))h); % find beta > h and get clusters %all numbers belonging to cluster 1 get a 1, to cluster 2 a 2 etc. if n==0; else ind=1:numel(L); S=sparse(L(logical(L)),ind(logical(L)),1); % a bit of a trick, but it seems to work :-) E=sum(repmat(diag(S*transpose(S)),1,size(S,2)).*S); %#ok TFCEtmp(logical(E))=TFCEtmp(logical(E))+E(logical(E)).^T.E*h.^T.H; %#ok % get tfce value by tfce=tfce_h(-1)+h^ch*e^ce per voxel end %% negative part [L2,n2]=bwlabel(I<-h); if n2==0; else ind=1:numel(L2); S=sparse(L2(logical(L2)),ind(logical(L2)),1); % a bit of a trick, but it seems to work :-) E2=sum(repmat(diag(S*transpose(S)),1,size(S,2)).*S); TFCEtmp(logical(E2))=TFCEtmp(logical(E2))-E2(logical(E2)).^T.E*h.^T.H; % get tfce value by tfce=tfce_h(-1)+h^ch*e^ce per voxel end end end end end