-
Notifications
You must be signed in to change notification settings - Fork 4
/
pop_groupSIFT_viewResultsAndExportForMovie.m
2032 lines (1703 loc) · 91.6 KB
/
pop_groupSIFT_viewResultsAndExportForMovie.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
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% pop_groupSIFT_viewResultsAndExportForMovie(varargin)
%
% History
% 04/04/2023 Makoto. Bug fixed. 'normlen', 'on' added for a workaround for the bug in dipplot().
% 08/20/2020 Makoto. Bug fixed. Edge name highlighted in red fixed.
% 08/15/2020 Makoto. Updated. The relation between 'pooling edges' and graph edge-wise multiple comparison correction was clarified. GUI and recommendations changed accordingly. The nature of the surrogate stat distribution of 'mass of cluster' seems to have an interesting property.
% 07/20/2020 Makoto. Updated. Supported Mike X Cohen's 'Matlab for Brain and Cognitive Scientists' p.245 calculation for determining mass of cluster threshold. Edge-pooled extreme value statistics. GFWER control (u=1), for which see Groppe et al. (2011)
% 05/31/2020 Makoto. Updated. Supported 2x2 test.
% 02/25/2020 Makoto. Updated. Contour plot for the case of subtraction.
% 12/20/2019 Makoto. Updated. The minor graphic details fixed.
% 12/13/2019 Makoto. Updated. Compatible with Matlab 2017b now.
% Copyright (C) 2016, Makoto Miyakoshi ([email protected]) , SCCN,INC,UCSD
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
% 1. Redistributions of source code must retain the above copyright notice,
% this list of conditions and the following disclaimer.
%
% 2. Redistributions in binary form must reproduce the above copyright notice,
% this list of conditions and the following disclaimer in the documentation
% and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
% THE POSSIBILITY OF SUCH DAMAGE.
function varargout = pop_groupSIFT_viewResultsAndExportForMovie(varargin)
% POP_GROUPSIFT_VIEWRESULTSANDEXPORTFORMOVIE MATLAB code for pop_groupSIFT_viewResultsAndExportForMovie.fig
% POP_GROUPSIFT_VIEWRESULTSANDEXPORTFORMOVIE, by itself, creates a new POP_GROUPSIFT_VIEWRESULTSANDEXPORTFORMOVIE or raises the existing
% singleton*.
%
% H = POP_GROUPSIFT_VIEWRESULTSANDEXPORTFORMOVIE returns the handle to a new POP_GROUPSIFT_VIEWRESULTSANDEXPORTFORMOVIE or the handle to
% the existing singleton*.
%
% POP_GROUPSIFT_VIEWRESULTSANDEXPORTFORMOVIE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in POP_GROUPSIFT_VIEWRESULTSANDEXPORTFORMOVIE.M with the given input arguments.
%
% POP_GROUPSIFT_VIEWRESULTSANDEXPORTFORMOVIE('Property','Value',...) creates a new POP_GROUPSIFT_VIEWRESULTSANDEXPORTFORMOVIE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before pop_groupSIFT_viewResultsAndExportForMovie_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to pop_groupSIFT_viewResultsAndExportForMovie_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help pop_groupSIFT_viewResultsAndExportForMovie
% Last Modified by GUIDE v2.5 15-Aug-2020 10:43:46
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @pop_groupSIFT_viewResultsAndExportForMovie_OpeningFcn, ...
'gui_OutputFcn', @pop_groupSIFT_viewResultsAndExportForMovie_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
function [processedLogoData, customColorMap] = prepareLogoData(inputImage, targetAxesHandle)
% Obtain the pixel size of the target region.
set(targetAxesHandle, 'Units', 'pixels');
targetPositionInPixel = get(targetAxesHandle, 'position');
targetSize = round(targetPositionInPixel([4 3])); % In the order of vertical, horizontal.
% Process the input image.
logoData = mean(double(inputImage),3);
shorterEdgeLength = min(targetSize);
longerEdgeLength = max(targetSize);
lengthRatio = longerEdgeLength/shorterEdgeLength;
outputLongerEdgeLength = round(size(logoData,1)*lengthRatio);
if targetSize(1) == targetSize(2)
processedLogoData = logoData;
elseif targetSize(1) > targetSize(2)
processedLogoData = repmat(logoData(1,1), outputLongerEdgeLength, size(logoData,2));
oneSideMergin = floor((outputLongerEdgeLength-size(logoData,2))/2);
processedLogoData(oneSideMergin+1:oneSideMergin+size(logoData,2),:) = logoData;
else
processedLogoData = repmat(logoData(1,1), size(logoData,1), outputLongerEdgeLength);
oneSideMergin = floor((outputLongerEdgeLength-size(logoData,1))/2);
processedLogoData(:, oneSideMergin+1:oneSideMergin+size(logoData,2)) = logoData;
end
% Obtain the colormap.
clockOutputs = clock;
currentMonth = clockOutputs(2);
colorRatio = 0.12221946;
if currentMonth>=3 & currentMonth<=5
originalColorMap = colormap(spring(256));
elseif currentMonth>=6 & currentMonth<=9
originalColorMap = colormap(summer(256));
elseif currentMonth>=10 & currentMonth<=11
originalColorMap = colormap(autumn(256));
else
originalColorMap = colormap(winter(256));
end
customColorMap = originalColorMap*colorRatio + repmat(1-colorRatio, size(originalColorMap));
% --- Executes just before pop_groupSIFT_viewResultsAndExportForMovie is made visible.
function pop_groupSIFT_viewResultsAndExportForMovie_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to pop_groupSIFT_viewResultsAndExportForMovie (see VARARGIN)
% Auto-fill the Edit Boxes
try
tStatisticsPath = dir('*_tStatistics.mat');
dipolePairDensityPath = dir('*_dipolePairDensity.mat');
set(handles.loadTstatisticsEdit, 'String', [pwd filesep tStatisticsPath.name]);
set(handles.loadDipolePairDensityEdit, 'String', [pwd filesep dipolePairDensityPath.name]);
end
% % display no data logo on connectivityAxes
% % Updated 12/13/2019 Makoto.
% axes(handles.connectivityAxes)
% logoPath = which('sccnLogo.jpg'); % Scott mentioned the relation between network analysis and mission of SCCN during tea time
% logoData = imread(logoPath);
% logoData = mean(double(logoData),3);
% clockOutputs = clock;
% currentMonth = clockOutputs(2);
% colorRatio = 0.12221946;
% if currentMonth>=3 & currentMonth<=5
% originalColorMap = colormap(spring(256));
% elseif currentMonth>=6 & currentMonth<=9
% originalColorMap = colormap(summer(256));
% elseif currentMonth>=10 & currentMonth<=11
% originalColorMap = colormap(autumn(256));
% else
% originalColorMap = colormap(winter(256));
% end
% customColorMap = originalColorMap*colorRatio + repmat(1-colorRatio, size(originalColorMap));
% colormap(customColorMap)
% imagesc(logoData);
% set(gca, 'XTick', [], 'YTick', [])
% drawnow
%
% axes(handles.timeFrequencyAxes);
% rectangleLogo = repmat(logoData(1,1), [length(logoData) round(length(logoData)*4/3)]);
% startPoint = round(size(rectangleLogo,2)/2)-round(size(logoData,2)/2);
% rectangleLogo(:,startPoint:startPoint+length(logoData)-1) = logoData;
% clockOutputs = clock;
% currentMonth = clockOutputs(2);
% colorRatio = 0.12221946;
% if currentMonth>=3 & currentMonth<=5
% originalColorMap = colormap(spring(256));
% elseif currentMonth>=6 & currentMonth<=9
% originalColorMap = colormap(summer(256));
% elseif currentMonth>=10 & currentMonth<=11
% originalColorMap = colormap(autumn(256));
% else
% originalColorMap = colormap(winter(256));
% end
% customColorMap = originalColorMap*colorRatio + repmat(1-colorRatio, size(originalColorMap));
% colormap(customColorMap)
% imagesc(rectangleLogo);
% set(gca, 'XTick', [], 'YTick', [])
% drawnow
%
% % display no data logo on dipole plot axes
% rectangleLogo = repmat(logoData(1,1), [round(length(logoData)*6/5) length(logoData)]);
% startPoint = round(size(rectangleLogo,1)/2)-round(size(logoData,1)/2);
% rectangleLogo(startPoint:startPoint+length(logoData)-1,:) = logoData;
% clockOutputs = clock;
% currentMonth = clockOutputs(2);
% colorRatio = 0.12221946;
% if currentMonth>=3 & currentMonth<=5
% originalColorMap = colormap(spring(256));
% elseif currentMonth>=6 & currentMonth<=9
% originalColorMap = colormap(summer(256));
% elseif currentMonth>=10 & currentMonth<=11
% originalColorMap = colormap(autumn(256));
% else
% originalColorMap = colormap(winter(256));
% end
% customColorMap = originalColorMap*colorRatio + repmat(1-colorRatio, size(originalColorMap));
% colormap(customColorMap)
%
% axes(handles.coronalAxes);
% imagesc(rectangleLogo);
% set(gca, 'XTick', [], 'YTick', [])
% freezeColors(handles.coronalAxes)
%
% axes(handles.sagittalAxes);
% imagesc(rectangleLogo);
% set(gca, 'XTick', [], 'YTick', [])
% freezeColors(handles.sagittalAxes)
%
% axes(handles.axialAxes);
% imagesc(rectangleLogo);
% set(gca, 'XTick', [], 'YTick', [])
% freezeColors(handles.axialAxes)
% drawnow
% Updated 12/13/2019 Makoto.
% Display no data logo on connectivityAxes
logoPath = which('sccnLogo.jpg');
logoData = imread(logoPath);
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.connectivityAxes);
imagesc(handles.connectivityAxes, processedLogoData);
colormap(handles.connectivityAxes, customColormap);
set(handles.connectivityAxes, 'XTick', [], 'YTick', []);
drawnow
% Display no data logo on timeFrequencyAxes
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.timeFrequencyAxes);
imagesc(handles.timeFrequencyAxes, processedLogoData);
colormap(handles.timeFrequencyAxes, customColormap);
set(handles.timeFrequencyAxes, 'XTick', [], 'YTick', []);
drawnow
% Display no data logo on timeFrequencyAxes
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.coronalAxes);
imagesc(handles.coronalAxes, processedLogoData);
colormap(handles.coronalAxes, customColormap);
set(handles.coronalAxes, 'XTick', [], 'YTick', []);
drawnow
% Display no data logo on timeFrequencyAxes
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.sagittalAxes);
imagesc(handles.sagittalAxes, processedLogoData);
colormap(handles.sagittalAxes, customColormap);
set(handles.sagittalAxes, 'XTick', [], 'YTick', []);
drawnow
% Display no data logo on timeFrequencyAxes
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.axialAxes);
imagesc(handles.axialAxes, processedLogoData);
colormap(handles.axialAxes, customColormap);
set(handles.axialAxes, 'XTick', [], 'YTick', []);
drawnow
% Obtain the initial connectivity matrix position and save it to the figure object
connectivityData.axesOriginalPosition = get(handles.connectivityAxes, 'position');
set(handles.calculateButton, 'UserData', connectivityData);
% Choose default command line output for pop_groupSIFT_viewResultsAndExportForMovie
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% Display process start
disp(sprintf('\n'))
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%%% ''6. View Results and Export for Movie'' start. %%%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp(sprintf('\n'))
% UIWAIT makes pop_groupSIFT_viewResultsAndExportForMovie wait for user response (see UIRESUME)
% uiwait(handles.viewResultsFigure);
% --- Outputs from this function are returned to the command line.
function varargout = pop_groupSIFT_viewResultsAndExportForMovie_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in loadTstatisticsButton.
function loadTstatisticsButton_Callback(hObject, eventdata, handles)
% hObject handle to loadTstatisticsButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% obtain *_tStatistics.mat
[loadFile, workingFolder] = uigetfile('*_tStatistics.mat');
if ~any(workingFolder)
disp('Cancelled.')
return
end
% set *_tStatistics.mat to Edit Box
set(handles.loadTstatisticsEdit, 'string', [workingFolder loadFile]);
function loadTstatisticsEdit_Callback(hObject, eventdata, handles)
% hObject handle to loadTstatisticsEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of loadTstatisticsEdit as text
% str2double(get(hObject,'String')) returns contents of loadTstatisticsEdit as a double
% --- Executes during object creation, after setting all properties.
function loadTstatisticsEdit_CreateFcn(hObject, eventdata, handles)
% hObject handle to loadTstatisticsEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in loadDipolePairDensityButton.
function loadDipolePairDensityButton_Callback(hObject, eventdata, handles)
% hObject handle to loadDipolePairDensityButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% obtain *_dipolePairDensity.mat
[loadFile, workingFolder] = uigetfile('*_dipolePairDensity.mat');
if ~any(workingFolder)
disp('Cancelled.')
return
end
% set *_dipolePairDensity.mat to Edit Box
set(handles.loadDipolePairDensityEdit, 'string', [workingFolder loadFile]);
function loadDipolePairDensityEdit_Callback(hObject, eventdata, handles)
% hObject handle to loadDipolePairDensityEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of loadDipolePairDensityEdit as text
% str2double(get(hObject,'String')) returns contents of loadDipolePairDensityEdit as a double
% --- Executes during object creation, after setting all properties.
function loadDipolePairDensityEdit_CreateFcn(hObject, eventdata, handles)
% hObject handle to loadDipolePairDensityEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function clusterLevelPvalueEdit_Callback(hObject, eventdata, handles)
% hObject handle to clusterLevelPvalueEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of clusterLevelPvalueEdit as text
% str2double(get(hObject,'String')) returns contents of clusterLevelPvalueEdit as a double
% --- Executes during object creation, after setting all properties.
function clusterLevelPvalueEdit_CreateFcn(hObject, eventdata, handles)
% hObject handle to clusterLevelPvalueEdit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in calculateButton.
function calculateButton_Callback(hObject, eventdata, handles)
% hObject handle to calculateButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% display start message
disp('Now loading...')
% uncheck checkboxes
set(handles.applyMaskCheckbox, 'Value', 0);
% if connectivityAxesColorbar is present, delete it
if isfield(handles, 'connectivityAxesColorbar')
try
delete(handles.connectivityAxesColorbar);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Display no data logo on connectivityAxes %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% axes(handles.connectivityAxes);
% cla(handles.connectivityAxes, 'reset');
% logoPath = which('sccnLogo.jpg'); % Scott mentioned the relation between network analysis and mission of SCCN during tea time
% logoData = imread(logoPath);
% logoData = mean(double(logoData),3);
% clockOutputs = clock;
% currentMonth = clockOutputs(2);
% colorRatio = 0.12221946;
% if currentMonth>=3 & currentMonth<=5
% originalColorMap = colormap(spring(256));
% elseif currentMonth>=6 & currentMonth<=9
% originalColorMap = colormap(summer(256));
% elseif currentMonth>=10 & currentMonth<=11
% originalColorMap = colormap(autumn(256));
% else
% originalColorMap = colormap(winter(256));
% end
% customColorMap = originalColorMap*colorRatio + repmat(1-colorRatio, size(originalColorMap));
% colormap(customColorMap)
% imagesc(logoData);
% set(gca, 'XTick', [], 'YTick', [])
%
% % display no data logo on timeFrequencyAxes
% axes(handles.timeFrequencyAxes);
% cla(handles.timeFrequencyAxes, 'reset');
% rectangleLogo = repmat(logoData(1,1), [length(logoData) round(length(logoData)*4/3)]);
% startPoint = round(size(rectangleLogo,2)/2)-round(size(logoData,2)/2);
% rectangleLogo(:,startPoint:startPoint+length(logoData)-1) = logoData;
% clockOutputs = clock;
% currentMonth = clockOutputs(2);
% colorRatio = 0.12221946;
% if currentMonth>=3 & currentMonth<=5
% originalColorMap = colormap(spring(256));
% elseif currentMonth>=6 & currentMonth<=9
% originalColorMap = colormap(summer(256));
% elseif currentMonth>=10 & currentMonth<=11
% originalColorMap = colormap(autumn(256));
% else
% originalColorMap = colormap(winter(256));
% end
% customColorMap = originalColorMap*colorRatio + repmat(1-colorRatio, size(originalColorMap));
% colormap(customColorMap);
% imagesc(rectangleLogo);
% freezeColors(handles.timeFrequencyAxes)
% set(gca, 'XTick', [], 'YTick', [])
% drawnow
%
% % display no data logo on dipole plot axes
% cla(handles.axialAxes, 'reset')
% cla(handles.sagittalAxes, 'reset')
% cla(handles.coronalAxes, 'reset')
% rectangleLogo = repmat(logoData(1,1), [round(length(logoData)*6/5) length(logoData)]);
% startPoint = round(size(rectangleLogo,1)/2)-round(size(logoData,1)/2);
% rectangleLogo(startPoint:startPoint+length(logoData)-1,:) = logoData;
% clockOutputs = clock;
% currentMonth = clockOutputs(2);
% colorRatio = 0.12221946;
% if currentMonth>=3 & currentMonth<=5
% originalColorMap = colormap(spring(256));
% elseif currentMonth>=6 & currentMonth<=9
% originalColorMap = colormap(summer(256));
% elseif currentMonth>=10 & currentMonth<=11
% originalColorMap = colormap(autumn(256));
% else
% originalColorMap = colormap(winter(256));
% end
% customColorMap = originalColorMap*colorRatio + repmat(1-colorRatio, size(originalColorMap));
% colormap(customColorMap)
%
% axes(handles.coronalAxes);
% imagesc(rectangleLogo);
% set(gca, 'XTick', [], 'YTick', [])
% freezeColors(handles.coronalAxes)
%
% axes(handles.sagittalAxes);
% imagesc(rectangleLogo);
% set(gca, 'XTick', [], 'YTick', [])
% freezeColors(handles.sagittalAxes)
%
% axes(handles.axialAxes);
% imagesc(rectangleLogo);
% set(gca, 'XTick', [], 'YTick', [])
% freezeColors(handles.axialAxes)
% drawnow
% Updated 12/13/2019 Makoto.
% Display no data logo on connectivityAxes
logoPath = which('sccnLogo.jpg');
logoData = imread(logoPath);
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.connectivityAxes);
imagesc(handles.connectivityAxes, processedLogoData);
colormap(handles.connectivityAxes, customColormap);
set(handles.connectivityAxes, 'XTick', [], 'YTick', []);
drawnow
% Display no data logo on timeFrequencyAxes
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.timeFrequencyAxes);
imagesc(handles.timeFrequencyAxes, processedLogoData);
colormap(handles.timeFrequencyAxes, customColormap);
set(handles.timeFrequencyAxes, 'XTick', [], 'YTick', []);
drawnow
% Display no data logo on timeFrequencyAxes
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.coronalAxes);
imagesc(handles.coronalAxes, processedLogoData);
colormap(handles.coronalAxes, customColormap);
set(handles.coronalAxes, 'XTick', [], 'YTick', []);
drawnow
% Display no data logo on timeFrequencyAxes
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.sagittalAxes);
imagesc(handles.sagittalAxes, processedLogoData);
colormap(handles.sagittalAxes, customColormap);
set(handles.sagittalAxes, 'XTick', [], 'YTick', []);
drawnow
% Display no data logo on timeFrequencyAxes
[processedLogoData, customColormap] = prepareLogoData(logoData, handles.axialAxes);
imagesc(handles.axialAxes, processedLogoData);
colormap(handles.axialAxes, customColormap);
set(handles.axialAxes, 'XTick', [], 'YTick', []);
drawnow
%%%%%%%%%%%%%%%%%%%%%%
%%% Load .mat data %%%
%%%%%%%%%%%%%%%%%%%%%%
load(get(handles.loadTstatisticsEdit, 'String'));
load(get(handles.loadDipolePairDensityEdit,'String'));
% store the loaded data to axis data
connectivityData = struct();
connectivityData.dimensionLabels = dimensionLabels;
connectivityData.frequencies = frequencies;
connectivityData.latencies = latencies;
connectivityData.connectivityType = connectivityType;
connectivityData.fileNameList = fileNameList;
connectivityData.baselineIdx = baselineIdx;
connectivityData.roiLabels = roiLabels;
connectivityData.symmetricRoiCentroids = symmetricRoiCentroids;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Perform cluster-level correction %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Obtain user-selected P-value for cluster-level correction.
clusterLevelPvalue = str2num(get(handles.clusterLevelPvalueEdit, 'String'));
% Obtain the critical Mass of Cluster from pooled surrogate results.
surroMassOfClusterMinMax = reshape(surroMassOfCluster, [size(surroMassOfCluster,1)/2 2 size(surroMassOfCluster,2)]);
surroMassOfClusterMin = squeeze(surroMassOfClusterMinMax(:,1,:));
surroMassOfClusterMax = squeeze(surroMassOfClusterMinMax(:,2,:));
% 07/19/2020 Makoto.
% From 'Matlab for Brain and Cognitive scientists' p.245, the lower and
% upper thresholds are deteremind by max stats and min stats separately.
% This approach seems slightly more sensitive than pooling the two
% distributions and apply a two-tailed test.
%criticalMassOfCluster = prctile(surroMassOfCluster(:), [clusterLevelPvalue*100/2 100-(clusterLevelPvalue*100/2)]); % Blob sizes are nicely bounded!
% Compute critical mass of cluster.
criticalMassOfCluster = zeros(1,2);
criticalMassOfCluster_G1 = zeros(1,2);
% ROI mode: no multiple comparison correction for graph edges.
if get(handles.mccForGraphEdgesCheckbox, 'Value')==0
criticalMassOfCluster(1,1) = prctile(surroMassOfClusterMin(:), clusterLevelPvalue*100); % Use one-tailed test for each (07/20/2020 Makoto)
criticalMassOfCluster(1,2) = prctile(surroMassOfClusterMax(:), 100-clusterLevelPvalue*100);
% Omnibus correction mode: multiple comparison correction for graph edges on.
elseif get(handles.mccForGraphEdgesCheckbox, 'Value')==1
% This is the rational--For real omnibus correction across all graph edges,
% we may want to use the strongest even among the graph edges. This
% should provide protection for all edges. However, including all the
% graph edge extreme values should also provide a certain type of
% protection with some limitation (but I cannot describe exactly what
% limitation it is.) The default value of this option should be 1.
surroMassOfClusterMinSorted = sort(surroMassOfClusterMin, 2, 'ascend');
surroMassOfClusterMaxSorted = sort(surroMassOfClusterMax, 2, 'descend');
% Support generalized family-wise error rate (GFWER) control with u = 1 (Groppe et al., 2011).
if get(handles.useGfwerCheckbox, 'Value')==0
surroMassOfClusterMinMin = surroMassOfClusterMinSorted(:,1);
surroMassOfClusterMaxMax = surroMassOfClusterMaxSorted(:,1);
elseif get(handles.useGfwerCheckbox, 'Value')==1
disp('Generalized FWER control option is on; Note at least 1 result is false positive.')
surroMassOfClusterMinMin = surroMassOfClusterMinSorted(:,2);
surroMassOfClusterMaxMax = surroMassOfClusterMaxSorted(:,2);
end
criticalMassOfCluster(1,1) = prctile(min(surroMassOfClusterMinMin, [], 2), clusterLevelPvalue*100);
criticalMassOfCluster(1,2) = prctile(max(surroMassOfClusterMaxMax, [], 2), 100-clusterLevelPvalue*100);
clear surroMassOfClusterMinSorted surroMassOfClusterMaxSorted
end
% Build the mask.
significantClusterMask = zeros(size(clusterMask));
for n = 1:size(clusterMask,1)
% Identify all blobs that survive the cluster-level threthold (pooled across edges)
tmpBlobMask = squeeze(clusterMask(n,:,:));
tmpTStatistics = squeeze(tStatistics(n,:,:));
[entryCount, blobId] = hist(tmpBlobMask(:), unique(tmpBlobMask(:)));
tmpMassOfCluster = zeros(length(blobId)-1,1);
for m = 2:length(blobId)
currentMask = tmpBlobMask==blobId(m);
tmpMassOfCluster(m-1) = sum(sum(currentMask.*tmpTStatistics));
end
survivedClusterMaskIdx = find(tmpMassOfCluster < criticalMassOfCluster(1) | tmpMassOfCluster > criticalMassOfCluster(2));
% Combine the survived blobs.
if ~isempty(survivedClusterMaskIdx)
combinedMask = zeros([size(clusterMask,2) size(clusterMask,3)]);
for clusterMaskIdx = 1:length(survivedClusterMaskIdx)
currentMask = tmpBlobMask==survivedClusterMaskIdx(clusterMaskIdx);
% If currentMask is a row vector, transpose it. (06/28/2020 Makoto)
if size(currentMask,1)==1
currentMask = currentMask';
end
combinedMask = logical(combinedMask + currentMask);
end
else
% disp('Nothing survived.')
continue
end
% Store the result.
significantClusterMask(n,:,:) = combinedMask;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Overwrite imported data by removing non-significant edges %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
significantEdgeIdx = find(sum(sum(significantClusterMask,2),3));
finallySelectedEdgeIdx = finallySelectedEdgeIdx(significantEdgeIdx);
significantClusterMask = significantClusterMask(significantEdgeIdx,:,:);
tStatistics = tStatistics(significantEdgeIdx,:,:);
pValues = pValues(significantEdgeIdx,:,:);
if exist('tStatistics_beforeSubtraction1', 'var')
tStatistics_beforeSubtraction1 = tStatistics_beforeSubtraction1(significantEdgeIdx,:,:);
tStatistics_beforeSubtraction2 = tStatistics_beforeSubtraction2(significantEdgeIdx,:,:);
end
if exist('tStatistics_beforeSubtraction3', 'var')
tStatistics_beforeSubtraction3 = tStatistics_beforeSubtraction3(significantEdgeIdx,:,:);
tStatistics_beforeSubtraction4 = tStatistics_beforeSubtraction4(significantEdgeIdx,:,:);
end
%%%%%%%%%%%%%%%%%%%%
%%% Make a mask. %%%
%%%%%%%%%%%%%%%%%%%%
% Limit latency window if necessary
latencyWindowMask = logical(zeros(size(significantClusterMask)));
latencyWindowLimit = str2num(get(handles.latencyEdit, 'String'));
if any(latencyWindowLimit)
latencyIdx = find(latencies>=latencyWindowLimit(1) & latencies<=latencyWindowLimit(2));
latencyWindowMask(:,:,latencyIdx) = 1;
significantClusterMask = logical(significantClusterMask.*latencyWindowMask);
else
latencyIdx = 1:length(latencies);
end
% Limit frequency band if necessary
freqRangeMask = logical(zeros(size(significantClusterMask)));
frequencyBandLimit = str2num(get(handles.freqEdit, 'String'));
if any(frequencyBandLimit)
freqIdx = find(frequencies>=frequencyBandLimit(1) & frequencies<=frequencyBandLimit(2));
freqRangeMask(:,freqIdx,:) = 1;
significantClusterMask = logical(significantClusterMask.*freqRangeMask);
else
freqIdx = 1:length(frequencies);
end
% Apply the inclusive mask --> this could be used for movie!
maskedT = tStatistics.*significantClusterMask;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Compute mass of cluster after cluster-level correction (i.e. blob rejection) %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Take absolute t-scores
if get(handles.absPosiNegaTscorePopupmenu, 'value') == 1
massOfCluster = sum(sum(abs(maskedT),3),2);
colorBarMinMax = [0 max(abs(massOfCluster))];
% Take positive t-scores
elseif get(handles.absPosiNegaTscorePopupmenu, 'value') == 2
positveMask = maskedT>0;
massOfCluster = sum(sum(maskedT.*positveMask,3),2);
colorBarMinMax = [0 max(massOfCluster)];
% Take negative t-scores
elseif get(handles.absPosiNegaTscorePopupmenu, 'value') == 3
negativeMask = maskedT<0;
massOfCluster = sum(sum(maskedT.*negativeMask,3),2);
colorBarMinMax = [min(massOfCluster) 0];
end
% Return if no significant result
if ~any(massOfCluster)
disp('Nothing survived.')
return
end
% Restore 2-D matrix.
connectivityMatrix1D = zeros(length(roiLabels)*length(roiLabels),1);
connectivityMatrix1D(finallySelectedEdgeIdx) = massOfCluster;
connectivityMatrix = reshape(connectivityMatrix1D, [length(roiLabels) length(roiLabels)]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Sort data and roiLabels so that 1) L and R are separated, 2) ROIs are sorted from frontal to occipital %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
symmetricRoiCentroids_LR = symmetricRoiCentroids([1:2:size(connectivityMatrix,1) 2:2:size(connectivityMatrix,1)],:,:);
symmetricRoiCentroids_L = symmetricRoiCentroids_LR(1:length(symmetricRoiCentroids_LR)/2,:,:);
yCoordinate = symmetricRoiCentroids_L(:,2);
[~,frontOccipitalSortL_Idx] = sort(yCoordinate, 'descend');
frontOccipitalSortIdx = [frontOccipitalSortL_Idx; frontOccipitalSortL_Idx+length(symmetricRoiCentroids_LR)/2];
originalOrder = 1:size(connectivityMatrix,1);
LR_separateOrder = originalOrder([1:2:size(connectivityMatrix,1) 2:2:size(connectivityMatrix,1)]);
roiOrderConvertIdx = LR_separateOrder(frontOccipitalSortIdx);
connectivityMatrixReordered = connectivityMatrix(roiOrderConvertIdx,roiOrderConvertIdx);
roiLabelsReordered = roiLabels(roiOrderConvertIdx);
% Rename ROI labels. 12/13/2019 Makoto.
for labelIdx = 1:length(roiLabelsReordered)
currentLabel = roiLabelsReordered{labelIdx};
underScoreIdx = strfind(currentLabel, '_');
currentLabel(underScoreIdx) = deal('-');
roiLabelsReordered{labelIdx} = currentLabel;
end
% % IMPORTANT CONFIRMATION!
% Ground Truth: connectivityMatrix(8,1)
% Wrong : connectivityMatrixReordered(roiOrderConvertIdx(8), roiOrderConvertIdx(1))
% Correct: connectivityMatrixReordered(find(roiOrderConvertIdx==8), find(roiOrderConvertIdx==1))
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%% Plot connectivity matrix with abs(massOfCluster) %%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% axes(handles.connectivityAxes)
% cla(handles.connectivityAxes, 'reset');
% imagesc(connectivityMatrixReordered, colorBarMinMax);
%
% % Display a short colorBar without deforming the connectivity matrix plot
% customColorMap = colormap(jet(256));
%
% if get(handles.absPosiNegaTscorePopupmenu, 'value') == 1 | get(handles.absPosiNegaTscorePopupmenu, 'value') == 2
% customColorMap = customColorMap(129:end, :);
% customColorMap(1,:) = 0.7; % Gray out zero values
% elseif get(handles.absPosiNegaTscorePopupmenu, 'value') == 3
% customColorMap = customColorMap(1:128, :);
% customColorMap(end,:) = 0.7; % Gray out zero values
% end
% plotConnectivityButtonUserData = get(handles.calculateButton, 'UserData');
% colormap(customColorMap);
% colorbar;
% colorbarHandle = cbfreeze(handles.connectivityAxes);
% set(handles.connectivityAxes, 'Position', plotConnectivityButtonUserData.axesOriginalPosition);
% set(colorbarHandle, 'Position', [0.5935 0.0195 0.0160 0.1901], 'YLim', colorBarMinMax)
% handles.connectivityAxesColorbar = colorbarHandle;
% set(get(colorbarHandle, 'Title'), 'String', ' Summed t')
%
% % Display anatomical labels
% set(gca, 'YTick', 1:size(connectivityMatrix,1), 'YTickLabel', roiLabelsReordered)
% XTickRoiLabels = roiLabelsReordered;
% for n = 1:length(XTickRoiLabels)
% XTickRoiLabels{n} = [' ' XTickRoiLabels{n}];
% end
% set(gca, 'XTick', 1:size(connectivityMatrix,1), 'XTickLabel', XTickRoiLabels, 'XAxisLocation', 'top')
% rotateXLabels(gca, 90)
% set(findall(gca, '-property', 'interpreter'), 'interpreter', 'none')
%
% % Overlay quadrant lines
% hold on
% line([0 size(connectivityMatrix,1)+0.5], [size(connectivityMatrix,1)/2+0.5 size(connectivityMatrix,1)/2+0.5], 'color', [0 0 0])
% line([size(connectivityMatrix,1)/2+0.5 size(connectivityMatrix,1)/2+0.5], [0 size(connectivityMatrix,1)+0.5], 'color', [0 0 0])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Plot connectivity matrix with abs(massOfCluster) %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
axes(handles.connectivityAxes)
cla(handles.connectivityAxes, 'reset');
imagesc(connectivityMatrixReordered, colorBarMinMax);
% Display a short colorBar without deforming the connectivity matrix plot
customColorMap = colormap(jet(256));
if get(handles.absPosiNegaTscorePopupmenu, 'value') == 1 | get(handles.absPosiNegaTscorePopupmenu, 'value') == 2
customColorMap = customColorMap(129:end, :);
customColorMap(1,:) = 0.7; % Gray out zero values
elseif get(handles.absPosiNegaTscorePopupmenu, 'value') == 3
customColorMap = customColorMap(1:128, :);
customColorMap(end,:) = 0.7; % Gray out zero values
end
plotConnectivityButtonUserData = get(handles.calculateButton, 'UserData');
colormap(handles.connectivityAxes, customColorMap);
colorbarHandle = colorbar;
set(handles.connectivityAxes, 'Position', plotConnectivityButtonUserData.axesOriginalPosition);
% 12/13/2019 Makoto. Updated for Matlab 2017b.
colorbarPosition = get(colorbarHandle, 'position');
set(colorbarHandle, 'Position', [colorbarPosition(1) colorbarPosition(2) colorbarPosition(3) colorbarPosition(4)/2], 'YLim', colorBarMinMax)
handles.connectivityAxesColorbar = colorbarHandle;
set(get(colorbarHandle, 'Title'), 'String', ' Summed t')
% Display anatomical labels
set(handles.connectivityAxes, 'YTick', 1:size(connectivityMatrix,1), 'YTickLabel', roiLabelsReordered, 'FontSize', 7)
XTickRoiLabels = roiLabelsReordered;
for n = 1:length(XTickRoiLabels)
XTickRoiLabels{n} = [' ' XTickRoiLabels{n}];
end
set(handles.connectivityAxes, 'XTick', 1:size(connectivityMatrix,1), 'XTickLabel', XTickRoiLabels, 'XAxisLocation', 'top' , 'FontSize', 7)
rotateXLabels(handles.connectivityAxes, 90)
%set(findall(gca, '-property', 'interpreter'), 'interpreter', 'none')
% Highlight labels of significant graph edges (John Iversen's idea. SMART.) 08/15/2020 Makoto. 08/20/2020 Makoto bug fixed.
try
significantGraphEdgeAddress = find(connectivityMatrixReordered);
[toEdges, fromEdges] = ind2sub(size(connectivityMatrixReordered), significantGraphEdgeAddress);
uniqueToEdges = unique(toEdges);
uniqueFromEdges = unique(fromEdges);
for significantFromEdgeIdx = 1:length(uniqueFromEdges)
currentLabel = handles.connectivityAxes.XTickLabel(uniqueFromEdges(significantFromEdgeIdx));
handles.connectivityAxes.XTickLabel(uniqueFromEdges(significantFromEdgeIdx)) = {['\color{red}\fontsize{7}\bf' currentLabel{1,1}]};
end
for significantToEdgeIdx = 1:length(uniqueToEdges)
currentLabel = handles.connectivityAxes.YTickLabel(uniqueToEdges(significantToEdgeIdx));
handles.connectivityAxes.YTickLabel(uniqueToEdges(significantToEdgeIdx)) = {['\color{red}\fontsize{7}\bf ' currentLabel{1,1}]};
end
catch
warning('Highlighting significant graph edgee labels failed. Sorry John!')
end
% Overlay quadrant lines
hold on
line([0 size(connectivityMatrix,1)+0.5], [size(connectivityMatrix,1)/2+0.5 size(connectivityMatrix,1)/2+0.5], 'color', [0 0 0])
line([size(connectivityMatrix,1)/2+0.5 size(connectivityMatrix,1)/2+0.5], [0 size(connectivityMatrix,1)+0.5], 'color', [0 0 0])
% Set the colorbar font size. 12/13/2019 Makoto.
set(colorbarHandle, 'fontsize', 7)
set(get(colorbarHandle, 'Title'), 'String', ' Summed t')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Display report: Ranking of positive and negative total information inflow and outflow %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Increase of information in/outflow (i.e. positive t-scores)
positiveMask = maskedT>0;
positveT = maskedT.*positiveMask;
positiveROIs = sum(sum(positveT,2),3);
posiConnMatrix1D = zeros(length(roiLabels)*length(roiLabels),1);
posiConnMatrix1D(finallySelectedEdgeIdx) = positiveROIs;
posiConnMatrix = reshape(posiConnMatrix1D, [length(roiLabels) length(roiLabels)]);
totalPosiOutflow = sum(posiConnMatrix,1);
totalPosiInflow = sum(posiConnMatrix,2);
[posiOutSorted, posiOutSortOrder] = sort(totalPosiOutflow, 'descend');
[posiInSorted, posiInSortOrder] = sort(totalPosiInflow, 'descend');
posiOutSortedLabels = roiLabels(posiOutSortOrder);
posiInSortedLabels = roiLabels(posiInSortOrder);
% Decrease of information in/outflow (i.e. negative t-scores)
negativeMask = maskedT<0;
negativeT = maskedT.*negativeMask;
negativeROIs = sum(sum(negativeT,2),3);
negaConnMatrix1D = zeros(length(roiLabels)*length(roiLabels),1);
negaConnMatrix1D(finallySelectedEdgeIdx) = negativeROIs;
negaConnMatrix = reshape(negaConnMatrix1D, [length(roiLabels) length(roiLabels)]);
totalPosiOutflow = sum(negaConnMatrix,1);
totalPosiInflow = sum(negaConnMatrix,2);
[negaOutSorted, negaOutSortOrder] = sort(totalPosiOutflow, 'ascend');
[negaInSorted, negaInSortOrder] = sort(totalPosiInflow, 'ascend');
negaOutSortedLabels = roiLabels(negaOutSortOrder);
negaInSortedLabels = roiLabels(negaInSortOrder);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Generate summary report of total information in/outflow %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Report total number of edges.
set(handles.resultReportPanel, 'Title', sprintf('Significant edges: %.0f', length(finallySelectedEdgeIdx)));
% Construct report of total information flows.
tmpStr = 'Increase in Info Outflow';
for n = 1:6
if any(posiOutSorted(n))
tmpSumTscore = posiOutSorted(n);
tmpROI = posiOutSortedLabels{n};
tmpStr = [tmpStr sprintf('\n %4.0f %s', tmpSumTscore, tmpROI)];
else
tmpStr = [tmpStr sprintf('\n (none)')];
end
end
tmpStr = [tmpStr sprintf('\n\n')];
tmpStr = [tmpStr 'Increase in Info Inflow'];
for n = 1:6
if any(posiInSorted(n))
tmpSumTscore = posiInSorted(n);
tmpROI = posiInSortedLabels{n};
tmpStr = [tmpStr sprintf('\n %4.0f %s', tmpSumTscore, tmpROI)];
else
tmpStr = [tmpStr sprintf('\n (none)')];
end
end
tmpStr = [tmpStr sprintf('\n\n')];
tmpStr = [tmpStr 'Decrease in Info Outflow'];
for n = 1:6
if any(negaOutSorted(n))
tmpSumTscore = negaOutSorted(n);
tmpROI = negaOutSortedLabels{n};
tmpStr = [tmpStr sprintf('\n %4.0f %s', tmpSumTscore, tmpROI)];
else
tmpStr = [tmpStr sprintf('\n (none)')];
end
end
tmpStr = [tmpStr sprintf('\n\n')];
tmpStr = [tmpStr 'Decrease in Info Inflow'];
for n = 1:6
if any(negaInSorted(n))
tmpSumTscore = negaInSorted(n);
tmpROI = negaInSortedLabels{n};
tmpStr = [tmpStr sprintf('\n %4.0f %s', tmpSumTscore, tmpROI)];
else
tmpStr = [tmpStr sprintf('\n (none)')];
end
end
% Display the result
set(handles.rankingText, 'String', tmpStr)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Update handles structure %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if exist('tStatistics_beforeSubtraction1', 'var') & exist('tStatistics_beforeSubtraction2', 'var')
connectivityData.tStatistics_beforeSubtraction1 = tStatistics_beforeSubtraction1;
connectivityData.tStatistics_beforeSubtraction2 = tStatistics_beforeSubtraction2;
end
if exist('tStatistics_beforeSubtraction3', 'var') & exist('tStatistics_beforeSubtraction4', 'var')
connectivityData.tStatistics_beforeSubtraction3 = tStatistics_beforeSubtraction3;
connectivityData.tStatistics_beforeSubtraction4 = tStatistics_beforeSubtraction4;
end
connectivityData.tStatistics = tStatistics;
connectivityData.finallySelectedEdgeIdx = finallySelectedEdgeIdx;
connectivityData.significantClusterMask = significantClusterMask;
connectivityData.pValues = pValues;
connectivityData.roiOrderConvertIdx = roiOrderConvertIdx;
connectivityData.latencyIdx = latencyIdx;
connectivityData.freqIdx = freqIdx;
connectivityData.meanSurvivedStatistics = massOfCluster;
connectivityData.significantClusterMask = significantClusterMask;
connectivityData.posiConnMatrix = posiConnMatrix;
connectivityData.negaConnMatrix = negaConnMatrix;
set(handles.connectivityAxes, 'UserData', connectivityData);
guidata(hObject, handles);
% % Lock axis color map
% freezeColors(handles.connectivityAxes);