forked from LIMO-EEG-Toolbox/limo_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
limo_display_results_tf.m
executable file
·714 lines (621 loc) · 33.8 KB
/
limo_display_results_tf.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
function varargout = limo_display_results_tf(varargin)
% limo_display_results_tf: interactive GUI to display time*freq results
%
% INPUT limo_display_results_tf(LIMO,toplot,mask,title)
% 1 - LIMO struct
% 2 - 3D matrix of values to plot, dim elec x freqs x time-bins
% 3 - 3D matrix of significant cells
% 4 - title (from limo_stat_values_tf)
%
% A. Stewart v1 mar14 axs - basic GUI set up + 3D tf plots from 3 point-of-view
% C. Pernet added mask,title, - fixed various bugs - made it show topoplot and time courses +
% fixed the code to update at each 'click' 9-04-2014
% ---------------------------------------------------------------
% Copyright (C) LIMO Team 2014
%% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @limo_display_results_tf_OpeningFcn, ...
'gui_OutputFcn', @limo_display_results_tf_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before limo_display_results_tf is made visible.
function limo_display_results_tf_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.LIMO = varargin{1};
handles.data3d = varargin{2};
handles.mask = varargin{3};
scale = handles.data3d.*handles.mask;
scale(scale==0) = NaN;
handles.scale = scale;
handles.title = varargin{4};
handles.freqs_here = linspace(handles.LIMO.data.lowf,handles.LIMO.data.hightf,size(handles.data3d,2));
handles.times_here = linspace(handles.LIMO.data.start,handles.LIMO.data.end,size(handles.data3d,3));
handles.plot_sel = 1;
clear varargin scale
% Find max values, save idx and value
if (size(handles.data3d,4)) == 3
dim = inputdlg('which dimension to use','4D input - plotting option');
handles.data3d = handles.data3d(:,:,:,dim);
end
handles.maxv = max(handles.data3d(:));
handles.maxvi = find(handles.data3d == handles.maxv);
if length(handles.maxvi) ~= 1
handles.maxvi = handles.maxvi(1);
end
[handles.maxe, handles.maxf, handles.maxt] = ind2sub(size(handles.data3d), handles.maxvi);
handles.clims = [0 handles.maxv]; % Set the global default scale of the colour bar to be 0:max value
handles.slider_sel = handles.maxt; % 0.5
handles.ef = squeeze(handles.data3d(:,:,handles.maxt));
plot_data.freqs_here = handles.LIMO.data.tf_freqs; % (handles.LIMO.data.trim_low_f:handles.LIMO.data.trim_high_f);
plot_data.times_here = handles.LIMO.data.tf_times; % (handles.LIMO.data.trim1:handles.LIMO.data.trim2);
guidata(hObject, plot_data);
guidata(hObject, handles);
% ----------------------------------------------------------
% This sets up the initial plot - only do when we are invisible
% By Default we plot Electrode * Frequencies (slide in time)
% so window can get raised using limo_display_results_tf.
% ----------------------------------------------------------
if strcmp(get(hObject,'Visible'),'off')
ef = handles.ef;
freqp = numel(handles.freqs_here);
axes(handles.Main_display);
imagesc(squeeze(handles.scale(:,:,handles.maxt)),handles.clims);
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
mytitle = sprintf('%s plotted at %g ms',handles.title, round(handles.times_here(handles.maxt)));
title(mytitle,'fontsize',12);
set(gca, 'XTick',[1 2 3 4 5 6],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.freqs_here(1)), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(freqp))},'fontsize',12);
xlabel('Frequency bin (Hz)','fontsize',12);
ylabel('Electrodes','fontsize',12);
try
set(gca,'YTick',1:length(handles.LIMO.data.expected_chanlocs));
catch ME
set(gca,'YTick',1:length(handles.LIMO.data.chanlocs));
end
if handles.LIMO.Level == 1
for i = 1 : length(handles.LIMO.data.chanlocs)
try
label_electrodes{i} = handles.LIMO.data.expected_chanlocs(i).labels;
catch ME
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
end
else
if isempty(handles.LIMO.design.electrode)
for i = 1 : length(handles.LIMO.data.chanlocs)
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
else
if length(handles.LIMO.design.electrode) == 1
label_electrodes = handles.LIMO.design.electrode;
else
label_electrodes = ' ';
ylabel('optimized electrode','FontSize',14);
end
end
end
set(gca,'YTickLabel', label_electrodes);
% topoplot
axes(handles.topoplot);
topoplot(ef(:,handles.maxf),handles.LIMO.data.chanlocs);
title(['topoplot @ ' num2str(round(handles.freqs_here(handles.maxf))) ' Hz'],'FontSize',12)
% time/freq courses
axes(handles.tf_course_plot);
plot(handles.freqs_here,ef(handles.maxe,:),'LineWidth',3); grid on; axis tight
mytitle = sprintf('power spectrum @ \n electrode %s (%g)', handles.LIMO.data.chanlocs(handles.maxe).labels,handles.LIMO.data.chanlocs(handles.maxe).urchan);
title(mytitle,'FontSize',12);
% sub-displays
axes(handles.sub_display1); cla;
timep = numel(handles.times_here);
imagesc(squeeze(handles.scale(:,handles.maxf,:)));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
title(['Electrode x times @ ' num2str(round(handles.freqs_here(handles.maxf))) ' Hz'],'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Electrodes','fontsize',12);
axes(handles.sub_display2); cla;
imagesc(flipud(squeeze(handles.scale(handles.maxe,:,:))));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
set(gca, 'YTick',[1 freqp/4 freqp/2 3*freqp/4 freqp],'fontsize',12);
set(gca, 'YTickLabel',{round(handles.freqs_here(freqp)),round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(1))},'fontsize',12);
title(['Frequency x time @ electrode ' num2str(handles.LIMO.data.chanlocs(handles.maxe).labels)],'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Frequencies','fontsize',12);
end
function varargout = limo_display_results_tf_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% UIWAIT makes limo_display_results_tf wait for user response (see UIRESUME)
% uiwait(handles.figure1);
%% interactive part
% ------------------------------------------------------------------
% UPDATE: swith between Electrode * Frequencies (slide in time)
% and Electrode * Time (slide in Frequencies)
% ------------------------------------------------------------------
function Main_display_CreateFcn(hObject, eventdata, handles)
function topoplot_CreateFcn(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function pop_up_dimensions_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
set(hObject, 'String', {'Electrodes x Frequencies', 'Electrodes x Times'});
% --- Executes on selection change in pop_up_dimensions.
function pop_up_dimensions_Callback(hObject, eventdata, handles)
popup_sel_index = get(hObject,'Value');
axes(handles.Main_display); cla;
timep = numel(handles.times_here);
freqp = numel(handles.freqs_here);
switch popup_sel_index
case 1
% show electrode * freq
ef = handles.data3d(:,:,handles.maxt);
freqp = numel(handles.freqs_here);
axes(handles.Main_display);
imagesc(handles.scale(:,:,handles.maxt),handles.clims);
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
mytitle = sprintf('%s plotted at %g ms',handles.title, round(handles.times_here(handles.maxt)));
title(mytitle,'fontsize',12);
set(gca, 'XTick',[1 freqp/4 freqp/2 3*freqp/4 freqp],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.freqs_here(1)), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(freqp))},'fontsize',12);
xlabel('Frequency bin (Hz)','fontsize',12);
ylabel('Electrodes','fontsize',12);
try
set(gca,'YTick',1:length(handles.LIMO.data.expected_chanlocs));
catch ME
set(gca,'YTick',1:length(handles.LIMO.data.chanlocs));
end
if handles.LIMO.Level == 1
for i = 1 : length(handles.LIMO.data.chanlocs)
try
label_electrodes{i} = handles.LIMO.data.expected_chanlocs(i).labels;
catch ME
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
end
else
if isempty(handles.LIMO.design.electrode)
for i = 1 : length(handles.LIMO.data.chanlocs)
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
else
if length(handles.LIMO.design.electrode) == 1
label_electrodes = handles.LIMO.design.electrode;
else
label_electrodes = ' ';
ylabel('optimized electrode','FontSize',14);
end
end
end
set(gca,'YTickLabel', label_electrodes);
% topoplot
axes(handles.topoplot); cla;
topoplot(ef(:,handles.maxf),handles.LIMO.data.chanlocs);
title(['topoplot @ ' num2str(round(handles.freqs_here(handles.maxf))) ' Hz'],'FontSize',12)
% time/freq courses
axes(handles.tf_course_plot); cla;
plot(handles.freqs_here,ef(handles.maxe,:),'LineWidth',3); grid on; axis tight
try
mytitle = sprintf('power spectrum @ \n electrode %s (%g)', handles.LIMO.data.chanlocs(handles.maxe).labels,handles.LIMO.data.chanlocs(maxe).urchan);
catch urchan_issue
mytitle = sprintf('power spectrum @ \n electrode %s', handles.LIMO.data.chanlocs(handles.maxe).labels);
end
title(mytitle,'FontSize',12);
% sub-displays
axes(handles.sub_display1); cla;
timep = numel(handles.times_here);
imagesc(squeeze(handles.scale(:,handles.maxf,:)));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
title(['Electrode x times @ ' num2str(round(handles.freqs_here(handles.maxf))) ' Hz'],'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Electrodes','fontsize',12);
axes(handles.sub_display2); cla;
imagesc(flipud(squeeze(handles.scale(handles.maxe,:,:))));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
set(gca, 'YTick',[1 freqp/4 freqp/2 3*freqp/4 freqp],'fontsize',12);
set(gca, 'YTickLabel',{round(handles.freqs_here(freqp)),round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(1))},'fontsize',12);
title(['Frequency x time @ electrode ' num2str(handles.LIMO.data.chanlocs(handles.maxe).labels)],'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Frequencies','fontsize',12);
handles.ef = ef;
case 2
% show electrode * time
et = squeeze(handles.data3d(:,handles.maxf,:));
axes(handles.Main_display); cla
imagesc(squeeze(handles.scale(:,handles.maxf,:)),handles.clims);
mytitle = sprintf('%s plotted at %g Hz',handles.title, round(handles.freqs_here(handles.maxf)));
title(mytitle,'fontsize',12);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Electrodes','fontsize',12);
try
set(gca,'YTick',1:length(handles.LIMO.data.expected_chanlocs));
catch ME
set(gca,'YTick',1:length(handles.LIMO.data.chanlocs));
end
if handles.LIMO.Level == 1
for i = 1 : length(handles.LIMO.data.chanlocs)
try
label_electrodes{i} = handles.LIMO.data.expected_chanlocs(i).labels;
catch ME
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
end
else
if isempty(handles.LIMO.design.electrode)
for i = 1 : length(handles.LIMO.data.chanlocs)
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
else
if length(handles.LIMO.design.electrode) == 1
label_electrodes = handles.LIMO.design.electrode;
else
label_electrodes = ' ';
ylabel('optimized electrode','FontSize',14);
end
end
end
set(gca,'YTickLabel', label_electrodes);
% topoplot
axes(handles.topoplot); cla;
topoplot(et(:,handles.maxt),handles.LIMO.data.chanlocs);
title(['topoplot @ ' num2str(round(handles.times_here(handles.maxt))) ' ms'],'FontSize',12)
% time/freq courses
axes(handles.tf_course_plot); cla;
plot(handles.times_here,et(handles.maxe,:),'LineWidth',3); grid on; axis tight
try
mytitle = sprintf('Amplitude @ \n electrode %s (%g)', handles.LIMO.data.chanlocs(handles.maxe).labels,handles.LIMO.data.chanlocs(maxe).urchan);
catch urchan_issue
mytitle = sprintf('Amplitude @ \n electrode %s', handles.LIMO.data.chanlocs(handles.maxe).labels);
end
title(mytitle,'FontSize',12);
% sub-displays
axes(handles.sub_display1); cla;
imagesc(squeeze(handles.scale(:,:,handles.maxt)));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
title(['Electrode x Frequencies @' num2str(round(handles.times_here(handles.maxt))) ' ms'],'fontsize',12);
set(gca, 'XTick',[1 freqp/4 freqp/2 3*freqp/4 freqp],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.freqs_here(1)), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(freqp))},'fontsize',12);
xlabel('Frequencies (Hz)','fontsize',12);
ylabel('Electrodes','fontsize',12);
axes(handles.sub_display2); cla;
imagesc(flipud(squeeze(handles.scale(handles.maxe,:,:))));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
title(['Frequency x times @ electrode ' num2str(handles.LIMO.data.chanlocs(handles.maxe).labels)],'fontsize',12);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Frequencies','fontsize',12);
handles.et = et;
end
guidata(hObject, handles);
% -----------------------------------------------------------
% SLIDER -- slide in time or in freq
% ------------------------------------------------------------
% --- Executes during object creation, after setting all properties.
function slider_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function slider_Callback(hObject, eventdata, handles)
plot_data = guidata(hObject);
popup_sel_index=get(handles.pop_up_dimensions, 'Value');
timep = numel(handles.times_here);
freqp = numel(handles.freqs_here);
if popup_sel_index==1;
slider_sel = get(hObject,'Value');
slider_sel = int32(ceil(numel(handles.times_here)*slider_sel)); % Scale to get ints 1:5 out
if slider_sel == 0
slider_sel = 1; % Don't want the 0th entry, set to 1 instead
end
% show electrode * freq
ef = handles.data3d(:,:,slider_sel);
axes(handles.Main_display);
imagesc(squeeze(handles.scale(:,:,slider_sel)),handles.clims);
mytitle = sprintf('%s plotted at %g ms',handles.title, round(handles.times_here(slider_sel)));
title(mytitle,'fontsize',12);
set(gca, 'XTick',[1 freqp/4 freqp/2 3*freqp/4 freqp],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.freqs_here(1)), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(freqp))},'fontsize',12);
xlabel('Frequency (Hz)','fontsize',12);
ylabel('Electrodes','fontsize',12);
try
set(gca,'YTick',1:length(handles.LIMO.data.expected_chanlocs));
catch ME
set(gca,'YTick',1:length(handles.LIMO.data.chanlocs));
end
if handles.LIMO.Level == 1
for i = 1 : length(handles.LIMO.data.chanlocs)
try
label_electrodes{i} = handles.LIMO.data.expected_chanlocs(i).labels;
catch ME
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
end
else
if isempty(handles.LIMO.design.electrode)
for i = 1 : length(handles.LIMO.data.chanlocs)
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
else
if length(handles.LIMO.design.electrode) == 1
label_electrodes = handles.LIMO.design.electrode;
else
label_electrodes = ' ';
ylabel('optimized electrode','FontSize',14);
end
end
end
set(gca,'YTickLabel', label_electrodes);
[maxe,maxf]=ind2sub(size(ef),find(ef == max(ef(:))));
% topoplot at max freq
axes(handles.topoplot); cla
topoplot(ef(:,maxf),handles.LIMO.data.chanlocs);
title(['topoplot @ ' num2str(round(handles.freqs_here(maxf))) ' Hz'],'FontSize',12)
% time/freq courses at max elec
axes(handles.tf_course_plot); cla
plot(handles.freqs_here,ef(maxe,:),'LineWidth',3); grid on; axis tight
try
mytitle = sprintf('power spectrum @ \n electrode %s (%g)', handles.LIMO.data.chanlocs(maxe).labels,handles.LIMO.data.chanlocs(maxe).urchan);
catch urchan_issue
mytitle = sprintf('power spectrum @ \n electrode %s', handles.LIMO.data.chanlocs(maxe).labels);
end
title(mytitle,'FontSize',12);
% sub-display
axes(handles.sub_display1); cla;
timep = numel(handles.times_here);
imagesc(squeeze(handles.scale(:,maxf,:)));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
title(['Electrode x times @ ' num2str(round(handles.freqs_here(maxf))) ' Hz'],'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Electrodes','fontsize',12);
axes(handles.sub_display2); cla;
imagesc(flipud(squeeze(handles.scale(maxe,:,:))));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
set(gca, 'YTick',[1 freqp/4 freqp/2 3*freqp/4 freqp],'fontsize',12);
set(gca, 'YTickLabel',{round(handles.freqs_here(freqp)),round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(1))},'fontsize',12);
title(['Frequency x time @ electrode ' num2str(handles.LIMO.data.chanlocs(maxe).labels)],'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Frequencies','fontsize',12);
handles.ef = ef;
end
if popup_sel_index==2;
slider_sel2 = get(hObject,'Value');
slider_sel = int32(ceil(numel(handles.freqs_here)*slider_sel2)); % Scale slider to correct ints
if slider_sel == 0
slider_sel = 1; % Don't want the 0th entry, set to 1 instead
end
% show electrode * time
et = squeeze(handles.data3d(:,slider_sel,:));
axes(handles.Main_display); cla;
imagesc(squeeze(handles.scale(:,slider_sel,:)),handles.clims);
title(['Values at freq of ',num2str(round(handles.freqs_here(slider_sel))),' Hz'],'fontsize',12);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Electrodes','fontsize',12);
try
set(gca,'YTick',1:length(handles.LIMO.data.expected_chanlocs));
catch ME
set(gca,'YTick',1:length(handles.LIMO.data.chanlocs));
end
if handles.LIMO.Level == 1
for i = 1 : length(handles.LIMO.data.chanlocs)
try
label_electrodes{i} = handles.LIMO.data.expected_chanlocs(i).labels;
catch ME
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
end
else
if isempty(handles.LIMO.design.electrode)
for i = 1 : length(handles.LIMO.data.chanlocs)
label_electrodes{i} = handles.LIMO.data.chanlocs(i).labels;
end
else
if length(handles.LIMO.design.electrode) == 1
label_electrodes = handles.LIMO.design.electrode;
else
label_electrodes = ' ';
ylabel('optimized electrode','FontSize',14);
end
end
end
set(gca,'YTickLabel', label_electrodes);
[maxe,maxt]=ind2sub(size(et),find(et == max(et(:))));
% topoplot at max time
axes(handles.topoplot); cla;
topoplot(et(:,maxt),handles.LIMO.data.chanlocs);
title(['topoplot @ ' num2str(round(handles.times_here(maxt))) ' ms'],'FontSize',12)
% time/freq courses at max elec
axes(handles.tf_course_plot); cla;
plot(handles.times_here,et(maxe,:),'LineWidth',3); grid on; axis tight
mytitle = sprintf('Amplitude @ \n electrode %s (%g)', handles.LIMO.data.chanlocs(maxe).labels,handles.LIMO.data.chanlocs(maxe).urchan);
title(mytitle,'FontSize',12);
% sub-displays
axes(handles.sub_display1); cla;
imagesc(squeeze(handles.scale(:,:,maxt)));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
title(['Electrode x Frequencies @' num2str(round(handles.times_here(maxt))) ' ms'],'fontsize',12);
set(gca, 'XTick',[1 freqp/4 freqp/2 3*freqp/4 freqp],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.freqs_here(1)), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(freqp))},'fontsize',12);
xlabel('Frequencies (Hz)','fontsize',12);
ylabel('Electrodes','fontsize',12);
axes(handles.sub_display2); cla;
imagesc(flipud(squeeze(handles.scale(maxe,:,:))));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
title(['Frequency x times @ electrode ' num2str(handles.LIMO.data.chanlocs(maxe).labels)],'fontsize',12);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Frequencies','fontsize',12);
handles.et = et;
end
handles.slider_sel=slider_sel;
guidata(hObject, handles);
% -------------------------------------------------
% MOUSE INPUT
% -------------------------------------------------
% --- Executes on button press in mouse_input.
function mouse_input_Callback(hObject, eventdata, handles)
plot_data = guidata(hObject);
popup_sel_index=get(handles.pop_up_dimensions, 'Value');
[x,y,button]=ginput(1);
while button == 1
fprintf('The current mouse location is: %g %g \n',x,y);
clickedAx = gca;
if clickedAx ==handles.Main_display
if x < 1; x=1; end
if y < 1; y=1; end
popup_sel_index_str = {'Frequency', 'Time', 'Electrode'};
timep = numel(handles.times_here);
freqp = numel(handles.freqs_here);
else
break
end
if popup_sel_index == 1 % if showing elec x freq
if x > numel(plot_data.freqs_here); x=numel(plot_data.freqs_here); end
sel_str = ['Selection is at electrode ',num2str(floor(y)),' (',plot_data.LIMO.data.chanlocs(1,floor(y)).labels,') and at a freq of ',num2str(plot_data.freqs_here(floor(x))),' Hz.'];
x = floor(x); y = floor(y);
% topoplot at selected freq
axes(handles.topoplot); cla;
topoplot(handles.ef(:,x),handles.LIMO.data.chanlocs);
title(['topoplot @ ' num2str(round(handles.freqs_here(x))) ' Hz'],'FontSize',12)
% time/freq courses at selected elec
axes(handles.tf_course_plot);
plot(handles.freqs_here,handles.ef(y,:),'LineWidth',3); grid on; axis tight
try
mytitle = sprintf('power spectrum @ \n electrode %s (%g)', handles.LIMO.data.chanlocs(y).labels,handles.LIMO.data.chanlocs(maxe).urchan);
catch urchan_issue
mytitle = sprintf('power spectrum @ \n electrode %s', handles.LIMO.data.chanlocs(y).labels);
end
title(mytitle,'FontSize',12);
% sub-display
axes(handles.sub_display1); cla;
timep = numel(handles.times_here);
imagesc(squeeze(handles.scale(:,x,:)));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
title(['Electrode x times @ ' num2str(round(handles.freqs_here(x))) ' Hz'],'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Electrodes','fontsize',12);
axes(handles.sub_display2); cla;
imagesc(flipud(squeeze(handles.scale(y,:,:))));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
set(gca, 'YTick',[1 freqp/4 freqp/2 3*freqp/4 freqp],'fontsize',12);
set(gca, 'YTickLabel',{round(handles.freqs_here(freqp)),round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(1))},'fontsize',12);
title(['Frequency x time @ electrode ' num2str(handles.LIMO.data.chanlocs(y).labels)],'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Frequencies','fontsize',12);
elseif popup_sel_index == 2 % if showing elec x times on main
if x > numel(plot_data.times_here); x=numel(plot_data.times_here); end
sel_str = ['Selection is at electrode ',num2str(floor(y)),' (',plot_data.LIMO.data.chanlocs(1,floor(y)).labels,') and at a time of ',num2str(plot_data.times_here(floor(x))),' ms.'];
x = floor(x); y = floor(y);
% topoplot at max time
axes(handles.topoplot); cla;
topoplot(handles.et(:,x),handles.LIMO.data.chanlocs);
title(['topoplot @ ' num2str(round(handles.times_here(x))) ' ms'],'FontSize',12)
% time/freq courses at max elec
axes(handles.tf_course_plot); cla;
plot(handles.times_here,handles.et(y,:),'LineWidth',3); grid on; axis tight
try
mytitle = sprintf('Amplitude @ \n electrode %s (%g)', handles.LIMO.data.chanlocs(y).labels,handles.LIMO.data.chanlocs(maxe).urchan);
catch urchan_issue
mytitle = sprintf('Amplitude @ \n electrode %s', handles.LIMO.data.chanlocs(y).labels);
end
title(mytitle,'FontSize',12);
% sub-displays
axes(handles.sub_display1); cla;
imagesc(squeeze(handles.scale(:,:,x)));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
title(['Electrode x Frequencies @' num2str(round(handles.times_here(x))) ' ms'],'fontsize',12);
set(gca, 'XTick',[1 freqp/4 freqp/2 3*freqp/4 freqp],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.freqs_here(1)), round(handles.freqs_here(round(freqp/4))), round(handles.freqs_here(round(freqp/2))), round(handles.freqs_here(round(3*freqp/4))),round(handles.freqs_here(freqp))},'fontsize',12);
xlabel('Frequencies (Hz)','fontsize',12);
ylabel('Electrodes','fontsize',12);
axes(handles.sub_display2); cla;
imagesc(flipud(squeeze(handles.scale(y,:,:))));
cc=colormap(jet);cc(1,:)=[.9 .9 .9];colormap(cc);
title(['Frequency x times @ electrode ' num2str(handles.LIMO.data.chanlocs(y).labels)],'fontsize',12);
set(gca, 'XTick',[1 timep/4 timep/2 3*timep/4 timep],'fontsize',12);
set(gca, 'XTickLabel',{round(handles.times_here(1)), round(handles.times_here(round(timep/4))), round(handles.times_here(round(timep/2))), round(handles.times_here(round(3*timep/4))),round(handles.times_here(timep))},'fontsize',12);
xlabel('Time (ms)','fontsize',12);
ylabel('Frequencies','fontsize',12);
end
[x,y,button]=ginput(1);
end
guidata(hObject, handles);
%%%%%%%%%%%%%%%%%%% MAKE A MOVIE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on button press in gifbutton.
function gifbutton_Callback(hObject, eventdata, handles)
% hObject handle to gifbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%%%%%%%%%%%%%%%%%%%% MENU %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes during object creation, after setting all properties.
% --------------------------------------------------------------------
function FileMenu_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function OpenMenuItem_Callback(hObject, eventdata, handles)
[file,p] = uigetfile('*.mat','select effect file');
if ~isequal(file, 0)
cd(p); load(file); load LIMO;
do_not_update = 0;
if strncmp(file,'Covariate_effect',16)
data3d = squeeze(Covariate_effect(:,:,:,1));
elseif strncmp(file,'Condition_effect',16)
data3d = squeeze(Condition_effect(:,:,:,1));
elseif strncmp(file,'R2',2)
data3d = squeeze(R2(:,:,:,2));
elseif strncmp(file,'one_sample',10)
data3d = squeeze(one_sample(:,:,:,4));
else
do_not_update = 1;
errordlg('file not supported')
end
% ---------------------
if do_not_update == 0
clc; uiresume
guidata(hObject, handles);
delete(handles.figure1)
limo_display_results_tf(LIMO,data3d,ones(size(data3d)),file)
end
end
% --------------------------------------------------------------------
function PrintMenuItem_Callback(hObject, eventdata, handles)
% saveas(handles.figure1,cell2mat(inputdlg('save figure as: ')))
name = cell2mat(inputdlg('save figure as: '));
fig_id = findall(0,'type','figure');
set(fig_id, 'PaperPositionMode', 'auto');
print(fig_id,'-depsc2',[name '.eps'])
guidata(hObject, handles);
% --------------------------------------------------------------------
function CloseMenuItem_Callback(hObject, eventdata, handles)
clc; uiresume
guidata(hObject, handles);
delete(handles.figure1)