0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 function specGND=bin_dif_spec(specGND,binA,binB,dif_bindesc)
0038
0039 if nargin<4,
0040 dif_bindesc=sprintf('Bin %d-Bin %d',binA,binB);
0041 end
0042
0043 specGND_copy=specGND;
0044
0045 [n_chans, n_freqs, n_bins, n_subs]=size(specGND.indiv_pow_dB);
0046 neo_bin=n_bins+1;
0047 specGND.dif(neo_bin)=1;
0048 specGND.indiv_pow_dB(:,:,neo_bin,:)=zeros(n_chans,n_freqs,1,n_subs);
0049 use_subs=[];
0050 for sub=1:n_subs,
0051 if sum(sum(isnan(specGND.indiv_pow_dB(:,:,binA,sub))))
0052 fprintf('Sub %d does not have spectra for Bin %. and will be ignored',sub,binA);
0053 specGND.indiv_erps(:,:,neo_bin,sub)=NaN;
0054 specGND.indiv_bin_ct(sub,neo_bin)=0;
0055 specGND.indiv_bin_raw_ct(sub,neo_bin)=0;
0056 else
0057 if sum(sum(isnan(specGND.indiv_pow_dB(:,:,binB,sub))))
0058 fprintf('Sub %d does not have spectra for Bin %. and will be ignored',sub,binB);
0059 specGND.indiv_erps(:,:,neo_bin,sub)=NaN;
0060 specGND.indiv_bin_ct(sub,neo_bin)=0;
0061 specGND.indiv_bin_raw_ct(sub,neo_bin)=0;
0062 else
0063 specGND.indiv_pow_dB(:,:,neo_bin,sub)=specGND.indiv_pow_dB(:,:,binA,sub)- ...
0064 specGND.indiv_pow_dB(:,:,binB,sub);
0065 specGND.indiv_bin_ct(sub,neo_bin)=-1;
0066 specGND.indiv_bin_raw_ct(sub,neo_bin)=-1;
0067 use_subs=[use_subs sub];
0068 end
0069 end
0070 end
0071 if isempty(use_subs),
0072 specGND=specGND_copy;
0073 error('No subjects have spectra in both Bin %d and Bin %d. No changes were made to specGND variable.\n',binA,binB);
0074 else
0075 specGND.sub_ct(neo_bin)=length(use_subs);
0076 specGND.grands_pow_dB(:,:,neo_bin)=mean(specGND.indiv_pow_dB(:,:,neo_bin,use_subs),4);
0077 specGND.grands_pow_dB_stder(:,:,neo_bin)=std(specGND.indiv_pow_dB(:,:,neo_bin,use_subs),0,4)/sqrt(specGND.sub_ct(neo_bin));
0078 specGND.grands_pow_dB_t(:,:,neo_bin)=specGND.grands_pow_dB(:,:,neo_bin)./specGND.grands_pow_dB_stder(:,:,neo_bin);
0079 specGND.bindesc{neo_bin}=dif_bindesc;
0080 end
0081
0082 fprintf('<<New bin successfully created>>\n');
0083 fprintf('Bin %d: %s\n',neo_bin,specGND.bindesc{neo_bin});
0084 hist_cmd=sprintf('specGND=bin_dif_spec(specGND,%d,%d,''%s'');',binA,binB, ...
0085 specGND.bindesc{neo_bin});
0086 specGND.history{length(specGND.history)+1}=hist_cmd;
0087 specGND.saved='no';
0088