0001 function status = bar_eeg_power(freqs,obs,chans,base_obs,lines,power_type,powerfname);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
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