0001 function [fwsm_mat] = eeg_2dfwsm(csdm_data,good_chan,freq,k_range);
0002
0003 ch_pair_indices
0004
0005 fwsm_mat = zeros(size(k_range,2),size(k_range,2));
0006 NChan = 129;
0007
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(freq,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 [x,y,z] = electrodes(129);
0020 elec = xyz2tp(x,y,z);
0021 cchan_pos(:,1) = 9.2*elec(:,1);
0022 cchan_pos(:,2) = 9.2*elec(:,2);
0023 chan_pos = cchan_pos(good_chan,:);
0024 for c = 1:size(k_range,2)
0025 for j = 1:size(k_range,2)
0026 kvec1 = exp(i*k_range(j)*(ones(size(good_chan,2),1)*chan_pos(:,2)'-chan_pos(:,2)*ones(1,size(good_chan,2))));
0027 kvec2 = exp(i*k_range(c)*(ones(size(good_chan,2),1)*chan_pos(:,1)'-chan_pos(:,1)*ones(1,size(good_chan,2))));
0028 kvec = kvec1.*kvec2;
0029
0030
0031
0032
0033
0034
0035
0036 power = csdm.*kvec;
0037 fwsm_mat(c,j) = real(sum(sum(power))/(size(good_chan,2).^2));
0038 end;
0039 end;
0040
0041
0042
0043
0044
0045
0046