Home > eeg > egis > net_utils > eeg_phase.m

eeg_phase

PURPOSE ^

phase_data= eeg_phase(ravgcsdm,iavgcsdm,output);

SYNOPSIS ^

function phase_data = eeg_phase(ravgcsdm, iavgcsdm,output)

DESCRIPTION ^

phase_data= eeg_phase(ravgcsdm,iavgcsdm,output); 

calculates relative phase 

avgcsdm= cross spectral density matrix
rel_chan = channel for indexing relative phase
output = output type can be 'pha' or 'cos' for raw phase and cosine of phase
  defaults to 'cos' (optional)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function phase_data = eeg_phase(ravgcsdm, iavgcsdm,output)
0002 %phase_data= eeg_phase(ravgcsdm,iavgcsdm,output);
0003 %
0004 %calculates relative phase
0005 %
0006 %avgcsdm= cross spectral density matrix
0007 %rel_chan = channel for indexing relative phase
0008 %output = output type can be 'pha' or 'cos' for raw phase and cosine of phase
0009 %  defaults to 'cos' (optional)
0010 %
0011 if nargin < 2
0012     error('duuh')
0013 end;
0014 if nargin < 3
0015     output = 'cos';
0016 end;
0017 ch_pair_indices;
0018 phase_data = zeros(size(ravgcsdm,1),size(ravgcsdm,2));
0019 if strcmp(output,'cos')
0020     phase_data = ravgcsdm./sqrt(ravgcsdm.^2 + iavgcsdm.^2);
0021 else
0022 %    real_sign = sign(ravgcsdm);
0023     phase_data = atan2(iavgcsdm,ravgcsdm);
0024 %    ang_sign = sign(phase_data);
0025 %    for iph = 1:size(phase_data,1)
0026 %        for jph = size(phase_data,2)
0027 %            if real_sign(iph,jph) < 0
0028 %                phase_data(iph,jph) = phase_data(iph,jph) + pi*real_sign(iph,jph)*ang_sign(iph,jph);
0029 %            end;
0030 %        end;
0031 %    end;
0032 %
0033 end
0034 phase_data(find(isnan(phase_data))) = zeros(size(find(isnan(phase_data))));
0035 testreal = isreal(sum(phase_data));
0036 if testreal ~= 1
0037     error('complex numbers')
0038 end;
0039 
0040

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