Home > eeg > egis > meg_code > make_meg_coherence.m

make_meg_coherence

PURPOSE ^

status = make_meg_coherence(csdmfname,coherencefname,obs_labels,noise_reduction);

SYNOPSIS ^

function status = make_meg_coherence(csdmfname,coherencefname,obs_labels,noise_flag);

DESCRIPTION ^

status = make_meg_coherence(csdmfname,coherencefname,obs_labels,noise_reduction);

csdmfname = matrix of csdmfilenames
obs_labels = labels for the csdm matrices
noise_flag = 'yes' or 'no'
     if yes the reference channels are used, and the mutiple 
    coherence between reference channels and each sensor is 
    calculated.  This tells us the proportion of the coherence spectrum
    due to the noise. We then remove this. See Bandat and Piersol, 1986

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function status = make_meg_coherence(csdmfname,coherencefname,obs_labels,noise_flag);
0002 %status = make_meg_coherence(csdmfname,coherencefname,obs_labels,noise_reduction);
0003 %
0004 %csdmfname = matrix of csdmfilenames
0005 %obs_labels = labels for the csdm matrices
0006 %noise_flag = 'yes' or 'no'
0007 %     if yes the reference channels are used, and the mutiple
0008 %    coherence between reference channels and each sensor is
0009 %    calculated.  This tells us the proportion of the coherence spectrum
0010 %    due to the noise. We then remove this. See Bandat and Piersol, 1986
0011 %
0012 
0013 if nargin < 3
0014     error('not enough input arguments');
0015 end;
0016 
0017 if nargin == 3
0018     noise_flag = 'yes';
0019 end;
0020 
0021 if isempty(obs_labels)
0022     obs_labels = csdmfname;
0023 end;
0024 all_bad_chan = zeros(size(csdmfname,1),100);
0025 for i = 1:size(csdmfname,1)
0026     [version, NChan_file,NMeg(i),NReference(i),NEeg(i),NAnalog(i),NBad_chan(i),bad_chan,NEpoch(i),Epoch(i),nfreq(i)] = rd_meg_csdm_hdr(csdmfname(i,:));
0027     all_bad_chan(i,1:NBad_chan(i)) = bad_chan;
0028     all_NChan(i) = 148+NReference(i)+NEeg(i) +NAnalog(i);
0029 end;
0030 
0031 pfid = fopen(coherencefname,'wb');
0032 pversion = -3;
0033 nfile = size(csdmfname,1);
0034 status = wt_meg_anal_hdr(pfid,pversion,nfile,all_NChan,NMeg,NReference,NEeg,NAnalog,NBad_chan,all_bad_chan,NEpoch,Epoch,nfreq,obs_labels);
0035 
0036 
0037 for i = 1:nfile
0038     [ravgcsdm,iavgcsdm] = rd_meg_csdm(csdmfname(i,:));
0039     coherence_data = meg_coherence(ravgcsdm,iavgcsdm,all_NChan(i),all_bad_chan(i,1:NBad_chan(i)),NReference(i),noise_flag);
0040     fwrite(pfid,coherence_data','real*4');
0041 end;
0042 
0043 fclose('all')
0044 status = 1;
0045     
0046 
0047 
0048 
0049

Generated on Tue 16-Jul-2019 04:00:51 by m2html © 2003