Home > eeg > egis > net_utils > eeg_coherence.m

eeg_coherence

PURPOSE ^

avg_coherence = eeg_coherence(ravgcsdm,iavgcsdm,bad_chan);

SYNOPSIS ^

function avg_coherence = eeg_coherence(ravgcsdm,iavgcsdm,bad_chan);

DESCRIPTION ^

avg_coherence = eeg_coherence(ravgcsdm,iavgcsdm,bad_chan);

avgcsdm= average cross spectral density matrix
bad_chan = bad_channels (optional)
avg_coherence = coherence matrix

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function avg_coherence = eeg_coherence(ravgcsdm,iavgcsdm,bad_chan);
0002 %avg_coherence = eeg_coherence(ravgcsdm,iavgcsdm,bad_chan);
0003 %
0004 %avgcsdm= average cross spectral density matrix
0005 %bad_chan = bad_channels (optional)
0006 %avg_coherence = coherence matrix
0007 %
0008 if nargin < 2
0009     error('you missing either the real or the imaginary part');
0010 end;
0011 if nargin == 2
0012     bad_chan = [];
0013 end;
0014 if size(ravgcsdm,2) == 8385
0015     NChan = 129;
0016 else
0017     error('unknown number of channels');
0018 end;
0019 mask = ones(1,NChan);
0020 mask(bad_chan) = zeros(1,size(bad_chan,2));
0021 good_chan = find(mask);
0022 ch_pair_indices;
0023 
0024 avg_coherence = zeros(size(ravgcsdm,1),size(ravgcsdm,2));
0025 
0026 for i = 1:size(good_chan,2)
0027     for j = i:size(good_chan,2)
0028         avg_coherence(:,chpair(good_chan(i),good_chan(j)))= ((ravgcsdm(:,chpair(good_chan(i),good_chan(j))).^2)+(iavgcsdm(:,chpair(good_chan(i),good_chan(j))).^2))./ravgcsdm(:,chpair(good_chan(i),good_chan(i)))./ravgcsdm(:,chpair(good_chan(j),good_chan(j)));
0029     end;
0030 end;
0031 
0032 avg_coherence(find(isnan(avg_coherence))) = zeros(size(find(isnan(avg_coherence))));
0033

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003