0001 function [fwsm_mat] = eeg_fwsm(csdm_data,good_chan,chan_pos,freqs,k_range); 0002 0003 ch_pair_indices 0004 0005 fwsm_mat = zeros(size(freqs,2),size(k_range,2)); 0006 NChan = 129; 0007 for if = 1:size(freqs,2) 0008 0009 csdm_mat = zeros(129,129); 0010 csdm = zeros(size(good_chan,2),size(good_chan,2)); 0011 for ichan =1:NChan 0012 for jchan = ichan:NChan; 0013 csdm_mat(ichan,jchan) = csdm_data(freqs(if),chpair(ichan,jchan)); 0014 csdm_mat(jchan,ichan) = conj(csdm_mat(ichan,jchan)); 0015 end; 0016 end; 0017 0018 csdm = csdm_mat(good_chan,good_chan); 0019 0020 for j = 1:size(k_range,2) 0021 for k = 1:size(good_chan,2) 0022 for l = 1:size(good_chan,2) 0023 kvec(k,l) = exp(i*k_range(j)*(chan_pos(l)-chan_pos(k))); 0024 0025 end; 0026 end; 0027 0028 power = csdm.*kvec; 0029 fwsm_mat(if,j) = real(sum(sum(power))/(size(good_chan,2).^2)); 0030 end; 0031 end;