0001 function cohmat = coh_from_csdm(csdmdata)
0002
0003
0004
0005
0006
0007
0008
0009
0010 nfreq = size(csdmdata, 1);
0011
0012 if (size(csdmdata,2) ~= (129^2 + 129)/2)
0013 error('Not equiped to handle non 129 channel data')
0014 end
0015
0016 ch_pair_indices
0017 power_indices = diag(chpair);
0018
0019 lower_indices = find(tril(ones(129)));
0020
0021 cohmat = zeros(size(csdmdata));
0022
0023 ncells = size(csdmdata,3);
0024
0025 for icell = 1:ncells
0026 for ifreq = 1:nfreq
0027 datavect = csdmdata(ifreq,:,icell);
0028 powervect = csdmdata(ifreq,power_indices,icell);
0029
0030 cross_power = powervect' * powervect;
0031
0032 cohmat(ifreq,:,icell) = (datavect .* conj(datavect))./cross_power(lower_indices)';
0033 end
0034 end