Home > eeg > egis > scripts > coherence_surface.m

coherence_surface

PURPOSE ^

status =coherence_surface(freqs,obs,array,lines,coherencefname);

SYNOPSIS ^

function status =coherence_surface(freqs,obs,array,lines,coherencefname);

DESCRIPTION ^

status =coherence_surface(freqs,obs,array,lines,coherencefname);

freqs = frequencies to plot, e.g. [3:30] limits the plot to 3 to 30 Hz  
obs = observations in the coherence file to plot (defaults to all)
array = either an array name,e.g., 'all','hemisphere','quadrant','frontback',
    or 'oned' or a list of channels
lines = 'black' or 'color'
coherencefname = coherencefilename (can be gui by skipping this param)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function status =coherence_surface(freqs,obs,array,lines,coherencefname);
0002 %status =coherence_surface(freqs,obs,array,lines,coherencefname);
0003 %
0004 %freqs = frequencies to plot, e.g. [3:30] limits the plot to 3 to 30 Hz
0005 %obs = observations in the coherence file to plot (defaults to all)
0006 %array = either an array name,e.g., 'all','hemisphere','quadrant','frontback',
0007 %    or 'oned' or a list of channels
0008 %lines = 'black' or 'color'
0009 %coherencefname = coherencefilename (can be gui by skipping this param)
0010 %
0011 
0012 if nargin < 5
0013     [fid] = get_fid('rb');
0014 else
0015     fid = fopen(coherencefname,'rb');
0016 end;
0017 version = fread(fid,1,'int16');
0018 if version ~= -2
0019     error('this is not a coherence file');
0020 end;
0021  [nfiles,obs_labels,Epoch,Window_Length,NEpoch,Nbad_chan,bad_chan,ref_flag,reference,NChan,NFreq] = rd_anal_hdr(fid);
0022 frewind(fid);
0023 if nargin == 0
0024     freqs = [0:40];
0025     obs = [1:nfiles];
0026     array = 'all';
0027     lines = 'black';
0028 end;
0029 if nargin == 1
0030     obs = [1:nfiles];
0031     array = 'all';
0032     lines = 'black';
0033 end;        
0034 if nargin == 2
0035     array = 'all';
0036     lines = 'black';
0037 end;    
0038 if nargin == 3
0039     lines = 'black';
0040 end;
0041 if isempty(lines)
0042     lines = 'black';
0043 end
0044 if isempty(array)
0045     array = 'all';
0046 end
0047 if isempty(obs)
0048     obs = [1:nfiles];
0049 end;
0050 if isempty(freqs)
0051     freqs = [0:40];
0052 end;
0053 
0054 ch_pair_indices;
0055 if strcmp(lines,'black')
0056 colorpalette = 'gray';
0057 else    
0058 colorpalette = 'hot';
0059 end;
0060 coherencemax = 1;
0061 iline = 1;
0062 [xelec,yelec,zelec] = electrodes(129);
0063 twod_dist = real(twod_pos(xelec,yelec,zelec,9.2));
0064 if isstr(array)
0065     [arrayg,gnames] = arrays(array,[]);
0066 else
0067     arrayg = array;
0068 end
0069 for g = 1:size(arrayg,1)
0070     for io = 1:size(obs,2)
0071         figure
0072         [npairs, pairs, pairnames] = look_up_pairs(array,g,bad_chan,obs(io));
0073         version = fread(fid,1,'int16');
0074         [nfiles,obs_labels,Epoch,Window_Length,NEpoch,Nbad_chan,bad_chan,ref_flag,reference,NChan,NFreq] = rd_anal_hdr(fid);
0075         coherence_array = real(get_eeg_coherence(fid,freqs,obs(io),nfiles,NChan,NFreq,Epoch));                                
0076         for j = 1:size(freqs,2)        
0077             p_coh = polyfit(twod_dist(pairs),coherence_array(j,pairs),4);
0078             coh_fit(j,:) = real(polyval(p_coh,[0:1:fix(max(twod_dist(pairs)))]));    
0079         end;        
0080         distance = [0:1:fix(max(twod_dist(pairs)))];
0081         surf(distance,freqs,coh_fit), colormap(colorpalette),colorbar
0082         axis([0 max(twod_dist(pairs)) 0 max(freqs) 0 1]);
0083         view(45,30)
0084         ylabel('Frequency(Hz)')
0085         xlabel('Interelectrode Distance (cm)')
0086         zlabel('Coherence')
0087         title([ deblank(setstr(obs_labels(obs(io),:))) ' ' pairnames]);
0088     end
0089 end
0090 
0091 
0092 
0093 
0094 
0095 
0096 
0097 
0098 
0099 
0100 
0101 
0102 
0103 
0104 
0105 
0106 
0107 
0108 
0109 
0110 
0111 
0112 
0113 
0114 
0115 
0116 
0117 
0118

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