Home > eeg > egis > meg_code > meg_power.m

meg_power

PURPOSE ^

SYNOPSIS ^

function power_data = meg_power(ravgcsdm,iavgcsdm,NChan,bad_chan,NReference,noise_flag);

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function power_data = meg_power(ravgcsdm,iavgcsdm,NChan,bad_chan,NReference,noise_flag);
0002 mask = ones(1,NChan);
0003 mask(bad_chan) = zeros(1,size(bad_chan,2));
0004 chpair = channel_pairs(NChan);
0005 if strcmp(noise_flag,'no')
0006     power_data = zeros(size(ravgcsdm,1),NChan);
0007     for ichan = 1:NChan
0008             power_data(:,ichan) = ravgcsdm(:,chpair(ichan,ichan));
0009     end;
0010 
0011     testreal = isreal(sum(power_data));
0012     if testreal ~= 1
0013         error('complex numbers in power array')
0014     end;
0015 else
0016     power_data = zeros(size(ravgcsdm,1),NChan);
0017     for ichan = 149:NChan
0018             power_data(:,ichan) = ravgcsdm(:,chpair(ichan,ichan));
0019     end;
0020 
0021     testreal = isreal(sum(power_data));
0022     if testreal ~= 1
0023         error('complex numbers in power array')
0024     end;
0025     for ichan = 1:148
0026         if mask(ichan)
0027         chan_list = [ichan 149:151];
0028         for ifreq = 1:size(ravgcsdm,1)
0029             for ilist = 1:size(chan_list,2)
0030                 for jlist = 1:size(chan_list,2)
0031                     aug_csdm(ilist,jlist) = ravgcsdm(ifreq,chpair(ilist,jlist))+i*iavgcsdm(ifreq,chpair(ilist,jlist));
0032                     if ilist > jlist
0033                         aug_csdm(ilist,jlist) = conj(aug_csdm(ilist,jlist));
0034                     end;
0035                 end;
0036             end;
0037             gan = det(aug_csdm);
0038             gnn = det(aug_csdm(2:size(aug_csdm,1),2:size(aug_csdm,2)));
0039             cohan = 1 - (gan/(ravgcsdm(ifreq,chpair(ichan,ichan))*gnn));
0040             power_data(ifreq,ichan) = (1-cohan)*ravgcsdm(ifreq,chpair(ichan,ichan));
0041         end;
0042         end;
0043     end;
0044 end;
0045 
0046     
0047

Generated on Sat 25-May-2019 04:00:51 by m2html © 2003