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
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
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
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301 function gui_pow(cmnd_str,varargin)
0302
0303 p=inputParser;
0304 p.addRequired('cmnd_str',@(x) ischar(x) || isstruct(x));
0305 p.addParamValue('fig_id',[],@(x) isempty(x) || (isnumeric(x) && (length(x)==1)));
0306 p.addParamValue('bin',1,@(x) isnumeric(x) && (length(x)==1));
0307 p.addParamValue('show_band',[],@(x) isempty(x) || (isnumeric(x) && (length(x)==2)));
0308 p.addParamValue('specGND_or_specGRP',[],@isstruct);
0309 p.addParamValue('critical_t',[],@(x) isempty(x) || (isnumeric(x) && (length(x)<=2)));
0310 p.addParamValue('test_wind',[],@(x) isempty(x) || (isnumeric(x) && (size(x,2)==2)));
0311 p.addParamValue('stat','t',@(x) ischar(x) || strcmpi(x,'t') || strcmpi(x,'stder'));
0312 p.addParamValue('exclude_chans',[],@(x) ischar(x) || iscell(x) || isempty(x));
0313 p.addParamValue('include_chans',[],@(x) ischar(x) || iscell(x) || isempty(x));
0314 p.addParamValue('alpha_or_q',[],@(x) isempty(x) || isnumeric(x));
0315 p.addParamValue('t_test',[],@(x) isempty(x) || (isnumeric(x) && (length(x)==1) && (x>0)));
0316 p.addParamValue('verblevel',2,@(x) isnumeric(x) && (length(x)==1));
0317 p.parse(cmnd_str,varargin{:});
0318
0319
0320 if isstruct(cmnd_str)
0321
0322
0323
0324 gui_pow('initialize','specGND_or_specGRP',cmnd_str,'fig_id',p.Results.fig_id, ...
0325 'bin',p.Results.bin, ...
0326 'critical_t',p.Results.critical_t, ...
0327 'test_wind',p.Results.test_wind, ...
0328 'show_band',p.Results.show_band, ...
0329 'stat',p.Results.stat, ...
0330 'exclude_chans',p.Results.exclude_chans, ...
0331 'include_chans',p.Results.include_chans, ...
0332 'alpha_or_q',p.Results.alpha_or_q, ...
0333 't_test',p.Results.t_test, ...
0334 'verblevel',p.Results.verblevel);
0335 return;
0336 end
0337
0338
0339 psbl_cmnds{1}='initialize';
0340 psbl_cmnds{2}='freq jump';
0341 psbl_cmnds{3}='back one';
0342 psbl_cmnds{4}='forward one';
0343 psbl_cmnds{5}='back';
0344 psbl_cmnds{6}='forward';
0345 psbl_cmnds{7}='change stat';
0346 psbl_cmnds{8}='new freq limits';
0347 psbl_cmnds{9}='new statistic limitsA';
0348 psbl_cmnds{10}='change bin';
0349 psbl_cmnds{11}='new statistic limitsB';
0350 psbl_cmnds{12}='update dashed lines';
0351 psbl_cmnds{13}='update critical t';
0352 psbl_cmnds{14}='redraw topo';
0353 psbl_cmnds{15}='change test';
0354 if ~ismember(cmnd_str,psbl_cmnds),
0355 error('''%s'' is not a valid value of cmnd_str for gui_pow.m',cmnd_str);
0356 end
0357
0358
0359 if ~strcmp(cmnd_str,'initialize')
0360 if isempty(p.Results.fig_id),
0361 fig_id=gcbf;
0362 else
0363 fig_id=p.Results.fig_id;
0364 end
0365 if ~strcmp(get(fig_id,'tag'),'gui_pow')
0366
0367
0368 h_figs = get(0,'children');
0369 fig_id = findobj(h_figs,'flat',...
0370 'tag','gui_pow');
0371 if isempty(fig_id),
0372
0373
0374
0375 gui_pow('initialize');
0376 gui_pow(cmnd_str);
0377 return;
0378 end
0379 end
0380
0381
0382
0383
0384
0385
0386
0387 dat=get(gcbf,'userdata');
0388 end
0389
0390
0391 if isempty(p.Results.verblevel),
0392 VERBLEVEL=2;
0393 else
0394 VERBLEVEL=p.Results.verblevel;
0395 end
0396
0397
0398 if strcmp(cmnd_str,'initialize')
0399 if isempty(p.Results.specGND_or_specGRP.grands_pow_dB)
0400 error('There are no bins in this specGND or specGRP variable. You need to add bins before you can visualize them with the spectral power GUI.');
0401 end
0402
0403
0404 if isempty(p.Results.fig_id),
0405 dat.fig_id=figure;
0406 else
0407 dat.fig_id=p.Results.fig_id;
0408 figure(dat.fig_id);
0409 clf
0410 end
0411 set(dat.fig_id,'name',['POW GUI ' p.Results.specGND_or_specGRP.exp_desc],'tag','gui_pow', ...
0412 'MenuBar','none','position',[139 42 690 700]);
0413
0414
0415 n_t_tests=length(p.Results.specGND_or_specGRP.t_tests);
0416 dat.psbl_tests=[];
0417 temp_bins=zeros(1,n_t_tests);
0418 for d=1:n_t_tests,
0419 if ~strcmpi(p.Results.specGND_or_specGRP.t_tests(d).mean_band,'yes'),
0420 dat.psbl_tests=[dat.psbl_tests d];
0421 temp_bins(d)=p.Results.specGND_or_specGRP.t_tests(d).bin;
0422 end
0423 end
0424 temp_bins=temp_bins(dat.psbl_tests);
0425 n_psbl_tests=length(dat.psbl_tests);
0426 dat.t_tests=p.Results.specGND_or_specGRP.t_tests(dat.psbl_tests);
0427 crnt_ttest=n_psbl_tests+1;
0428
0429 use_ttest=0;
0430 if isempty(p.Results.t_test),
0431 if isempty(p.Results.include_chans) && isempty(p.Results.exclude_chans) ...
0432 && isempty(p.Results.critical_t) && isempty(p.Results.alpha_or_q) ...
0433 && isempty(p.Results.test_wind),
0434
0435
0436
0437 test_ids=find(p.Results.bin==temp_bins);
0438 if ~isempty(test_ids),
0439 use_ttest=1;
0440 crnt_ttest=test_ids(1);
0441 if VERBLEVEL>=2
0442 fprintf('Plotting results of t-tests set %d. Any input arguments (e.g., ''critical_t'') inconsistent with this test will be ignored.\n', ...
0443 dat.psbl_tests(crnt_ttest));
0444 end
0445 end
0446 end
0447 else
0448 if p.Results.t_test>n_t_tests,
0449 error('Argument ''t_test'' value of %d exceeds the number of test results stored in this specGND/specGRP variable (i.e., %d).', ...
0450 p.Results.t_test,n_t_tests);
0451 elseif ~ismember(p.Results.t_test,dat.psbl_tests),
0452 error('t-test set %d in this specGND/specGRP variable was performed on mean amplitudes within one or more frequency bands. You cannot visualize such tests with gui_pow.m.', ...
0453 p.Results.t_test);
0454 else
0455 use_ttest=1;
0456 crnt_ttest=find(dat.psbl_tests==p.Results.t_test);
0457 if VERBLEVEL>=2
0458 fprintf('Plotting results of t-test set %d. Any input arguments (e.g., ''bin'') inconsistent with this test will be ignored.\n', ...
0459 p.Results.t_test);
0460 end
0461 end
0462 end
0463 if use_ttest,
0464
0465
0466 bin=dat.t_tests(crnt_ttest).bin;
0467 if isnan(dat.t_tests(crnt_ttest).estimated_alpha)
0468 dat.alpha=dat.t_tests(crnt_ttest).desired_alphaORq;
0469 dat.mltplcmp_crct='fdr';
0470 else
0471 dat.alpha=dat.t_tests(crnt_ttest).estimated_alpha;
0472 dat.mltplcmp_crct='perm';
0473 end
0474 test_wind=dat.t_tests(crnt_ttest).freq_band;
0475 dat.n_wind=size(test_wind,1);
0476 include_chans=dat.t_tests(crnt_ttest).include_chans;
0477 dat.critical_t=dat.t_tests(crnt_ttest).crit_t;
0478 dat.null_mean=dat.t_tests(crnt_ttest).null_mean;
0479 else
0480
0481 bin=p.Results.bin;
0482 test_wind=p.Results.test_wind;
0483 include_chans=p.Results.include_chans;
0484 dat.alpha=p.Results.alpha_or_q;
0485 dat.critical_t=p.Results.critical_t;
0486 dat.null_mean=0;
0487 end
0488
0489
0490
0491 if bin>size(p.Results.specGND_or_specGRP.grands_pow_dB,3)
0492 close(gcf);
0493 error('You asked to visualize Bin %d, but your specGND/specGRP variable only contains %d bins.', ...
0494 bin,size(p.Results.specGND_or_specGRP.grands_pow_dB,3));
0495 end
0496
0497
0498 n_chan=length(p.Results.specGND_or_specGRP.chanlocs);
0499
0500 if ~isempty(include_chans) && ~isempty(p.Results.exclude_chans)
0501 if use_ttest,
0502 error('You cannot specify a set of t-tests to visualize and use the ''exclude_chans'' option.');
0503 else
0504 error('You cannot use BOTH ''include_chans'' and ''exclude_chans'' options.');
0505 end
0506 end
0507 if ischar(p.Results.exclude_chans),
0508 exclude_chans{1}=p.Results.exclude_chans;
0509 elseif isempty(p.Results.exclude_chans)
0510 exclude_chans=[];
0511 else
0512 exclude_chans=p.Results.exclude_chans;
0513 end
0514 if ischar(include_chans),
0515 temp_var=include_chans;
0516 clear include_chans;
0517 include_chans{1}=temp_var;
0518 clear temp_var;
0519 end
0520 if ~isempty(exclude_chans),
0521 ignore_chans=zeros(1,length(exclude_chans));
0522 ct=0;
0523 for x=1:length( exclude_chans),
0524 found=0;
0525 for c=1:n_chan,
0526 if strcmpi(exclude_chans{x},p.Results.specGND_or_specGRP.chanlocs(c).labels),
0527 found=1;
0528 ct=ct+1;
0529 ignore_chans(ct)=c;
0530 end
0531 end
0532 if ~found,
0533 watchit(sprintf('I attempted to exclude %s. However no such electrode was found in specGND/specGRP variable.', ...
0534 exclude_chans{x}));
0535 end
0536 end
0537 ignore_chans=ignore_chans(1:ct);
0538 loaded_chans=setdiff(1:n_chan,ignore_chans);
0539 elseif ~isempty(include_chans),
0540 loaded_chans=zeros(1,length(include_chans));
0541 ct=0;
0542 for x=1:length(include_chans),
0543 found=0;
0544 for c=1:n_chan,
0545 if strcmpi(include_chans{x},p.Results.specGND_or_specGRP.chanlocs(c).labels),
0546 found=1;
0547 ct=ct+1;
0548 loaded_chans(ct)=c;
0549 end
0550 end
0551 if ~found,
0552 watchit(sprintf('I attempted to include %s. However no such electrode was found in specGND/specGRP variable.', ...
0553 include_chans{x}));
0554 end
0555 end
0556 loaded_chans=loaded_chans(1:ct);
0557 else
0558 loaded_chans=1:n_chan;
0559 end
0560 if isempty(loaded_chans),
0561 error('No channels selected for visualization!');
0562 end
0563
0564 yes_coord=zeros(1,n_chan);
0565 for c=loaded_chans,
0566 if ~isempty(p.Results.specGND_or_specGRP.chanlocs(c).theta) && ~isnan(p.Results.specGND_or_specGRP.chanlocs(c).theta)
0567 yes_coord(c)=1;
0568 end
0569 end
0570 if (sum(yes_coord)==0)
0571 if use_ttest
0572
0573 watchit(sprintf('None of the channels you wish to visualize have scalp coordinates.\nIt is pointless to use the gui_pow.m. Using sig_wave.m instead.'));
0574 close(gcf);
0575 sig_wave(p.Results.specGND_or_specGRP,crnt_ttest, ...
0576 'verblevel',p.Results.verblevel);
0577 else
0578 watchit('None of the channels you wish to visualize have scalp coordinates. It is pointless to use the gui_pow.m.');
0579 close(gcf);
0580 end
0581 return
0582 elseif sum(yes_coord)<length(loaded_chans),
0583 watchit(sprintf('%d channels do not have scalp coordinates. The spectra for such channels will be visualized but they the will not be represented in the scalp topography.', ...
0584 length(loaded_chans)-sum(yes_coord)));
0585 end
0586
0587
0588
0589 use_tests=[];
0590 for d=1:n_psbl_tests,
0591 if ~isempty(intersect(loaded_chans,dat.t_tests(d).used_chan_ids)),
0592 use_tests=[use_tests d];
0593 end
0594 end
0595 dat.psbl_tests=dat.psbl_tests(use_tests);
0596 dat.t_tests=dat.t_tests(use_tests);
0597 crnt_ttest=find(crnt_ttest==[use_tests n_psbl_tests+1]);
0598 n_psbl_tests=length(use_tests);
0599
0600
0601 dat.spec=p.Results.specGND_or_specGRP.grands_pow_dB;
0602 dat.t_scores=p.Results.specGND_or_specGRP.grands_pow_dB_t;
0603 dat.stder=p.Results.specGND_or_specGRP.grands_pow_dB_stder;
0604 dat.dif=p.Results.specGND_or_specGRP.dif;
0605 for dd=1:length(dat.dif),
0606 if dat.dif(dd),
0607
0608
0609 dat.rms(:,dd)=squeeze(sqrt(mean(dat.spec(:,:,dd).^2,1)))';
0610 else
0611
0612
0613 non_db=(10.^(dat.spec(:,:,dd)/10));
0614 dat.rms(:,dd)=squeeze(sqrt(mean(non_db,1)))';
0615 end
0616 end
0617
0618 if (crnt_ttest<=n_psbl_tests) && (dat.t_tests(crnt_ttest).null_mean),
0619
0620 dat.showing_t=squeeze( (p.Results.specGND_or_specGRP.grands_pow_dB(loaded_chans,:,bin)- ...
0621 dat.t_tests(crnt_ttest).null_mean)./p.Results.specGND_or_specGRP.grands_pow_dB_stder(loaded_chans,:,bin) );
0622 else
0623 dat.showing_t=squeeze(p.Results.specGND_or_specGRP.grands_pow_dB_t(loaded_chans,:,bin));
0624 end
0625
0626 if isinf(dat.t_scores(1,1,bin)) || isnan(dat.t_scores(1,1,bin)) || strcmpi(p.Results.stat,'rms'),
0627
0628
0629
0630
0631
0632 dat.showingB=dat.rms(:,bin)';
0633 elseif strcmpi(p.Results.stat,'t'),
0634 dat.showingB=dat.showing_t;
0635 else
0636
0637 dat.showingB=squeeze(p.Results.specGND_or_specGRP.grands_pow_dB_stder(loaded_chans,:,bin));
0638 end
0639 dat.showingA=squeeze(p.Results.specGND_or_specGRP.grands_pow_dB(loaded_chans,:,bin));
0640
0641 n_bin=size(p.Results.specGND_or_specGRP.grands_pow_dB,3);
0642 dat.bindesc=cell(1,n_bin);
0643 for b=1:n_bin,
0644 if isfield(p.Results.specGND_or_specGRP,'bindesc'),
0645 dat.bindesc{b}=p.Results.specGND_or_specGRP.bindesc{b};
0646 else
0647 dat.bindesc{b}=p.Results.specGND_or_specGRP.bin_info(b).bindesc;
0648 end
0649 end
0650 dat.freqs=p.Results.specGND_or_specGRP.freqs;
0651 if isempty(p.Results.show_band),
0652 dat.plt_freqs=[p.Results.specGND_or_specGRP.freqs(1) p.Results.specGND_or_specGRP.freqs(end)];
0653 else
0654 dat.plt_freqs=p.Results.show_band;
0655 end
0656 dat.chanlocs=p.Results.specGND_or_specGRP.chanlocs;
0657 dat.loaded_chans=loaded_chans;
0658 dat.showing_chans=loaded_chans;
0659 critical_t=dat.critical_t;
0660 if length(critical_t)>2,
0661 critical_t=critical_t(1:2);
0662 end
0663 dat.critical_t=critical_t;
0664
0665
0666
0667
0668
0669 frm_col=[1 1 1]*.702;
0670 uipanel(dat.fig_id,...
0671 'Units','normalized', ...
0672 'Position',[ 0 0.59 .72 0.42 ],...
0673 'shadowcolor','k', ...
0674 'highlightcolor',frm_col, ...
0675 'foregroundcolor',frm_col, ...
0676 'backgroundcolor',frm_col);
0677
0678 dat.h_freqA=axes('position',[0.1 .62 .6 .33]);
0679 dat.start_pt=find_tpt(dat.plt_freqs(1),dat.freqs);
0680 dat.end_pt=find_tpt(dat.plt_freqs(2),dat.freqs);
0681 plotted_pts=dat.start_pt:dat.end_pt;
0682 plotted_freqs=dat.freqs(dat.start_pt:dat.end_pt);
0683 dat.absmxA=max(max(abs(dat.showingA(:,dat.start_pt:dat.end_pt))));
0684 [dummy, mx_tpt]=max(dat.rms(dat.start_pt:dat.end_pt,bin));
0685 stat_mx=max(max(dat.showingA(:,dat.start_pt:dat.end_pt)));
0686 stat_mn=min(min(dat.showingA(:,dat.start_pt:dat.end_pt)));
0687 stat_rng=stat_mx-stat_mn;
0688 stat_plt_rng=[stat_mn-stat_rng*.02 stat_mx+stat_rng*.02];
0689 stat_plt_rng=round(stat_plt_rng*100)/100;
0690 if dat.dif(bin)
0691 dat.h_db_zeroA=plot([p.Results.specGND_or_specGRP.freqs(1) p.Results.specGND_or_specGRP.freqs(end)],[0 0],'k');
0692 else
0693 dat.h_db_zeroA=[];
0694 end
0695 hold on;
0696 set(dat.h_freqA,'ygrid','on');
0697 if size(dat.showingA,1)==1,
0698
0699 dat.h_showingA=plot(dat.freqs,dat.showingA);
0700 else
0701 dat.h_showingA=plot(dat.freqs,dat.showingA');
0702 end
0703 axis tight;
0704 axis([plotted_freqs(1) plotted_freqs(end) stat_plt_rng]);
0705 vA=axis;
0706 dat.h_lineA=plot([1 1]*plotted_freqs(mx_tpt),vA(3:4),'k');
0707 set(dat.h_lineA,'linewidth',2);
0708
0709
0710 dat.n_wind=size(test_wind,1);
0711 if dat.n_wind
0712 for nw=1:dat.n_wind,
0713 dat.h_wind1A(nw)=plot([1 1]*test_wind(nw,1),vA(3:4),'k--');
0714 set(dat.h_wind1A(nw),'linewidth',2);
0715 dat.h_wind2A(nw)=plot([1 1]*test_wind(nw,2),vA(3:4),'k--');
0716 set(dat.h_wind2A(nw),'linewidth',2);
0717 end
0718 else
0719 dat.h_wind1A=[];
0720 dat.h_wind2A=[];
0721 end
0722
0723
0724 h=ylabel('10*log10(\muV^2/Hz)');
0725 dat.h_freq_ylabA=h;
0726 set(h,'fontsize',10,'fontunits','normalized');
0727
0728
0729 new_title=['Bin ' int2str(bin) ': ' dat.bindesc{bin}];
0730 title_max_char=43;
0731 if length(new_title)>title_max_char,
0732 new_title=new_title(1:title_max_char);
0733 end
0734 dat.h_freq_title=title(new_title);
0735 set(dat.h_freq_title,'fontsize',10,'fontunits','normalized');
0736 bdf_code = [ 'tmppos = get(gca, ''currentpoint'');' ...
0737 'dat=get(gcbf, ''userdata'');' ...
0738 'new_freq=find_tpt(tmppos(1,1),dat.freqs);' ...
0739 'set(dat.h_lineA,''XData'',[1 1]*dat.freqs(new_freq));' ...
0740 'set(dat.h_lineB,''XData'',[1 1]*dat.freqs(new_freq));' ...
0741 'set(dat.h_topo_freq,''string'',num2str(dat.freqs(new_freq)));' ...
0742 'set(dat.fig_id,''userdata'',dat);' ...
0743 'gui_pow(''redraw topo'');' ...
0744 'drawnow;' ...
0745 'clear latpoint dattmp tmppos;' ...
0746 ];
0747 set(dat.h_freqA,'ButtonDownFcn',bdf_code);
0748 set(dat.h_showingA,'ButtonDownFcn',bdf_code);
0749
0750
0751
0752
0753
0754
0755 frm_col=[1 1 1]*.702;
0756 uipanel(dat.fig_id,...
0757 'Units','normalized', ...
0758 'Position',[ 0 0.175 .72 0.42 ],...
0759 'shadowcolor','k', ...
0760 'highlightcolor',frm_col, ...
0761 'foregroundcolor',frm_col, ...
0762 'backgroundcolor',frm_col);
0763
0764 dat.h_freqB=axes('position',[0.1 .25 .6 .33]);
0765 dat.absmxB=max(max(abs(dat.showingB(:,dat.start_pt:dat.end_pt))));
0766 stat_mx=max(max(dat.showingB(:,dat.start_pt:dat.end_pt)));
0767 stat_mn=min(min(dat.showingB(:,dat.start_pt:dat.end_pt)));
0768 stat_rng=stat_mx-stat_mn;
0769 stat_plt_rng=[stat_mn-stat_rng*.02 stat_mx+stat_rng*.02];
0770 stat_plt_rng=round(stat_plt_rng*100)/100;
0771 if dat.dif(bin) && strcmpi(p.Results.stat,'t')
0772 dat.h_db_zeroB=plot([p.Results.specGND_or_specGRP.freqs(1) p.Results.specGND_or_specGRP.freqs(end)],[0 0],'k');
0773 else
0774 dat.h_db_zeroB=[];
0775 end
0776 hold on;
0777 set(dat.h_freqB,'ygrid','on');
0778 if size(dat.showingB,1)==1,
0779
0780 dat.h_showingB=plot(dat.freqs,dat.showingB);
0781 else
0782 dat.h_showingB=plot(dat.freqs,dat.showingB');
0783 end
0784 axis tight;
0785 axis([plotted_freqs(1) plotted_freqs(end) stat_plt_rng]);
0786 vB=axis;
0787 dat.h_lineB=plot([1 1]*plotted_freqs(mx_tpt),vB(3:4),'k');
0788 set(dat.h_lineB,'linewidth',2);
0789
0790
0791 if dat.n_wind
0792 for nw=1:dat.n_wind,
0793 dat.h_wind1B(nw)=plot([1 1]*test_wind(nw,1),vB(3:4),'k--');
0794 set(dat.h_wind1B(nw),'linewidth',2);
0795 dat.h_wind2B(nw)=plot([1 1]*test_wind(nw,2),vB(3:4),'k--');
0796 set(dat.h_wind2B(nw),'linewidth',2);
0797 end
0798 else
0799 dat.h_wind1B=[];
0800 dat.h_wind2B=[];
0801 end
0802
0803
0804 dat.h_crit1=[];
0805 dat.h_crit2=[];
0806 dat.h_alph1=[];
0807 dat.h_alph2=[];
0808 if ~isempty(critical_t) && ~isempty(test_wind),
0809 if strcmpi(p.Results.stat,'t'),
0810 if isempty(dat.alpha),
0811 watchit('You did not specify an alpha level via optional input argument ''alpha''. Alpha level will not be displayed.');
0812 else
0813 for nw=1:dat.n_wind,
0814 dat.h_crit1(nw)=plot(test_wind(nw,:),[1 1]*critical_t(1),'r--');
0815 set(dat.h_crit1(nw),'linewidth',3);
0816 if nw==1,
0817 tm_rng=p.Results.specGND_or_specGRP.freqs(end)-p.Results.specGND_or_specGRP.freqs(1);
0818 if strcmpi(dat.mltplcmp_crct,'fdr')
0819 dat.h_alph1=text(test_wind(nw,1)-tm_rng*.02,critical_t(1), ...
0820 ['q=' num2str(rnd_orderofmag(dat.alpha))]);
0821 else
0822 dat.h_alph1=text(test_wind(nw,1)-tm_rng*.02,critical_t(1), ...
0823 ['\alpha=' num2str(rnd_orderofmag(dat.alpha))]);
0824 end
0825 set(dat.h_alph1,'color','r','fontweight','normal','fontsize',12, ...
0826 'horizontalalignment','right','backgroundcolor',[1 1 1], ...
0827 'edgecolor',[1 1 1]*.3,'clipping','on','fontname','fixedwidth');
0828 end
0829 end
0830 end
0831 if length(critical_t)>1,
0832 for nw=1:dat.n_wind,
0833 dat.h_crit2(nw)=plot(test_wind(nw,:),[1 1]*critical_t(2),'r--');
0834 set(dat.h_crit2(nw),'linewidth',3);
0835 if nw==1,
0836 if strcmpi(dat.mltplcmp_crct,'fdr')
0837 dat.h_alph2=text(test_wind(nw,1)-tm_rng*.02,critical_t(2), ...
0838 ['q=' num2str(rnd_orderofmag(dat.alpha))]);
0839 else
0840 dat.h_alph2=text(test_wind(nw,1)-tm_rng*.02,critical_t(2), ...
0841 ['\alpha=' num2str(rnd_orderofmag(dat.alpha))]);
0842 end
0843 set(dat.h_alph2,'color','r','fontweight','normal','fontsize',12, ...
0844 'horizontalalignment','right','backgroundcolor',[1 1 1], ...
0845 'edgecolor',[1 1 1]*.3,'clipping','on','fontname','fixedwidth');
0846 end
0847 end
0848 end
0849 end
0850 end
0851
0852 h=xlabel('Frequency (Hz)');
0853 set(h,'fontsize',10,'fontunits','normalized');
0854
0855
0856 if strcmpi(p.Results.stat,'rms') || isinf(dat.t_scores(1,1,bin)) || isnan(dat.t_scores(1,1,bin)),
0857 h=ylabel('\muV/sqrt(Hz) (RMS)');
0858 elseif strcmpi(p.Results.stat,'t'),
0859 h=ylabel('t-score');
0860 else
0861 h=ylabel('10*log10(\muV^2/Hz) (StdEr)');
0862 end
0863 dat.h_freq_ylabB=h;
0864 set(h,'fontsize',10,'fontunits','normalized');
0865
0866 bdf_code = [ 'tmppos = get(gca, ''currentpoint'');' ...
0867 'dat=get(gcbf, ''userdata'');' ...
0868 'new_freq=find_tpt(tmppos(1,1),dat.freqs);' ...
0869 'set(dat.h_lineA,''XData'',[1 1]*dat.freqs(new_freq));' ...
0870 'set(dat.h_lineB,''XData'',[1 1]*dat.freqs(new_freq));' ...
0871 'set(dat.h_topo_freq,''string'',num2str(dat.freqs(new_freq)));' ...
0872 'set(dat.fig_id,''userdata'',dat);' ...
0873 'gui_pow(''redraw topo'');' ...
0874 'drawnow;' ...
0875 'clear latpoint dattmp tmppos;' ...
0876 ];
0877 set(dat.h_freqB,'ButtonDownFcn',bdf_code);
0878 set(dat.h_showingB,'ButtonDownFcn',bdf_code);
0879
0880
0881
0882
0883
0884
0885 uipanel(dat.fig_id,...
0886 'Units','normalized', ...
0887 'Position',[ 0.719 0.59 0.281 0.42 ],...
0888 'shadowcolor','k', ...
0889 'highlightcolor',frm_col, ...
0890 'foregroundcolor',frm_col, ...
0891 'backgroundcolor',frm_col);
0892
0893
0894 dat.h_topoA=axes('position',[0.705 .68 .31 .24],'box','off');
0895
0896 sig_chans=[];
0897 cbar_title_fontsize=14;
0898 if ~isempty(test_wind) && ~isempty(critical_t),
0899
0900
0901 for nw=1:dat.n_wind,
0902 if (dat.freqs(plotted_pts(mx_tpt))>=test_wind(nw,1)) && (dat.freqs(plotted_pts(mx_tpt))<=test_wind(nw,2)),
0903 if length(critical_t)==2,
0904 sig_chans=find(dat.showing_t(:,plotted_pts(mx_tpt))>max(critical_t));
0905 sig_chans=[sig_chans; find(dat.showing_t(:,plotted_pts(mx_tpt))<min(critical_t))];
0906 else
0907 if critical_t>0,
0908 sig_chans=find(dat.showing_t(:,plotted_pts(mx_tpt))>critical_t);
0909 else
0910 sig_chans=find(dat.showing_t(:,plotted_pts(mx_tpt))<critical_t);
0911 end
0912 end
0913 break;
0914 end
0915 end
0916 end
0917 if size(dat.showingA,1)<=2,
0918
0919 topoplotMK(dat.showingA(:,plotted_pts(mx_tpt)),dat.chanlocs(dat.showing_chans), ...
0920 'style','blank','plain_blank',1,'emarker2',{sig_chans,'o',[1 1 1],4});
0921 cbar_title='Not Applicable';
0922 cbar_title_fontsize=10;
0923 topo_xtick_labA={' ',' ',' '};
0924 else
0925
0926 if dat.dif(bin),
0927
0928 dat.mx_topoA=max(max(abs(dat.showingA(:,dat.start_pt:dat.end_pt))));
0929 dat.mn_topoA=-dat.mx_topoA;
0930 else
0931
0932
0933 dat.mx_topoA=max(dat.showingA(:,plotted_pts(mx_tpt)));
0934 dat.mn_topoA=min(dat.showingA(:,plotted_pts(mx_tpt)));
0935 end
0936 topoplotMK(dat.showingA(:,plotted_pts(mx_tpt)),dat.chanlocs(dat.showing_chans), ...
0937 'maplimits',[dat.mn_topoA dat.mx_topoA],'emarker2',{sig_chans,'o',[1 1 1],4});
0938 set(findobj(gca,'type','patch'),'facecolor',[1 1 1]*.702);
0939 cbar_title='10*log10(\muV^2/Hz)';
0940 topo_xtick_labA=[dat.mn_topoA 0 dat.mx_topoA];
0941 topo_xtick_labA=round(topo_xtick_labA*100)/100;
0942 end
0943
0944
0945
0946 dat.h_cbarA=axes('position',[0.76 .945 .2 .015]);
0947 cbar(dat.h_cbarA);
0948 set(gca,'xticklabel',topo_xtick_labA);
0949 h_cbar_title=title(cbar_title);
0950 set(h_cbar_title,'fontsize',cbar_title_fontsize);
0951
0952
0953
0954
0955 uicontrol(dat.fig_id,...
0956 'Units','normalized', ...
0957 'Position',[ 0.905 0.62 0.07 0.04 ],...
0958 'String','Hz',...
0959 'fontsize',14, ...
0960 'fontunits','normalized', ...
0961 'Style','text');
0962 dat.h_topo_freq=uicontrol(dat.fig_id,...
0963 'CallBack','gui_pow(''freq jump'');',...
0964 'Units','normalized', ...
0965 'Position',[ 0.805 0.62 0.1 0.05 ], ...
0966 'String',num2str(plotted_freqs(mx_tpt)), ...
0967 'Style','edit', ...
0968 'Enable','on', ...
0969 'ToolTipString','Frequency to visualize topographicaly.', ...
0970 'fontsize',14, ...
0971 'fontunits','normalized', ...
0972 'horizontalalignment','center', ...
0973 'BackGroundColor','w', ...
0974 'Tag','topo_freq');
0975
0976
0977
0978
0979
0980
0981
0982
0983 uipanel(dat.fig_id,...
0984 'Units','normalized', ...
0985 'Position',[ 0.719 0.175 0.281 0.42 ],...
0986 'shadowcolor','k', ...
0987 'highlightcolor',frm_col, ...
0988 'foregroundcolor',frm_col, ...
0989 'backgroundcolor',frm_col);
0990
0991
0992 dat.h_topoB=axes('position',[0.705 .27 .31 .24],'box','off');
0993
0994 cbar_title_fontsize=14;
0995 if strcmpi(p.Results.stat,'rms') || isinf(dat.t_scores(1,1,bin)) || isnan(dat.t_scores(1,1,bin))
0996
0997 topoplotMK([],dat.chanlocs(dat.showing_chans), ...
0998 'style','blank','plain_blank',1);
0999 cbar_title='Not Applicable';
1000 cbar_title_fontsize=10;
1001 topo_xtick_labB={' ',' ',' '};
1002 else
1003 sig_chans=[];
1004 if ~isempty(test_wind) && ~isempty(critical_t),
1005
1006
1007 for nw=1:dat.n_wind,
1008 if (dat.freqs(plotted_pts(mx_tpt))>=test_wind(nw,1)) && (dat.freqs(plotted_pts(mx_tpt))<=test_wind(nw,2)),
1009 if length(critical_t)==2,
1010 sig_chans=find(dat.showing_t(:,plotted_pts(mx_tpt))>max(critical_t));
1011 sig_chans=[sig_chans; find(dat.showing_t(:,plotted_pts(mx_tpt))<min(critical_t))];
1012 else
1013 if critical_t>0,
1014 sig_chans=find(dat.showing_t(:,plotted_pts(mx_tpt))>critical_t);
1015 else
1016 sig_chans=find(dat.showing_t(:,plotted_pts(mx_tpt))<critical_t);
1017 end
1018 end
1019 break;
1020 end
1021 end
1022 end
1023 if size(dat.showingB,1)<=2,
1024
1025 topoplotMK(dat.showingB(:,plotted_pts(mx_tpt)),dat.chanlocs(dat.showing_chans), ...
1026 'style','blank','plain_blank',1,'emarker2',{sig_chans,'o',[1 1 1],4});
1027 cbar_title='Not Applicable';
1028 cbar_title_fontsize=10;
1029 topo_xtick_labB={' ',' ',' '};
1030 else
1031 if dat.dif(bin),
1032
1033 dat.mx_topoB=max(max(abs(dat.showingB(:,dat.start_pt:dat.end_pt))));
1034 dat.mn_topoB=-dat.mx_topoB;
1035 else
1036
1037 dat.mx_topoB=max(dat.showingB(:,plotted_pts(mx_tpt)));
1038 dat.mn_topoB=min(dat.showingB(:,plotted_pts(mx_tpt)));
1039 end
1040 topoplotMK(dat.showingB(:,plotted_pts(mx_tpt)),dat.chanlocs(dat.showing_chans), ...
1041 'maplimits',[dat.mn_topoB dat.mx_topoB],'emarker2',{sig_chans,'o',[1 1 1],4});
1042 set(findobj(gca,'type','patch'),'facecolor',[1 1 1]*.702);
1043 topo_xtick_labB=[dat.mn_topoB 0 dat.mx_topoB];
1044 topo_xtick_labB=round(topo_xtick_labB*100)/100;
1045 if strcmpi(p.Results.stat,'t'),
1046 cbar_title='t-score';
1047 else
1048 cbar_title='10*log10(\muV^2/Hz)';
1049 end
1050 end
1051 end
1052
1053
1054 dat.h_cbarB=axes('position',[0.76 .535 .2 .015]);
1055 cbar(dat.h_cbarB);
1056 set(gca,'xticklabel',topo_xtick_labB);
1057 h_cbar_title=title(cbar_title);
1058 set(h_cbar_title,'fontsize',cbar_title_fontsize);
1059
1060
1061 dat.h_back1=uicontrol(dat.fig_id,...
1062 'CallBack','gui_pow(''back one'');',...
1063 'Units','normalized', ...
1064 'Position',[ 0.80 0.232 0.055 0.04 ],...
1065 'String','<',...
1066 'fontsize',14, ...
1067 'fontunits','normalized', ...
1068 'Tag','back1', ...
1069 'ToolTipString','Show topography at preceding frequency.', ...
1070 'Style','pushbutton');
1071
1072
1073 dat.h_forward1=uicontrol(dat.fig_id,...
1074 'CallBack','gui_pow(''forward one'');',...
1075 'Units','normalized', ...
1076 'Position',[ 0.865 0.232 0.055 0.04 ],...
1077 'String','>', ...
1078 'fontsize',14, ...
1079 'fontunits','normalized', ...
1080 'Tag','forward1', ...
1081 'ToolTipString','Show topography at subsequent frequency.', ...
1082 'Style','pushbutton');
1083
1084
1085 dat.h_back=uicontrol(dat.fig_id,...
1086 'CallBack','gui_pow(''back'');',...
1087 'Units','normalized', ...
1088 'Position',[ 0.735 0.232 0.055 0.04 ],...
1089 'String','<<',...
1090 'fontsize',14, ...
1091 'fontunits','normalized', ...
1092 'Tag','back', ...
1093 'interruptible','on', ...
1094 'ToolTipString','Animate topography going backwards in frequency.', ...
1095 'Style','pushbutton');
1096
1097
1098 dat.h_forward=uicontrol(dat.fig_id,...
1099 'CallBack','gui_pow(''forward'');',...
1100 'Units','normalized', ...
1101 'Position',[ 0.93 0.232 0.055 0.04 ],...
1102 'String','>>',...
1103 'fontsize',14, ...
1104 'fontunits','normalized', ...
1105 'Tag','back', ...
1106 'interruptible','on', ...
1107 'ToolTipString','Animate topography going forwards in frequency.', ...
1108 'Style','pushbutton');
1109
1110
1111 dat.h_stop=uicontrol(dat.fig_id,...
1112 'CallBack','dat=get(gcbf,''userdata''); dat.interrupt=1; set(dat.fig_id,''userdata'',dat);',...
1113 'Units','normalized', ...
1114 'Position',[ 0.745 0.179 0.23 0.05 ],...
1115 'String','Stop Animation',...
1116 'fontsize',14, ...
1117 'fontunits','normalized', ...
1118 'Tag','stop', ...
1119 'enable','off', ...
1120 'ToolTipString','Stop topography animation.', ...
1121 'Style','pushbutton');
1122
1123
1124
1125
1126
1127
1128
1129
1130 uipanel(dat.fig_id,...
1131 'Units','normalized', ...
1132 'Position',[ 0 0 1 0.178 ],...
1133 'shadowcolor','k', ...
1134 'highlightcolor',frm_col, ...
1135 'foregroundcolor',frm_col, ...
1136 'backgroundcolor',frm_col);
1137
1138
1139
1140 bdesc_str=cell(1,n_bin);
1141 for a=1:n_bin,
1142 bdesc_str{a}=sprintf('Bin %d: %s',a,dat.bindesc{a});
1143 end
1144
1145 uicontrol(dat.fig_id,...
1146 'Units','normalized', ...
1147 'Position',[ 0.01 0.115 0.2 0.05 ],...
1148 'String','Current Bin',...
1149 'fontsize',12, ...
1150 'ToolTipString','Bin to plot in Frequency x Spectra/t-Score axis.', ...
1151 'Style','text');
1152
1153 dat.h_bin=uicontrol(dat.fig_id,...
1154 'CallBack','gui_pow(''change bin'');',...
1155 'Units','normalized', ...
1156 'Position',[ 0.01 0.08 0.24 0.05 ],...
1157 'fontsize',12, ...
1158 'String',bdesc_str, ...
1159 'Value',bin, ...
1160 'Style','popup', ...
1161 'ToolTipString','Bin to plot in Frequency x Spectra/t-Score axis.', ...
1162 'tag','bin');
1163
1164
1165
1166 ttest_str=cell(1,n_psbl_tests+1);
1167 for a=1:n_psbl_tests,
1168 ttest_str{a}=sprintf('Test %d: Bin %d, Frequencies ',dat.psbl_tests(a),dat.t_tests(a).bin);
1169 n_ttst_wind=size(dat.t_tests(a).freq_band,1);
1170 for b=1:n_ttst_wind,
1171 ttest_str{a}=[ttest_str{a} int2str(dat.t_tests(a).freq_band(b,1)) '-' int2str(dat.t_tests(a).freq_band(b,2)) ','];
1172 end
1173 if length(dat.t_tests(a).crit_t)==2,
1174 ttest_str{a}=[ttest_str{a} ' Two-Tailed,'];
1175 elseif dat.t_tests(a).crit_t<0,
1176 ttest_str{a}=[ttest_str{a} ' Lower-Tailed,'];
1177 else
1178 ttest_str{a}=[ttest_str{a} ' Upper-Tailed,'];
1179 end
1180
1181 if isnan(dat.t_tests(a).estimated_alpha)
1182 ttest_str{a}=[ttest_str{a} sprintf(' q=%.4f',dat.t_tests(a).desired_alphaORq)];
1183 ttest_str{a}=[ttest_str{a} sprintf(', method=%s',dat.t_tests(a).mult_comp_method)];
1184 else
1185 ttest_str{a}=[ttest_str{a} sprintf(' alpha=%.4f',dat.t_tests(a).estimated_alpha)];
1186 end
1187
1188 if dat.t_tests(a).null_mean,
1189 ttest_str{a}=[ttest_str{a} sprintf(', Null Mean=%.4f',dat.t_tests(a).null_mean)];
1190 end
1191 end
1192 ttest_str{n_psbl_tests+1}='None/Manual';
1193
1194
1195 uicontrol(dat.fig_id,...
1196 'Units','normalized', ...
1197 'Position',[ 0.275 0.115 0.2 0.05 ],...
1198 'String','Current Test Result',...
1199 'fontsize',12, ...
1200 'ToolTipString','Set of t-test results to visualize.', ...
1201 'Style','text');
1202
1203 dat.h_ptest=uicontrol(dat.fig_id,...
1204 'CallBack','gui_pow(''change test'');',...
1205 'Units','normalized', ...
1206 'Position',[ 0.26 0.075 0.24 0.055 ],...
1207 'fontsize',12, ...
1208 'String',ttest_str, ...
1209 'Value',crnt_ttest, ...
1210 'Style','popup', ...
1211 'ToolTipString','Set of t-test results to visualize.', ...
1212 'tag','bin');
1213
1214
1215
1216 uicontrol(dat.fig_id,...
1217 'Units','normalized', ...
1218 'Position',[ 0.505 0.115 0.26 0.05 ],...
1219 'String','Test Band(s) [Min Max]:',...
1220 'fontsize',12, ...
1221 'Style','text');
1222
1223 wind_edges=[];
1224 for nw=1:dat.n_wind,
1225 if nw==dat.n_wind,
1226 wind_edges=[wind_edges num2str(test_wind(nw,:))];
1227 else
1228 wind_edges=[wind_edges num2str(test_wind(nw,:)) '; '];
1229 end
1230 end
1231 dat.h_testwind=uicontrol(dat.fig_id,...
1232 'CallBack','gui_pow(''update dashed lines'');',...
1233 'Units','normalized', ...
1234 'fontsize',12, ...
1235 'BackGroundColor','w', ...
1236 'Position',[ 0.525 0.095 0.22 0.04 ],...
1237 'String',wind_edges, ...
1238 'Style','edit', ...
1239 'ToolTipString','Miniumum and maximum frequency in band in which hypothesis tests were done.', ...
1240 'tag','freqrange');
1241
1242
1243
1244
1245 uicontrol(dat.fig_id,...
1246 'Units','normalized', ...
1247 'Position',[ 0.76 0.115 0.23 0.05 ],...
1248 'String','Critical t-score(s)',...
1249 'fontsize',12, ...
1250 'Style','text');
1251
1252 dat.h_critval=uicontrol(dat.fig_id,...
1253 'CallBack','gui_pow(''update critical t'');',...
1254 'Units','normalized', ...
1255 'fontsize',12, ...
1256 'BackGroundColor','w', ...
1257 'Position',[ 0.79 0.09 0.16 0.045 ],...
1258 'String',num2str(critical_t), ...
1259 'Style','edit', ...
1260 'ToolTipString','Critical t-score(s) for reliable deviation from 0 difference between bins.', ...
1261 'tag','freqrange');
1262
1263
1264 stats={'t-score of spectra','standard error of spectra','root mean spectra squared'};
1265
1266 uicontrol(dat.fig_id,...
1267 'Units','normalized', ...
1268 'Position',[ 0.01 0.183 0.09 0.03 ],...
1269 'String','Statistic:',...
1270 'fontsize',12, ...
1271 'ToolTipString','Select what to plot in secondary waveform axis: t-scores, standard error of the mean, or root mean squared.', ...
1272 'Style','text');
1273
1274 if strcmpi(p.Results.stat,'rms') || isinf(dat.t_scores(1,1,bin)) || isnan(dat.t_scores(1,1,bin))
1275
1276
1277 ini_val=3;
1278 elseif strcmpi(p.Results.stat,'t'),
1279 ini_val=1;
1280 elseif strcmpi(p.Results.stat,'stder'),
1281 ini_val=2;
1282 else
1283 close(gcf);
1284 error('Unrecognized value of input argument ''stat''.');
1285 end
1286 dat.h_stat=uicontrol(dat.fig_id,...
1287 'CallBack','gui_pow(''change stat'');',...
1288 'Units','normalized', ...
1289 'Position',[ 0.095 0.165 0.16 0.05 ],...
1290 'fontsize',12, ...
1291 'value',ini_val, ...
1292 'String',stats, ...
1293 'Style','popup', ...
1294 'ToolTipString','Plot spectra t-scores or standard error of the mean in secondary axis?', ...
1295 'tag','stat');
1296
1297
1298
1299 uicontrol(dat.fig_id,...
1300 'Units','normalized', ...
1301 'Position',[ 0.01 0.035 0.24 0.05 ],...
1302 'String','Freq Range [Min Max]',...
1303 'fontsize',12, ...
1304 'Style','text');
1305
1306 dat.h_freqrange=uicontrol(dat.fig_id,...
1307 'CallBack','gui_pow(''new freq limits'');',...
1308 'Units','normalized', ...
1309 'fontsize',12, ...
1310 'BackGroundColor','w', ...
1311 'Position',[ 0.06 0.013 0.11 0.045 ],...
1312 'String',num2str(dat.plt_freqs), ...
1313 'Style','edit', ...
1314 'ToolTipString','Miniumum and maximum frequency on Frequency x Power axis.', ...
1315 'tag','freqrange');
1316
1317
1318
1319 uicontrol(dat.fig_id,...
1320 'Units','normalized', ...
1321 'Position',[ 0.26 0.035 0.26 0.05 ],...
1322 'String','Power Range [Min Max]',...
1323 'HorizontalAlignment','left', ...
1324 'fontsize',12, ...
1325 'Style','text');
1326
1327 dat.h_statrangeA=uicontrol(dat.fig_id,...
1328 'CallBack','gui_pow(''new statistic limitsA'');',...
1329 'Units','normalized', ...
1330 'fontsize',12, ...
1331 'BackGroundColor','w', ...
1332 'Position',[ 0.28 0.013 0.16 0.045 ],...
1333 'String',num2str(round(vA(3:4)*100)/100), ...
1334 'ToolTipString','Miniumum and maximum power on Frequency x Power axis.', ...
1335 'Style','edit', ...
1336 'tag','statrange');
1337
1338
1339
1340 uicontrol(dat.fig_id,...
1341 'Units','normalized', ...
1342 'Position',[ 0.50 0.035 0.26 0.05 ],...
1343 'String','t/SE/RMS Range [Min Max]',...
1344 'HorizontalAlignment','left', ...
1345 'fontsize',12, ...
1346 'Style','text');
1347
1348 dat.h_statrangeB=uicontrol(dat.fig_id,...
1349 'CallBack','gui_pow(''new statistic limitsB'');',...
1350 'Units','normalized', ...
1351 'fontsize',12, ...
1352 'BackGroundColor','w', ...
1353 'Position',[ 0.54 0.013 0.16 0.045 ],...
1354 'String',num2str(round(vB(3:4)*100)/100), ...
1355 'ToolTipString','Miniumum and maximum t-scores/power on Frequency x t-Scores/Standard Error/RMS axis.', ...
1356 'Style','edit', ...
1357 'tag','statrange');
1358
1359
1360 uicontrol(dat.fig_id,...
1361 'CallBack','close(gcbf);',...
1362 'Units','normalized', ...
1363 'Position',[ 0.75 0.012 0.11 0.05 ],...
1364 'String','Close',...
1365 'fontsize',12, ...
1366 'Tag','close', ...
1367 'backgroundcolor','m', ...
1368 'ToolTipString','Close GUI', ...
1369 'Style','pushbutton');
1370
1371 dat.help_msg=sprintf(['Hold mouse cursor over a GUI control for an explanation of what it does.\n\n', ...
1372 'Frequency x power axes visualizes EEG spectral power, t-score of power, standard error of power, or root mean spectra squared simultaneously at multiple electrodes. ' ...
1373 'Each colored line corresponds to a different electrode.\n\nClick on Freq x power/t-score/stderr/RMS axis to visualize the scalp topography\n', ...
1374 'at that frequency.\n\nClick on electrodes in scalp topography to see electrode name.\n\n', ...
1375 'This GUI was produced by gui_pow.m']);
1376
1377
1378 uicontrol(dat.fig_id,...
1379 'CallBack','dat=get(gcbf,''userdata''); helpdlg(dat.help_msg,''POW GUI Help'');', ...
1380 'Units','normalized', ...
1381 'Position',[ 0.87 0.01 0.11 0.05 ],...
1382 'String','Help',...
1383 'fontsize',12, ...
1384 'Tag','help', ...
1385 'ToolTipString','Click for help', ...
1386 'Style','pushbutton');
1387 dat.interrupt=1;
1388 set(dat.fig_id,'userdata',dat);
1389 elseif strcmpi(cmnd_str,'freq jump'),
1390 new_freq=find_tpt(str2num(get(dat.h_topo_freq,'string')), ...
1391 dat.freqs);
1392 if new_freq<dat.start_pt,
1393 errordlg('That frequency is too low.');
1394 elseif new_freq>dat.end_pt,
1395 errordlg('That frequency is too high.');
1396 else
1397 set(dat.h_topo_freq,'string',num2str(dat.freqs(new_freq)));
1398 set(dat.h_lineA,'XData',[1 1]*dat.freqs(new_freq));
1399 set(dat.h_lineB,'XData',[1 1]*dat.freqs(new_freq));
1400 set(dat.fig_id,'userdata',dat);
1401 bin=get(dat.h_bin,'value');
1402 redraw_topos(dat,~dat.dif(bin));
1403 drawnow;
1404 end
1405 elseif strcmpi(cmnd_str,'back one'),
1406 current_freq=find_tpt(str2double(get(dat.h_topo_freq,'string')), ...
1407 dat.freqs);
1408 new_freq=current_freq-1;
1409 if new_freq<dat.start_pt,
1410 errordlg('Can''t go back any further.');
1411 else
1412 set(dat.h_topo_freq,'string',num2str(dat.freqs(new_freq)));
1413 set(dat.h_lineA,'XData',[1 1]*dat.freqs(new_freq));
1414 set(dat.h_lineB,'XData',[1 1]*dat.freqs(new_freq));
1415 set(dat.fig_id,'userdata',dat);
1416 bin=get(dat.h_bin,'value');
1417 redraw_topos(dat,~dat.dif(bin));
1418 drawnow;
1419 end
1420 elseif strcmpi(cmnd_str,'forward one'),
1421 current_freq=find_tpt(str2double(get(dat.h_topo_freq,'string')), ...
1422 dat.freqs);
1423 new_freq=current_freq+1;
1424 if new_freq>dat.end_pt,
1425 errordlg('Can''t go forward any further.');
1426 else
1427 set(dat.h_topo_freq,'string',num2str(dat.freqs(new_freq)));
1428 set(dat.h_lineA,'XData',[1 1]*dat.freqs(new_freq));
1429 set(dat.h_lineB,'XData',[1 1]*dat.freqs(new_freq));
1430 set(dat.fig_id,'userdata',dat);
1431 bin=get(dat.h_bin,'value');
1432 redraw_topos(dat,~dat.dif(bin));
1433 drawnow;
1434 end
1435 elseif strcmpi(cmnd_str,'back'),
1436 interrupt=0;
1437 dat.interrupt=0;
1438 set(dat.h_stop,'enable','on');
1439 set(dat.h_forward,'enable','off');
1440 set(dat.h_back,'enable','off');
1441 set(dat.h_forward1,'enable','off');
1442 set(dat.h_back1,'enable','off');
1443 set(dat.fig_id,'userdata',dat);
1444 bin=get(dat.h_bin,'value');
1445 redraw_cbar=~dat.dif(bin);
1446 drawnow;
1447 current_freq=find_tpt(str2double(get(dat.h_topo_freq,'string')), ...
1448 dat.freqs);
1449 new_freq=current_freq-1;
1450 loop_ct=0;
1451 while (new_freq>=dat.start_pt) && (interrupt~=1),
1452 set(dat.h_topo_freq,'string',num2str(dat.freqs(new_freq)));
1453 set(dat.h_lineA,'XData',[1 1]*dat.freqs(new_freq));
1454 set(dat.h_lineB,'XData',[1 1]*dat.freqs(new_freq));
1455 drawnow('update');
1456 redraw_topos(dat,redraw_cbar);
1457 drawnow;
1458 new_freq=new_freq-1;
1459 loop_ct=loop_ct+1;
1460 if loop_ct==5,
1461 loop_ct=0;
1462 new_tmp=get(dat.fig_id,'userdata');
1463 interrupt=new_tmp.interrupt;
1464 end
1465 end
1466 drawnow;
1467 dat.interrupt=0;
1468 new_freq=new_freq+1;
1469 set(dat.h_topo_freq,'string',num2str(dat.freqs(new_freq)));
1470 set(dat.h_stop,'enable','off');
1471 set(dat.h_forward,'enable','on');
1472 set(dat.h_back,'enable','on');
1473 set(dat.h_forward1,'enable','on');
1474 set(dat.h_back1,'enable','on');
1475 set(dat.fig_id,'userdata',dat);
1476 elseif strcmpi(cmnd_str,'forward'),
1477 interrupt=0;
1478 dat.interrupt=0;
1479 set(dat.h_stop,'enable','on');
1480 set(dat.h_forward,'enable','off');
1481 set(dat.h_back,'enable','off');
1482 set(dat.h_forward1,'enable','off');
1483 set(dat.h_back1,'enable','off');
1484 set(dat.fig_id,'userdata',dat);
1485 bin=get(dat.h_bin,'value');
1486 redraw_cbar=~dat.dif(bin);
1487 drawnow;
1488 current_freq=find_tpt(str2double(get(dat.h_topo_freq,'string')), ...
1489 dat.freqs);
1490 new_freq=current_freq+1;
1491 loop_ct=0;
1492 while (new_freq<=dat.end_pt) && (interrupt~=1),
1493 set(dat.h_topo_freq,'string',num2str(dat.freqs(new_freq)));
1494 set(dat.h_lineA,'XData',[1 1]*dat.freqs(new_freq));
1495 set(dat.h_lineB,'XData',[1 1]*dat.freqs(new_freq));
1496 drawnow('update');
1497 redraw_topos(dat,redraw_cbar);
1498 drawnow;
1499 new_freq=new_freq+1;
1500 loop_ct=loop_ct+1;
1501 if loop_ct==5,
1502 loop_ct=0;
1503 new_tmp=get(dat.fig_id,'userdata');
1504 interrupt=new_tmp.interrupt;
1505 end
1506 end
1507 drawnow;
1508 dat.interrupt=0;
1509 new_freq=new_freq-1;
1510 set(dat.h_topo_freq,'string',num2str(dat.freqs(new_freq)));
1511 set(dat.h_stop,'enable','off');
1512 set(dat.h_forward,'enable','on');
1513 set(dat.h_back,'enable','on');
1514 set(dat.h_forward1,'enable','on');
1515 set(dat.h_back1,'enable','on');
1516 set(dat.fig_id,'userdata',dat);
1517 elseif strcmpi(cmnd_str,'change stat'),
1518 stat=get(dat.h_stat,'value');
1519 current_bin=get(dat.h_bin,'value');
1520 if (stat~=3),
1521
1522 if isinf(dat.t_scores(1,1,current_bin)) || isnan(dat.t_scores(1,1,current_bin))
1523 stat=3;
1524 set(dat.h_stat,'value',stat);
1525 if (stat==2)
1526 warndlg('Only one participant contributed to this bin. Thus the grand average standard error cannot be esimated.','gui_pow Warning');
1527 else
1528 warndlg('Only one participant contributed to this bin. Thus the grand average t-scores cannot be derived.','gui_pow Warning');
1529 end
1530 end
1531 end
1532
1533 if (stat==1),
1534
1535 if ~isempty(dat.h_crit1),
1536 delete(dat.h_crit1);
1537 end
1538 if ~isempty(dat.h_crit2),
1539 delete(dat.h_crit2);
1540 end
1541 dat.h_crit1=[];
1542 dat.h_crit2=[];
1543
1544 if ~isempty(dat.h_alph1),
1545 delete(dat.h_alph1);
1546 end
1547 if ~isempty(dat.h_alph2),
1548 delete(dat.h_alph2);
1549 end
1550 dat.h_alph1=[];
1551 dat.h_alph2=[];
1552 end
1553
1554
1555 draw_waveforms(dat,0);
1556 gui_pow('update dashed lines');
1557 elseif strcmpi(cmnd_str,'change bin'),
1558 new_bin=get(dat.h_bin,'value');
1559 crnt_ttest_id=get(dat.h_ptest,'value');
1560 n_t_tests=length(dat.t_tests);
1561 if (crnt_ttest_id==(n_t_tests+1)) || (dat.t_tests(crnt_ttest_id).bin~=new_bin),
1562
1563
1564
1565
1566
1567 crnt_ttest_id=n_t_tests+1;
1568 for a=1:n_t_tests,
1569 if dat.t_tests(a).bin==new_bin;
1570 crnt_ttest_id=a;
1571 break;
1572 end
1573 end
1574 set(dat.h_ptest,'value',crnt_ttest_id);
1575 dat=update_test(dat);
1576 end
1577 draw_waveforms(dat,1);
1578 gui_pow('update dashed lines');
1579 elseif strcmpi(cmnd_str,'new freq limits'),
1580
1581 plotted_freqs=dat.freqs(dat.start_pt:dat.end_pt);
1582 freq_lim=str2num(get(dat.h_freqrange,'string'));
1583 if length(freq_lim)~=2,
1584 errordlg('Enter exactly two values for frequency range (desired Min and Max values).','gui_pow Error');
1585 set(dat.h_freqrange,'string',num2str([plotted_freqs(1) plotted_freqs(end)]));
1586 elseif freq_lim(2)<freq_lim(1),
1587 errordlg('The frequency range value must be greater than the first (enter desired Min then Max).','gui_pow Error');
1588 set(dat.h_freqrange,'string',num2str([plotted_freqs(1) plotted_freqs(end)]));
1589 elseif (freq_lim(1)<dat.freqs(1)) || (freq_lim(2)>dat.freqs(end))
1590 errordlg(sprintf('Frequency range values must be between %d and %d Hz.',dat.freqs(1),dat.freqs(end)),'gui_pow Error');
1591 set(dat.h_freqrange,'string',num2str([plotted_freqs(1) plotted_freqs(end)]));
1592 else
1593
1594 set(dat.h_freqA,'xlim',freq_lim);
1595 set(dat.h_freqB,'xlim',freq_lim);
1596 dat.start_pt=find_tpt(freq_lim(1),dat.freqs);
1597 dat.end_pt=find_tpt(freq_lim(2),dat.freqs);
1598
1599
1600 dat.absmxA=max(max(abs(dat.showingA(:,dat.start_pt:dat.end_pt))));
1601 dat.absmxB=max(max(abs(dat.showingB(:,dat.start_pt:dat.end_pt))));
1602 current_freq=find_tpt(str2double(get(dat.h_topo_freq,'string')), ...
1603 dat.freqs);
1604 if (current_freq>dat.end_pt) || (current_freq<dat.start_pt)
1605
1606
1607
1608 bin=get(dat.h_bin,'value');
1609 [dummy, mx_tpt]=max(dat.rms(dat.start_pt:dat.end_pt,bin));
1610 showing_pts=dat.start_pt:dat.end_pt;
1611 set(dat.h_lineA,'xdata',[1 1]*dat.freqs(showing_pts(mx_tpt)));
1612 set(dat.h_lineB,'xdata',[1 1]*dat.freqs(showing_pts(mx_tpt)));
1613
1614 set(dat.h_topo_freq,'string',num2str(dat.freqs(showing_pts(mx_tpt))));
1615 end
1616
1617 redraw_topos(dat,1);
1618 set(dat.fig_id,'userdata',dat);
1619 end
1620 elseif strcmpi(cmnd_str,'new statistic limitsA'),
1621
1622 plotted_limits=get(dat.h_freqA,'ylim');
1623 new_lim=str2num(get(dat.h_statrangeA,'string'));
1624 if length(new_lim)~=2,
1625 errordlg('Enter exactly two values for statistic range (desired Min and Max values).','gui_pow Error');
1626 set(dat.h_statrangeA,'string',num2str([plotted_limits(1) plotted_limits(end)]));
1627 elseif new_lim(2)<new_lim(1),
1628 errordlg('The second statistic range value must be greater than the first (enter desired Min then Max).','gui_pow Error');
1629 set(dat.h_statrangeA,'string',num2str([plotted_limits(1) plotted_limits(end)]));
1630 else
1631
1632 set(dat.h_freqA,'ylim',new_lim);
1633 set(dat.h_lineA,'YData',new_lim);
1634
1635
1636 if ~isempty(dat.h_wind1A)
1637 set(dat.h_wind1A,'YData',new_lim);
1638 set(dat.h_wind2A,'YData',new_lim);
1639 end
1640 end
1641 elseif strcmpi(cmnd_str,'new statistic limitsB'),
1642
1643 plotted_limits=get(dat.h_freqB,'ylim');
1644 new_lim=str2num(get(dat.h_statrangeB,'string'));
1645 if length(new_lim)~=2,
1646 errordlg('Enter exactly two values for statistic range (desired Min and Max values).','gui_pow Error');
1647 set(dat.h_statrangeB,'string',num2str([plotted_limits(1) plotted_limits(end)]));
1648 elseif new_lim(2)<new_lim(1),
1649 errordlg('The second statistic range value must be greater than the first (enter desired Min then Max).','gui_pow Error');
1650 set(dat.h_statrangeB,'string',num2str([plotted_limits(1) plotted_limits(end)]));
1651 else
1652
1653 set(dat.h_freqB,'ylim',new_lim);
1654 set(dat.h_lineB,'YData',new_lim);
1655
1656
1657 if ~isempty(dat.h_wind1B)
1658 set(dat.h_wind1B,'YData',new_lim);
1659 set(dat.h_wind2B,'YData',new_lim);
1660 end
1661 end
1662 elseif strcmpi(cmnd_str,'redraw topo'),
1663 redraw_topos(dat,1);
1664 elseif strcmpi(cmnd_str,'update dashed lines'),
1665 test_wind=str2num(get(dat.h_testwind,'string'));
1666
1667 if (size(test_wind,2)>2) || (isempty(test_wind) && ~isempty(get(dat.h_testwind,'string')))
1668 errordlg('Enter pairs of values for frequency band range (desired Min and Max values) or leave box blank. Separate multiple pairs with semicolons.', ...
1669 'gui_pow Error');
1670 elseif length(dat.critical_t)>2,
1671 errordlg('Enter one (for one-tailed test) or two (for two-tailed test) value(s) for critical t-scores or leave box blank.', ...
1672 'gui_pow Error');
1673 else
1674 if isempty(test_wind),
1675 test_wind=[NaN NaN];
1676 end
1677
1678
1679 if ~isempty(dat.h_crit1),
1680 delete(dat.h_crit1);
1681 end
1682 if ~isempty(dat.h_crit2),
1683 delete(dat.h_crit2);
1684 end
1685 if ~isempty(dat.h_alph1),
1686 delete(dat.h_alph1);
1687 end
1688 if ~isempty(dat.h_alph2),
1689 delete(dat.h_alph2);
1690 end
1691 if ~isempty(dat.h_wind1A),
1692 delete(dat.h_wind1A);
1693 end
1694 if ~isempty(dat.h_wind2A),
1695 delete(dat.h_wind2A);
1696 end
1697 if ~isempty(dat.h_wind1B),
1698 delete(dat.h_wind1B);
1699 end
1700 if ~isempty(dat.h_wind2B),
1701 delete(dat.h_wind2B);
1702 end
1703 dat.h_wind1A=[];
1704 dat.h_wind2A=[];
1705 dat.h_wind1B=[];
1706 dat.h_wind2B=[];
1707 dat.h_crit1=[];
1708 dat.h_crit2=[];
1709 dat.h_alph1=[];
1710 dat.h_alph2=[];
1711 dat.n_wind=size(test_wind,1);
1712
1713 if ~sum(isnan(test_wind))
1714 y_rngA=get(dat.h_freqA,'YLim');
1715 y_rngB=get(dat.h_freqB,'YLim');
1716
1717 axes(dat.h_freqA);
1718 for nw=1:dat.n_wind,
1719 dat.h_wind1A(nw)=plot([1 1]*test_wind(nw,1),y_rngA,'k--');
1720 set(dat.h_wind1A(nw),'linewidth',2);
1721 dat.h_wind2A(nw)=plot([1 1]*test_wind(nw,2),y_rngA,'k--');
1722 set(dat.h_wind2A(nw),'linewidth',2);
1723 end
1724
1725 axes(dat.h_freqB);
1726 for nw=1:dat.n_wind,
1727 dat.h_wind1B(nw)=plot([1 1]*test_wind(nw,1),y_rngB,'k--');
1728 set(dat.h_wind1B(nw),'linewidth',2);
1729 dat.h_wind2B(nw)=plot([1 1]*test_wind(nw,2),y_rngB,'k--');
1730 set(dat.h_wind2B(nw),'linewidth',2);
1731 end
1732
1733
1734 stat=get(dat.h_stat,'value');
1735
1736
1737 if ~sum(isnan(dat.critical_t)) && (stat==1) && ~isempty(dat.critical_t)
1738 for nw=1:dat.n_wind,
1739 dat.h_crit1(nw)=plot(test_wind(nw,:),[1 1]*dat.critical_t(1),'r--');
1740 set(dat.h_crit1(nw),'linewidth',3);
1741 if nw==1,
1742
1743 tm_rng=dat.freqs(end)-dat.freqs(1);
1744 if strcmpi(dat.mltplcmp_crct,'fdr')
1745 dat.h_alph1=text(test_wind(nw,1)-tm_rng*.02,dat.critical_t(1), ...
1746 ['q=' num2str(rnd_orderofmag(dat.alpha))]);
1747 else
1748 dat.h_alph1=text(test_wind(nw,1)-tm_rng*.02,dat.critical_t(1), ...
1749 ['\alpha=' num2str(rnd_orderofmag(dat.alpha))]);
1750 end
1751 set(dat.h_alph1,'color','r','fontweight','normal','fontsize',12, ...
1752 'horizontalalignment','right','backgroundcolor',[1 1 1], ...
1753 'edgecolor',[1 1 1]*.3,'clipping','on','fontname','fixedwidth');
1754 end
1755 if length(dat.critical_t)>1,
1756 dat.h_crit2(nw)=plot(test_wind(nw,:),[1 1]*dat.critical_t(2),'r--');
1757 set(dat.h_crit2(nw),'linewidth',3);
1758 if nw==1,
1759
1760 if strcmpi(dat.mltplcmp_crct,'fdr')
1761 dat.h_alph2=text(test_wind(1)-tm_rng*.02,dat.critical_t(2), ...
1762 ['q=' num2str(rnd_orderofmag(dat.alpha))]);
1763 else
1764 dat.h_alph2=text(test_wind(1)-tm_rng*.02,dat.critical_t(2), ...
1765 ['\alpha=' num2str(rnd_orderofmag(dat.alpha))]);
1766 end
1767 set(dat.h_alph2,'color','r','fontweight','normal','fontsize',12, ...
1768 'horizontalalignment','right','backgroundcolor',[1 1 1], ...
1769 'edgecolor',[1 1 1]*.3,'clipping','on','fontname','fixedwidth');
1770 end
1771 end
1772 end
1773 end
1774 end
1775 set(dat.fig_id,'userdata',dat);
1776 redraw_topos(dat,1);
1777 end
1778 elseif strcmpi(cmnd_str,'update critical t'),
1779 critical_t=str2num(get(dat.h_critval,'string'));
1780 if ~isequal(sort(critical_t),sort(dat.critical_t)),
1781 new_alpha=[];
1782 while isempty(new_alpha),
1783 new_alpha=inputdlg({'Enter alpha level for new critical t-score(s)'}, ...
1784 'Set New Alpha Level',1,{num2str(dat.alpha)});
1785 new_alpha=str2num(new_alpha{1});
1786 if isempty(new_alpha),
1787 errrodlg('You must enter a numeric value for the new alpha level','gui_pow Error');
1788 end
1789 end
1790 dat.alpha=new_alpha;
1791 dat.critical_t=critical_t;
1792 end
1793 set(dat.fig_id,'userdata',dat);
1794 gui_pow('update dashed lines');
1795 elseif strcmpi(cmnd_str,'change test'),
1796 [dat, redraw_wform]=update_test(dat);
1797 if redraw_wform,
1798 draw_waveforms(dat,1);
1799 end
1800 gui_pow('update dashed lines');
1801 else
1802 errordlg(sprintf('Command "%s" not recognized by gui_pow.m',cmnd_str), ...
1803 'gui_pow Error');
1804 end
1805
1806
1807 function draw_waveforms(dat,redrawA)
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817 new_bin=get(dat.h_bin,'value');
1818 stat=get(dat.h_stat,'value');
1819 crnt_ttest_id=get(dat.h_ptest,'value');
1820 n_t_tests=length(dat.t_tests);
1821 if crnt_ttest_id==n_t_tests+1,
1822
1823 dat.showing_chans=dat.loaded_chans;
1824 else
1825 dat.showing_chans=intersect(dat.t_tests(crnt_ttest_id).used_chan_ids, ...
1826 dat.loaded_chans);
1827 end
1828
1829
1830 axes(dat.h_freqB);
1831 delete(dat.h_showingB);
1832 delete(dat.h_lineB);
1833 plotted_freqs=dat.freqs(dat.start_pt:dat.end_pt);
1834
1835 if (crnt_ttest_id<=n_t_tests) && dat.t_tests(crnt_ttest_id).null_mean
1836
1837 dat.showing_t=squeeze( (dat.spec(dat.showing_chans,:,new_bin)- ...
1838 dat.t_tests(crnt_ttest_id).null_mean)./dat.stder(dat.showing_chans,:,new_bin) );
1839 else
1840 dat.showing_t=squeeze(dat.t_scores(dat.showing_chans,:,new_bin));
1841 end
1842
1843 if (stat==1),
1844
1845 dat.showingB=dat.showing_t;
1846 cbar_title='t-score';
1847 ylab='t-score';
1848 if dat.dif(new_bin)
1849 dat.h_db_zeroB=plot([dat.freqs(1) dat.freqs(end)],[0 0],'k');
1850 hold on;
1851 elseif ~isempty(dat.h_db_zeroB)
1852 delete(dat.h_db_zeroB);
1853 dat.h_db_zeroB=[];
1854 end
1855 elseif (stat==2),
1856
1857 dat.showingB=squeeze(dat.stder(dat.showing_chans,:,new_bin));
1858 cbar_title='10*log10(\muV^2/Hz)';
1859 ylab='10*log10(\muV^2/Hz) (StdEr)';
1860 if ~isempty(dat.h_db_zeroB)
1861 delete(dat.h_db_zeroB);
1862 dat.h_db_zeroB=[];
1863 end
1864 elseif (stat==3),
1865
1866 dat.showingB=dat.rms(:,new_bin)';
1867 cbar_title='Not Applicable';
1868 ylab='\muV/sqrt(Hz) (RMS)';
1869 if ~isempty(dat.h_db_zeroB)
1870 delete(dat.h_db_zeroB);
1871 dat.h_db_zeroB=[];
1872 end
1873 end
1874 if size(dat.showingB,1)==1,
1875
1876 dat.h_showingB=plot(dat.freqs,dat.showingB);
1877 cbar_title='Not Applicable';
1878 cbar_title_fontsize=10;
1879 else
1880 dat.h_showingB=plot(dat.freqs,dat.showingB');
1881 cbar_title_fontsize=14;
1882 end
1883 set(dat.h_freq_ylabB,'string',ylab);
1884
1885 stat_mx=max(max(dat.showingB));
1886 stat_mn=min(min(dat.showingB));
1887 stat_rng=stat_mx-stat_mn;
1888 stat_plt_rng=[stat_mn-stat_rng*.02 stat_mx+stat_rng*.02];
1889 stat_plt_rng=round(stat_plt_rng*100)/100;
1890 axis([plotted_freqs(1) plotted_freqs(end) stat_plt_rng]);
1891 set(dat.h_statrangeB,'string',num2str(stat_plt_rng));
1892 current_freq=find_tpt(str2double(get(dat.h_topo_freq,'string')), ...
1893 dat.freqs);
1894 h_lineB=plot([1 1]*dat.freqs(current_freq),stat_plt_rng,'k');
1895 set(h_lineB,'linewidth',2);
1896 dat.h_lineB=h_lineB;
1897
1898 bdf_code = [ 'tmppos = get(gca, ''currentpoint'');' ...
1899 'dat=get(gcbf, ''userdata'');' ...
1900 'new_freq=find_tpt(tmppos(1,1),dat.freqs);' ...
1901 'set(dat.h_lineA,''XData'',[1 1]*dat.freqs(new_freq));' ...
1902 'set(dat.h_lineB,''XData'',[1 1]*dat.freqs(new_freq));' ...
1903 'set(dat.h_topo_freq,''string'',num2str(dat.freqs(new_freq)));' ...
1904 'set(dat.fig_id,''userdata'',dat);' ...
1905 'gui_pow(''redraw topo'');' ...
1906 'drawnow;' ...
1907 'clear latpoint dattmp tmppos;' ...
1908 ];
1909 set(dat.h_showingB,'ButtonDownFcn',bdf_code);
1910 set(dat.h_freqB,'ButtonDownFcn',bdf_code);
1911
1912
1913 dat.absmxB=max(max(abs(dat.showingB(:,dat.start_pt:dat.end_pt))));
1914 axes(dat.h_cbarB);
1915 cla;
1916 cbar(dat.h_cbarB);
1917 absmx=round(dat.absmxB*100)/100;
1918 set(gca,'xticklabel',[-absmx 0 absmx]);
1919 h_cbar_title=title(cbar_title);
1920 set(h_cbar_title,'fontsize',cbar_title_fontsize);
1921
1922 if redrawA,
1923
1924 new_title=['Bin ' int2str(new_bin) ': ' dat.bindesc{new_bin}];
1925 title_max_char=43;
1926 if length(new_title)>title_max_char,
1927 new_title=new_title(1:title_max_char);
1928 end
1929 set(dat.h_freq_title,'string',new_title);
1930
1931
1932
1933 axes(dat.h_freqA);
1934 delete(dat.h_showingA);
1935 delete(dat.h_lineA);
1936 plotted_freqs=dat.freqs(dat.start_pt:dat.end_pt);
1937 if dat.dif(new_bin)
1938 dat.h_db_zeroA=plot([dat.freqs(1) dat.freqs(end)],[0 0],'k');
1939 else
1940 if ~isempty(dat.h_db_zeroA)
1941 delete(dat.h_db_zeroA);
1942 dat.h_db_zeroA=[];
1943 end
1944 end
1945 hold on;
1946
1947
1948 if (crnt_ttest_id<=n_t_tests) && dat.t_tests(crnt_ttest_id).null_mean
1949
1950 dat.showing_t=squeeze( (dat.spec(dat.showing_chans,:,new_bin)- ...
1951 dat.t_tests(crnt_ttest_id).null_mean)./dat.stder(dat.showing_chans,:,new_bin) );
1952 else
1953 dat.showing_t=squeeze(dat.t_scores(dat.showing_chans,:,new_bin));
1954 end
1955
1956 dat.showingA=squeeze(dat.spec(dat.showing_chans,:,new_bin));
1957 cbar_title='10*log10(\muV^2/Hz)';
1958 ylab='10*log10(\muV^2/Hz)';
1959 if size(dat.showingA,1)==1,
1960
1961 dat.h_showingA=plot(dat.freqs,dat.showingA);
1962 cbar_title='Not Applicable';
1963 cbar_title_fontsize=10;
1964 else
1965 dat.h_showingA=plot(dat.freqs,dat.showingA');
1966 end
1967 set(dat.h_freq_ylabA,'string',ylab);
1968
1969 stat_mx=max(max(dat.showingA));
1970 stat_mn=min(min(dat.showingA));
1971 stat_rng=stat_mx-stat_mn;
1972 stat_plt_rng=[stat_mn-stat_rng*.02 stat_mx+stat_rng*.02];
1973 stat_plt_rng=round(stat_plt_rng*100)/100;
1974 axis([plotted_freqs(1) plotted_freqs(end) stat_plt_rng]);
1975 set(dat.h_statrangeA,'string',num2str(stat_plt_rng));
1976 current_freq=find_tpt(str2double(get(dat.h_topo_freq,'string')), ...
1977 dat.freqs);
1978 h_lineA=plot([1 1]*dat.freqs(current_freq),stat_plt_rng,'k');
1979 set(h_lineA,'linewidth',2);
1980 dat.h_lineA=h_lineA;
1981
1982 bdf_code = [ 'tmppos = get(gca, ''currentpoint'');' ...
1983 'dat=get(gcbf, ''userdata'');' ...
1984 'new_freq=find_tpt(tmppos(1,1),dat.freqs);' ...
1985 'set(dat.h_lineA,''XData'',[1 1]*dat.freqs(new_freq));' ...
1986 'set(dat.h_lineB,''XData'',[1 1]*dat.freqs(new_freq));' ...
1987 'set(dat.h_topo_freq,''string'',num2str(dat.freqs(new_freq)));' ...
1988 'set(dat.fig_id,''userdata'',dat);' ...
1989 'gui_pow(''redraw topo'');' ...
1990 'drawnow;' ...
1991 'clear latpoint dattmp tmppos;' ...
1992 ];
1993 set(dat.h_freqA,'ButtonDownFcn',bdf_code);
1994 set(dat.h_showingA,'ButtonDownFcn',bdf_code);
1995
1996
1997 dat.absmxA=max(max(abs(dat.showingA(:,dat.start_pt:dat.end_pt))));
1998 axes(dat.h_cbarA);
1999 cla;
2000 cbar(dat.h_cbarA);
2001 absmx=round(dat.absmxA*100)/100;
2002 set(gca,'xticklabel',[-absmx 0 absmx]);
2003 h_cbar_title=title(cbar_title);
2004 set(h_cbar_title,'fontsize',cbar_title_fontsize);
2005 end
2006
2007 set(dat.fig_id,'userdata',dat);
2008
2009
2010
2011
2012
2013 function [dat, redraw_wform]=update_test(dat)
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027 crnt_ttest=get(dat.h_ptest,'value');
2028
2029 n_psbl_tests=length(dat.psbl_tests);
2030 crnt_bin=get(dat.h_bin,'value');
2031 redraw_wform=0;
2032 if n_psbl_tests<crnt_ttest,
2033
2034 set(dat.h_testwind,'string',[]);
2035 dat.alpha=[];
2036 dat.critical_t=[];
2037 dat.mltplcmp_crct=[];
2038 set(dat.h_critval,'string',[]);
2039
2040 if ~isequal(dat.loaded_chans,dat.showing_chans)
2041 redraw_wform=1;
2042 end
2043 else
2044 ptest_bin=dat.t_tests(crnt_ttest).bin;
2045 if ptest_bin~=crnt_bin,
2046 redraw_wform=1;
2047 set(dat.h_bin,'value',ptest_bin);
2048 end
2049
2050
2051
2052 crnt_null_mean=dat.null_mean;
2053 if crnt_null_mean~=dat.t_tests(crnt_ttest).null_mean,
2054 redraw_wform=1;
2055 end
2056 dat.null_mean=dat.t_tests(crnt_ttest).null_mean;
2057
2058
2059 test_wind=dat.t_tests(crnt_ttest).freq_band;
2060 dat.n_wind=size(test_wind,1);
2061 wind_edges=[];
2062 for nw=1:dat.n_wind,
2063 if nw==dat.n_wind,
2064 wind_edges=[wind_edges num2str(test_wind(nw,:))];
2065 else
2066 wind_edges=[wind_edges num2str(test_wind(nw,:)) '; '];
2067 end
2068 end
2069 set(dat.h_testwind,'string',wind_edges);
2070
2071
2072
2073 if ~isempty(setdiff(dat.t_tests(crnt_ttest).used_chan_ids, ...
2074 dat.loaded_chans)),
2075 warndlg('The set of t-tests you selected includes some channels that were excluded when you created this GUI. Keep this in mind when interpreting the visualization.','gui_pow Warning');
2076 end
2077
2078
2079
2080 if ~isequal(dat.t_tests(crnt_ttest).used_chan_ids,dat.showing_chans)
2081 redraw_wform=1;
2082 end
2083
2084
2085 if isnan(dat.t_tests(crnt_ttest).estimated_alpha)
2086 dat.alpha=dat.t_tests(crnt_ttest).desired_alphaORq;
2087 dat.mltplcmp_crct='fdr';
2088 else
2089 dat.alpha=dat.t_tests(crnt_ttest).estimated_alpha;
2090 dat.mltplcmp_crct='perm';
2091 end
2092 dat.critical_t=dat.t_tests(crnt_ttest).crit_t;
2093 set(dat.h_critval,'string',num2str(dat.critical_t));
2094 end
2095 set(dat.fig_id,'userdata',dat);
2096
2097
2098 function redraw_topos(dat,redraw_cbars)
2099
2100 current_freq=find_tpt(str2double(get(dat.h_topo_freq,'string')), ...
2101 dat.freqs);
2102
2103 test_wind=str2num(get(dat.h_testwind,'string'));
2104 critical_t=str2num(get(dat.h_critval,'string'));
2105
2106 if ~isempty(test_wind) && ~isempty(critical_t),
2107 n_showing=length(dat.showing_chans);
2108 sig_chans=zeros(1,n_showing);
2109
2110
2111
2112 for nw=1:dat.n_wind,
2113 if (dat.freqs(current_freq)>=test_wind(nw,1)) && (dat.freqs(current_freq)<=test_wind(nw,2)),
2114 if length(critical_t)==2,
2115 sig_chans(dat.showing_t(:,current_freq)>max(critical_t))=1;
2116 sig_chans(dat.showing_t(:,current_freq)<min(critical_t))=1;
2117 else
2118 if critical_t>0,
2119 sig_chans(dat.showing_t(:,current_freq)>critical_t)=1;
2120 else
2121 sig_chans(dat.showing_t(:,current_freq)<critical_t)=1;
2122 end
2123 end
2124 break;
2125 end
2126 end
2127 sig_chans=find(sig_chans>0);
2128 else
2129 sig_chans=[];
2130 end
2131
2132
2133 set(dat.fig_id,'CurrentAxes',dat.h_topoA);
2134
2135 if size(dat.showingA,1)<=2,
2136
2137 topoplotMK(dat.showingA(:,current_freq),dat.chanlocs(dat.showing_chans), ...
2138 'style','blank','plain_blank',1,'emarker2',{sig_chans,'o',[1 1 1],4});
2139
2140
2141
2142
2143 topo_xtick_labA={' ',' ',' '};
2144 topo_xtick_labB={' ',' ',' '};
2145
2146 if get(dat.h_stat,'value')==3,
2147
2148 if redraw_cbars,
2149
2150
2151 set(dat.fig_id,'CurrentAxes',dat.h_topoB);
2152 topoplotMK(dat.showingA(:,current_freq),dat.chanlocs(dat.showing_chans), ...
2153 'style','blank','plain_blank',1);
2154 end
2155 else
2156
2157 set(dat.fig_id,'CurrentAxes',dat.h_topoB);
2158 topoplotMK(dat.showingB(:,current_freq),dat.chanlocs(dat.showing_chans), ...
2159 'style','blank','plain_blank',1,'emarker2',{sig_chans,'o',[1 1 1],4});
2160 end
2161 else
2162 bin=get(dat.h_bin,'value');
2163 if dat.dif(bin),
2164
2165 dat.mx_topoA=max(max(abs(dat.showingA(:,dat.start_pt:dat.end_pt))));
2166 dat.mn_topoA=-dat.mx_topoA;
2167 dat.mx_topoB=max(max(abs(dat.showingB(:,dat.start_pt:dat.end_pt))));
2168 dat.mn_topoB=-dat.mx_topoB;
2169 else
2170
2171
2172 dat.mx_topoA=max(max(dat.showingA(:,current_freq)));
2173 dat.mn_topoA=min(min(dat.showingA(:,current_freq)));
2174 dat.mx_topoB=max(max(dat.showingB(:,current_freq)));
2175 dat.mn_topoB=min(min(dat.showingB(:,current_freq)));
2176 end
2177 topo_xtick_labA=[dat.mn_topoA 0 dat.mx_topoA];
2178 topo_xtick_labA=round(topo_xtick_labA*100)/100;
2179 topo_xtick_labB=[dat.mn_topoB 0 dat.mx_topoB];
2180 topo_xtick_labB=round(topo_xtick_labB*100)/100;
2181 topoplotMK(dat.showingA(:,current_freq),dat.chanlocs(dat.showing_chans),'maplimits', ...
2182 [dat.mn_topoA dat.mx_topoA],'emarker2',{sig_chans,'o',[1 1 1],4});
2183 set(findobj(gca,'type','patch'),'facecolor',[1 1 1]*.702);
2184
2185 if get(dat.h_stat,'value')==3,
2186
2187 if redraw_cbars,
2188
2189 set(dat.fig_id,'CurrentAxes',dat.h_topoB);
2190 topoplotMK([],dat.chanlocs(dat.showing_chans), ...
2191 'style','blank','plain_blank',1);
2192
2193
2194
2195 topo_xtick_labB={' ',' ',' '};
2196 set(findobj(gca,'type','patch'),'facecolor',[1 1 1]*.702);
2197 end
2198 else
2199
2200 set(dat.fig_id,'CurrentAxes',dat.h_topoB);
2201 topoplotMK(dat.showingB(:,current_freq),dat.chanlocs(dat.showing_chans),'maplimits', ...
2202 [dat.mn_topoB dat.mx_topoB],'emarker2',{sig_chans,'o',[1 1 1],4});
2203 set(findobj(gca,'type','patch'),'facecolor',[1 1 1]*.702);
2204 end
2205 end
2206
2207 if (redraw_cbars)
2208
2209
2210 set(dat.fig_id,'CurrentAxes',dat.h_cbarA);
2211 set(gca,'xticklabel',topo_xtick_labA);
2212
2213
2214
2215 set(dat.fig_id,'CurrentAxes',dat.h_cbarB);
2216 B_stat=get(dat.h_stat,'value');
2217 if B_stat==1,
2218
2219 cbar_title='t-score';
2220 cbar_title_fontsize=14;
2221 elseif B_stat==3,
2222
2223 cbar_title='Not Applicable';
2224 cbar_title_fontsize=10;
2225 else
2226
2227 cbar_title='10*log10(\muV^2/Hz)';
2228 cbar_title_fontsize=14;
2229 end
2230
2231 set(gca,'xticklabel',topo_xtick_labB);
2232 set(get(gca,'title'),'string',cbar_title,'fontsize',cbar_title_fontsize);
2233 end
2234 drawnow
2235