function [plitr pli]=pli_hilbert_trials(filtered1,filtered2) %INPUT:filtered1,2 = trials x n where n = number of samples %signals should be filtered %OUTPUT:plitr = keeps the PLI values for each trial % pli = average PLI value across trials %LACHAUX et al.1999 %STAVROS DIMITRIADIS 4/2007 %http://users.auth.gr/stdimitr/ hilbert1=hilbert(filtered1); hilbert2=hilbert(filtered2); [trials len]=size(hilbert1); phase1=angle(hilbert1); phase2=angle(hilbert2); unwrap1=unwrap(phase1); unwrap2=unwrap(phase2); value=0; plitr=0; pli=0; for tr=1:trials pl=0; for k=1:len value=(exp(i*(unwrap1(tr,k)-unwrap2(tr,k)))); pl=pl + value; end plitr(tr)=abs(pl)/len; end pli=mean(plitr);