Home > eeg > egis > meg_code > make_meg_power.m

make_meg_power

PURPOSE ^

status = make_meg_power(csdmfname,powerfname,obs_labels,noise_reduction);

SYNOPSIS ^

function status = make_meg_power(csdmfname,powerfname,obs_labels,noise_flag);

DESCRIPTION ^

status = make_meg_power(csdmfname,powerfname,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 power 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_power(csdmfname,powerfname,obs_labels,noise_flag);
0002 %status = make_meg_power(csdmfname,powerfname,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 power 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(powerfname,'wb');
0032 pversion = -2;
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     power_data = meg_power(ravgcsdm,iavgcsdm,all_NChan(i),all_bad_chan(i,1:NBad_chan(i)),NReference(i),noise_flag);
0040     fwrite(pfid,power_data','real*4');
0041 end;
0042 
0043 fclose('all')
0044 status = 1;
0045     
0046 
0047 
0048 
0049 
0050 
0051 
0052

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