Home > eeg > egis > scripts > bar_eeg_power.m

bar_eeg_power

PURPOSE ^

status =bar_eeg_power(freqs,obs,chans,base_obs,lines,power_type,powerfname)

SYNOPSIS ^

function status = bar_eeg_power(freqs,obs,chans,base_obs,lines,power_type,powerfname);

DESCRIPTION ^

status =bar_eeg_power(freqs,obs,chans,base_obs,lines,power_type,powerfname)

freqs = list of freqs, e.g. [3 30] limits the plot to 3 to 30 Hz  
obs = observations in the power file corresponding to freqs
note: nfreqs == nobs
chans = channels to plot; channel list separatedby a semicolon will be
averaged together .  standard array names can be used.  
base_obs = observation to plot at each freq under freqs asa line graph.  
lines = 'black' or 'color'
power_type = can be either 'power', 'amplitude', or 'logpower'
powerfname = powerfilename (can be gui by skipping or passing a blank)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function status = bar_eeg_power(freqs,obs,chans,base_obs,lines,power_type,powerfname);
0002 %status =bar_eeg_power(freqs,obs,chans,base_obs,lines,power_type,powerfname)
0003 %
0004 %freqs = list of freqs, e.g. [3 30] limits the plot to 3 to 30 Hz
0005 %obs = observations in the power file corresponding to freqs
0006 %note: nfreqs == nobs
0007 %chans = channels to plot; channel list separatedby a semicolon will be
0008 %averaged together .  standard array names can be used.
0009 %base_obs = observation to plot at each freq under freqs asa line graph.
0010 %lines = 'black' or 'color'
0011 %power_type = can be either 'power', 'amplitude', or 'logpower'
0012 %powerfname = powerfilename (can be gui by skipping or passing a blank)
0013 %
0014 
0015 if nargin < 6
0016     error('insufficient number of arguments')
0017 end
0018 if size(obs,2) ~= size(freqs,2) 
0019     error('frequencies and observations dont match')
0020 end
0021 if nargin < 7
0022     [fid] = get_fid('rb');
0023 
0024 else
0025     fid = fopen(powerfname,'rb');
0026 end;
0027 version = fread(fid,1,'int16');
0028 if version ~= -3
0029     error('this is not a power file');
0030 end;
0031 
0032  [nfiles,obs_labels,Epoch,Window_Length,NEpoch,Nbad_chan,bad_chan,ref_flag,reference,NChan,NFreq] = rd_anal_hdr(fid);
0033 
0034 layout = ceil(sqrt(size(chans,2)));
0035 
0036 if strcmp(lines,'black')
0037 line_type1 = ['w-'];
0038 line_type2 = ['k--'];
0039 else    
0040 line_type1 = ['r-'];
0041 line_type2 = ['b--'];
0042 end;
0043 
0044 figure
0045 
0046 obs_mask = zeros(1,nfiles);
0047 obs_mask(obs) = ones(1,size(obs,2));
0048 maxpower = 0;
0049 plot_power = zeros(size(obs,2),size(chans,2));
0050 iline = 1;
0051 icount = 1;
0052 for i = 1:nfiles
0053     power = fread(fid,[NChan(i),NFreq(i)],'float');
0054     if strcmp(power_type,'amplitude')
0055             power = sqrt(power);
0056     end;
0057     if i == base_obs
0058         power_base = power';
0059     end;
0060     if obs_mask(i) > 0
0061         power = power';
0062         
0063         plot_power(icount,1:size(chans,2)) = power(freqs(icount)*Epoch(i)+1,chans);
0064         icount = icount + 1;
0065     end;
0066 max_power = max(max(plot_power));
0067 end;
0068 icount = 1;
0069 for i = 1:size(chans,2)
0070     subplot(layout,layout,icount), bar(freqs,plot_power(:,icount),line_type1)
0071     hold on, plot(freqs,power_base(freqs*Epoch(base_obs)+ones(1,size(freqs,2)),chans(icount)),line_type2);
0072     hold on, axis([min(freqs)-1 max(freqs)+1 0 max_power]);
0073     title(['Channel ' int2str(chans(icount))]);
0074     icount = icount + 1;
0075     
0076 end;
0077 fclose('all')
0078 status = 1;
0079     
0080 
0081 
0082         
0083 
0084 
0085 
0086 
0087 
0088 
0089

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