-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNoisyImagesAnalysis_20220822.m
3085 lines (2306 loc) · 107 KB
/
NoisyImagesAnalysis_20220822.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
%% Noisy Image analysis
%August 2022
close all; clearvars;
currpath = pwd;
Idx = regexp(pwd,'Images/','end');
main_path = currpath(1:Idx);
redoLocalPolys = 0;
%% 1) Load Experiment Data
fprintf('Loading Experiment Data\n');
redo_data_compile = 1; % 1 to rerun data compilations (compileDataExp1_3), 0 to use previous compilation
if exist(fullfile(main_path, 'scripts/Analysis/Scoring.mat'), 'file')
load(fullfile(main_path, 'scripts/Analysis/Scoring.mat'))
end
if ~exist('../../data/Exp1/AllData/AllExp1ControlData.mat', 'file') || ~exist('../../data/Exp1/AllData/AllExp1Data.mat', 'file') || redo_data_compile
[AllExp1Data, AllControlData, AllCatchData] = compileDataExp1_3(currpath);
else
load('../../data/Exp1/AllData/AllExp1ControlData.mat');
load('../../data/Exp1/AllData/AllExp1Data.mat')
load('../../data/Exp1/AllData/AllCatchData.mat');
end
fprintf('Loading Polygons\n');
load('images_withPoly.mat'); %exp polys (images_withPoly2 with new Crocodile Eye Poly)
load('CatchPolys.mat'); %catch polys
load('../LookupPromptsCatch.mat');
load('../LookupPromptsExp1.mat');
%% 2) Define Variables
fprintf('Defining Variables\n');
imageIDs = [1 2 4 5 7 8 11 12 13 14 15 16 17 24 25 26 27 32 39 40]; %IDs of images used in final study
NumIi = length(imageIDs);
ssIDs = unique(AllExp1Data.pertrial.pID); %all participant IDs
NumSs = length(ssIDs);
sizeMark = 20;
pxpermm = 680/273.9; %680px = 273.9mm
mmperpx = 273.9/680;
redoPolys = 0; % 1 to redraw polygons do poiting accuracy, two-tone images
redoPolysCatch = 0;% 1 to redraw polygons do poiting accuracy, catch images
%colour maps
Rainbow = [0.265 0.555 0.465; 0.46 0.42 0.62; 0.87 0.485 0.6; 0.855 0.58 0.4];
Light = [0.455 0.745 0.655; 0.65 0.61 0.81; 1 0.675 0.795; 1 0.77 0.59];
MeanColours = {[0.8157 0.8157 0.8157], [0.6706 0.6706 0.6706], [0.5725 0.5725 0.5725], [0.1412 0.1412 0.1412]; [1 0.7490 0.247], [1 0.5529 0.4431], [1 0.4196 0.5765], [0.5098 0.2549 0.7529]};
spring2 = [linspace(0.4,0.6,66)',linspace(0.2,0.3,66)', linspace(0.7,0.8,66)'; ones(190,1),linspace(0,1,190)', linspace(1,0,190)' ]; %colourmap
x = jet;
jet2 = x(0.5*end:end,:);
BGsize = [1080 1920];
%% 3) Extract Per-Subject & Per-Image Data
if ~exist(fullfile(main_path, '/scripts/Analysis/Scoring.mat'), 'file')
disp('Extracting Data');
%define structs
subs.ID = nan(NumSs,1);
subs.ages = nan(NumSs,1);
subs.AgeGroup = nan(NumSs,1);
subs.Gender = nan(NumSs,1);
subs.ImNum = nan(NumSs,NumIi);
subs.TwoToneAcc = nan(NumSs,NumIi);
subs.GrayScAcc = nan(NumSs,NumIi);
subs.CanSeeNow = nan(NumSs,NumIi);
subs.TwoToneCoord1 = nan(NumSs,NumIi,2);
subs.TwoToneCoord2 = nan(NumSs,NumIi,2);
subs.GrayScaleCoord1 = nan(NumSs,NumIi,2);
subs.GrayScaleCoord2 = nan(NumSs,NumIi,2);
for ss = 1:NumSs
for ii = 1:NumIi
ssIdx = ssIDs(ss);
iiIdx = imageIDs(ii);
idx = AllExp1Data.pertrial.pID == ssIdx & AllExp1Data.pertrial.ImNum == iiIdx;
if sum(idx) == 1
subs.ID(ss) = AllExp1Data.pertrial.pID(idx);
subs.ages(ss) = AllExp1Data.pertrial.age(idx);
subs.AgeGroup(ss) = AllExp1Data.pertrial.ageGroup(idx);
subs.ImNum(ss,ii) = AllExp1Data.pertrial.ImNum(idx);
subs.TwoToneReport(ss,ii) = AllExp1Data.pertrial.TwoToneReport(idx);
subs.GreyScaleReport(ss,ii) = AllExp1Data.pertrial.GreyScaleReport(idx);
subs.TwoToneAcc(ss,ii) = AllExp1Data.pertrial.TwoToneAcc(idx);
subs.GrayScAcc(ss,ii) = AllExp1Data.pertrial.GrayScAcc(idx);
subs.CanSeeNow(ss,ii) = AllExp1Data.pertrial.CanSeeNow(idx);
subs.TwoToneCoord1(ss,ii,:) = AllExp1Data.pertrial.coord1(idx,:);
subs.TwoToneCoord2(ss,ii,:) = AllExp1Data.pertrial.coord2(idx,:);
subs.GrayScaleCoord1(ss,ii,:) = AllControlData.pertrial.coord1(idx,:);
subs.GrayScaleCoord2(ss,ii,:) = AllControlData.pertrial.coord2(idx,:);
elseif sum(idx) > 1 % if there are two of the same images in single particpant
fprintf('subject %i',ss)
fprintf('image %i',ii)
break
end
end
end
end
%Find Individual distances between TwoTone and GreyScale coordinates
%(pointing distance)
subs.TT2GSDist1 = mmperpx*hypot((subs.TwoToneCoord1(:,:,1) - subs.GrayScaleCoord1(:,:,1)), (subs.TwoToneCoord1(:,:,2) - subs.GrayScaleCoord1(:,:,2))); %distance in mm
subs.TT2GSDist2 = mmperpx*hypot((subs.TwoToneCoord2(:,:,1) - subs.GrayScaleCoord2(:,:,1)), (subs.TwoToneCoord2(:,:,2) - subs.GrayScaleCoord2(:,:,2))); %distance in mm
%% 3) Extract Per-Subject Catch Data
disp('Extracting Catch Data');
%define structs
subs.CaImNum = nan(NumSs,4);
subs.CaTwoToneAcc = nan(NumSs,4);
subs.CaGrayScAcc = nan(NumSs,4);
subs.CaCanSeeNow = nan(NumSs,4);
subs.CaTwoToneCoord1 = nan(NumSs,4,2);
subs.CaTwoToneCoord2 = nan(NumSs,4,2);
subs.CaGrayScaleCoord1 = nan(NumSs,4,2);
subs.CaGrayScaleCoord2 = nan(NumSs,4,2);
for ss = 1:NumSs
for ii = 1:5
newim = ii;
if ii == 5
newim = 4;
end
ssIdx = ssIDs(ss);
idx = AllCatchData.pertrial.pID == ssIdx & AllCatchData.pertrial.ImNum == ii;
if sum(idx) == 1
%exclude turtle images
if contains(AllCatchData.pertrial.ImLabel(idx), 'Turtle')
if ~cellfun(@isempty,AllCatchData.pertrial.GrayScReport{idx})
if contains(AllCatchData.pertrial.GrayScReport{idx}, 'turtle') || contains(AllCatchData.pertrial.GrayScReport{idx}, 'tortoise')
AllCatchData.pertrial.GrayScReport{idx}
AllCatchData.pertrial.coord1(idx,1) = NaN; AllCatchData.pertrial.coord1(idx,2) = NaN;
AllCatchData.pertrial.coord2(idx,1) = NaN; AllCatchData.pertrial.coord2(idx,2) = NaN;
AllCatchData.pertrial.GrayScAcc(idx) = NaN; AllCatchData.pertrial.TwoToneAcc(idx) = NaN;
end
end
end
subs.CaImNum(ss,newim) = AllCatchData.pertrial.ImNum(idx);
subs.CaTwoToneReport(ss,newim) = AllCatchData.pertrial.TwoToneReport(idx);
subs.CaGreyScaleReport(ss,newim) = AllCatchData.pertrial.GrayScReport(idx);
subs.CaTwoToneAcc(ss,newim) = AllCatchData.pertrial.TwoToneAcc(idx);
subs.CaGrayScAcc(ss,newim) = AllCatchData.pertrial.GrayScAcc(idx);
subs.CaCanSeeNow(ss,newim) = AllCatchData.pertrial.CanSeeNow(idx);
subs.CaTwoToneCoord1(ss,newim,:) = AllCatchData.pertrial.coord1(idx,:);
subs.CaTwoToneCoord2(ss,newim,:) = AllCatchData.pertrial.coord2(idx,:);
subs.CaGrayScaleCoord1(ss,newim,:) = AllCatchData.pertrial.coord1(idx,:);
subs.CaGrayScaleCoord2(ss,newim,:) = AllCatchData.pertrial.coord2(idx,:);
elseif sum(idx) > 1 % if there are two of the same images in single particpant
fprintf('subject %i',ss)
fprintf('image %i',ii)
break
end
end
end
subs.CaImNum = subs.CaImNum + 40;
%Find Individual distances between TwoTone and GreyScale coordinates
%(pointing distance)
subs.CaTT2GSDist1 = mmperpx*hypot((subs.CaTwoToneCoord1(:,:,1) - subs.CaGrayScaleCoord1(:,:,1)), (subs.CaTwoToneCoord1(:,:,2) - subs.CaGrayScaleCoord1(:,:,2))); %distance in mm
subs.CaTT2GSDist2 = mmperpx*hypot((subs.CaTwoToneCoord2(:,:,1) - subs.CaGrayScaleCoord2(:,:,1)), (subs.CaTwoToneCoord2(:,:,2) - subs.CaGrayScaleCoord2(:,:,2))); %distance in mm
%% Demographics
Ages.Groups = unique(subs.AgeGroup(~isnan(subs.AgeGroup)));
Ages.NumGroups = length(Ages.Groups);
for i = 1:Ages.NumGroups
idx = subs.AgeGroup == i;
Ages.mean(i) = mean(subs.ages(idx),'omitnan');
Ages.minmax(i,1) = nanmin(subs.ages(idx)); %#ok<NANMIN>
Ages.minmax(i,2) = nanmax(subs.ages(idx)); %#ok<NANMAX>
Ages.SD(i) = std(subs.ages(idx),'omitnan');
Ages.size(i) = sum(idx);
Ages.GroupNames{i} = [num2str(floor(Ages.minmax(i,1))), '-', num2str(floor(Ages.minmax(i,2)))];
end
ColorRange = max(0.5*subs.ages); % for transferring colormap, - & + this number
%% Polygons
if redoPolys
for ii = 1:NumIi %#ok<UNRCH>
iid = imageIDs(ii);
background = NaN(1080,1920);
GreyImage = imread(fullfile(main_path, ['/stimuli/Pilot_Stimuli/Greyscale/Im_' num2str(iid), '.jpg']));
GreyImage = imresize(GreyImage, [680 NaN]);
GreyImageInsert = insertMatrix(background, GreyImage);
imagesc(GreyImageInsert)
colormap(gray)
disp(LookupPrompt(iid).FirstPrompt)
poly = drawpolygon('FaceAlpha',0,'Color','r');
images.ROI1Poly{iid} = poly.Position;
pause
clearvars poly
disp(LookupPrompt(iid).SecondPrompt)
poly = drawpolygon('FaceAlpha',0,'Color','r');
images.ROI2Poly{iid} = poly.Position;
pause
clearvars poly
end
end
if redoLocalPolys
for ii = 1:NumIi
iid = imageIDs(ii);
background = NaN(1080,1920);
TwoToneImage = imread(fullfile(main_path, ['/stimuli/Pilot_Stimuli/TwoTone/Im_' num2str(iid), '.jpg']));
TwoToneImage = imresize(TwoToneImage, [680 NaN]);
TwoToneInsert = insertMatrix(background, TwoToneImage);
imagesc(TwoToneInsert)
colormap(gray)
disp(LookupPrompt(iid).FirstPrompt)
poly = drawpolygon('FaceAlpha',0,'Color','r','Position',images.ROI1Poly{iid});
pause
images.ROI1LocalPoly{iid} = poly.Position
bigpoly = scale(polyshape(images.ROI1Poly{iid}),sqrt(3),mean(images.ROI1Poly{iid}))
bigpoly = drawpolygon('FaceAlpha',0,'Color','r','Position',bigpoly.Vertices);
images.ROI1BigPoly{iid} = bigpoly.Position;
pause
clearvars poly
disp(LookupPrompt(iid).SecondPrompt)
poly = drawpolygon('FaceAlpha',0,'Color','r','Position',images.ROI2Poly{iid});
pause
images.ROI2LocalPoly{iid} = poly.Position
bigpoly = scale(polyshape(images.ROI2Poly{iid}),sqrt(3),mean(images.ROI2Poly{iid}))
bigpoly = drawpolygon('FaceAlpha',0,'Color','r','Position',bigpoly.Vertices);
images.ROI2BigPoly{iid} = bigpoly.Position;
pause
clearvars poly
end
end
if redoPolysCatch
for ii = 1:length(CatchLookupPrompt) %#ok<UNRCH>
background = NaN(1080,1920);
GreyImage = imread(fullfile(main_path, ['/stimuli/CatchTrialStimuli/Greyscale/Im_' num2str(ii), '.jpg']));
GreyImage = imresize(GreyImage, [680 NaN]);
GreyImageInsert = insertMatrix(background, GreyImage);
imagesc(GreyImageInsert)
colormap(gray)
disp(CatchLookupPrompt(ii).FirstPrompt)
poly = drawpolygon('FaceAlpha',0,'Color','r');
Catch.ROI1Poly{ii} = poly.Position;
pause
clearvars poly
disp(CatchLookupPrompt(ii).SecondPrompt)
poly = drawpolygon('FaceAlpha',0,'Color','r');
Catch.ROI2Poly{ii} = poly.Position;
pause
clearvars poly
end
end
%plot polygons
figure
tiledlayout('flow', 'Padding', 'none')
for ii = 1:NumIi
iid = imageIDs(ii);
background = NaN(1080,1920);
% load two tone (fig 17 weird border)
TwoToneImage = imread(fullfile(main_path, ['/stimuli/Pilot_Stimuli/TwoTone/Im_' num2str(iid), '.jpg']));
TwoToneImage = imresize(TwoToneImage, [680 NaN]);
TwoToneInsert = insertMatrix(background, TwoToneImage);
% load greyscale
GreyImage = imread(fullfile(main_path, ['/stimuli/Pilot_Stimuli/Greyscale/Im_' num2str(iid), '.jpg']));
GreyImage = imresize(GreyImage, [680 NaN]);
GreyImageInsert = insertMatrix(background, GreyImage);
ROI1 = polyshape(images.ROI1Poly{iid});
ROI2 = polyshape(images.ROI2Poly{iid});
if images.ROI1LocalPoly{iid} ~= images.ROI1Poly{iid}
ROI1l = images.ROI1LocalPoly{iid};
end
if images.ROI2LocalPoly{iid} ~= images.ROI2Poly{iid}
ROI2l = images.ROI2LocalPoly{iid};
end
set(gcf,'Color',[1,1,1])%%%set figure background to white
nexttile
imagesc(GreyImageInsert)
colormap(gray)
hold on
plot(ROI1)
hold on
plot(ROI2)
axis off
nexttile
imagesc(TwoToneInsert)
colormap(gray)
hold on
plot(ROI1)
hold on
plot(ROI2)
hold on
plot(ROI1l)
hold on
plot(ROI2l)
axis off
end
%% compute Polygon Accuracy
disp('Computing Catch Trial Polygon Accuracy');
%define variables
AllCatchData.pertrial.Coord1PolyAcc = nan(size(AllCatchData.pertrial.pID));
AllCatchData.pertrial.Coord2PolyAcc = nan(size(AllCatchData.pertrial.pID));
AllCatchData.pertrial.ROI1Area = nan(size(AllCatchData.pertrial.pID));
AllCatchData.pertrial.ROI2Area = nan(size(AllCatchData.pertrial.pID));
for tt = 1:length(AllCatchData.pertrial.pID)
background = NaN(1080,1920);
ii = AllCatchData.pertrial.ImNum(tt);
ROI1 = polyshape(Catch.ROI1Poly{ii});
ROI2 = polyshape(Catch.ROI2Poly{ii});
AllCatchData.pertrial.ROI1Area(tt) = area(ROI1);
AllCatchData.pertrial.ROI2Area(tt) = area(ROI2);
%Individual within bound?
withinBound1 = inpolygon(AllCatchData.pertrial.coord1(tt,1),AllCatchData.pertrial.coord1(tt,2),Catch.ROI1Poly{ii}(:,1),Catch.ROI1Poly{ii}(:,2));
withinBound2 = inpolygon(AllCatchData.pertrial.coord2(tt,1),AllCatchData.pertrial.coord2(tt,2),Catch.ROI2Poly{ii}(:,1),Catch.ROI2Poly{ii}(:,2));
if ~isnan(AllCatchData.pertrial.coord1(tt,1)) && ~isnan(AllCatchData.pertrial.coord1(tt,2))
AllCatchData.pertrial.Coord1PolyAcc(tt) = double(withinBound1);
else
AllCatchData.pertrial.Coord1PolyAcc(tt) = NaN;
end
if ~isnan(AllCatchData.pertrial.coord2(tt,1)) && ~isnan(AllCatchData.pertrial.coord2(tt,2))
AllCatchData.pertrial.Coord2PolyAcc(tt) = double(withinBound2);
else
AllCatchData.pertrial.Coord2PolyAcc(tt) = NaN;
end
end
figure
tiledlayout('flow', 'Padding', 'none')
for ag = 1:Ages.NumGroups
for ii = 1:4
TwoToneImage = imread(fullfile(main_path, ['/stimuli/CatchTrialStimuli/Twotone/Im_' num2str(40+ii), '.jpg']));
TwoToneImage = imresize(TwoToneImage, [680 NaN]);
TwoToneInsert = insertMatrix(background, TwoToneImage);
ROI1 = polyshape(Catch.ROI1Poly{ii});
ROI2 = polyshape(Catch.ROI2Poly{ii});
Catch.ROI1Area(ii) = area(ROI1);
Catch.ROI2Area(ii) = area(ROI2);
set(gcf,'Color',[1,1,1]);%%%set figure background to white
x1 = 0:1920; x2 = 0:1080;
nexttile
imagesc(TwoToneInsert)
colormap(gray)
hold on
%plot ROI 1
correctID = (AllCatchData.pertrial.ageGroup == ag) & (AllCatchData.pertrial.ImNum == ii) & (AllCatchData.pertrial.Coord1PolyAcc == 1);
incorrectID = AllCatchData.pertrial.ageGroup == ag & (AllCatchData.pertrial.ImNum == ii) & AllCatchData.pertrial.Coord1PolyAcc == 0;
scatter(AllCatchData.pertrial.coord1(correctID,1), AllCatchData.pertrial.coord1(correctID,2), sizeMark, [0 0.8 0], 'o', 'filled');
hold on
scatter(AllCatchData.pertrial.coord1(incorrectID,1), AllCatchData.pertrial.coord1(incorrectID,2), sizeMark, [0.8 0 0], 'o', 'filled');
%text(AllCatchData.pertrial.pID(incorrectID),AllCatchData.pertrial.pID(incorrectID), string(Numss))
hold on
%plot ROI 2
correctID = AllCatchData.pertrial.ageGroup == ag & (AllCatchData.pertrial.ImNum == ii) & AllCatchData.pertrial.Coord2PolyAcc == 1;
incorrectID = AllCatchData.pertrial.ageGroup == ag & (AllCatchData.pertrial.ImNum == ii) & AllCatchData.pertrial.Coord2PolyAcc == 0;
scatter(AllCatchData.pertrial.coord2(correctID,1), AllCatchData.pertrial.coord2(correctID,2), sizeMark, [0 0.8 0], 'x', 'Linewidth', 2);
hold on
scatter(AllCatchData.pertrial.coord2(incorrectID,1), AllCatchData.pertrial.coord2(incorrectID,2), sizeMark, [0.8 0 0], 'x', 'Linewidth', 2);
%text(AllCatchData.pertrial.pID(incorrectID),AllCatchData.pertrial.pID(incorrectID), string(Numss))
hold on
axis off
title(Ages.GroupNames{ag} + " years")
end
end
%extract to subs struct
subs.CaCoord1PolyAcc = nan(NumSs,4);
subs.CaCoord2PolyAcc = nan(NumSs,4);
for ss = 1:NumSs
for ii = 1:4
ssIdx = ssIDs(ss);
idx = AllCatchData.pertrial.pID == ssIdx & AllCatchData.pertrial.ImNum == ii;
if sum(idx) == 1
subs.CaCoord1PolyAcc(ss,ii) = AllCatchData.pertrial.Coord1PolyAcc(idx);
subs.CaCoord2PolyAcc(ss,ii) = AllCatchData.pertrial.Coord2PolyAcc(idx);
elseif sum(idx) > 1 % if there are two of the same images in single particpant
fprintf('subject %i',ss)
fprintf('image %i',ii)
break
end
end
end
for ss = 1:NumSs
ii = 5;
ssIdx = ssIDs(ss);
idx = AllCatchData.pertrial.pID == ssIdx & AllCatchData.pertrial.ImNum == ii;
if sum(idx) == 1
if isnan(subs.CaCoord1PolyAcc(ss,4))
subs.CaCoord1PolyAcc(ss,4) = AllCatchData.pertrial.Coord1PolyAcc(idx);
end
if isnan(subs.CaCoord2PolyAcc(ss,4))
subs.CaCoord2PolyAcc(ss,4) = AllCatchData.pertrial.Coord2PolyAcc(idx);
end
elseif sum(idx) > 1 % if there are two of the same images in single particpant
fprintf('subject %i',ss)
fprintf('image %i',ii)
break
end
end
disp('Computing Gray-Scale Polygon Accuracy');
%define variables
subs.GrayScaleCoord1PolyAcc = nan(NumSs,NumIi);
subs.GrayScaleCoord2PolyAcc = nan(NumSs,NumIi);
figure
tiledlayout('flow', 'Padding', 'none', 'TileSpacing', 'tight')
for ag = 1:Ages.NumGroups
for ii = 1:NumIi
background = NaN(1080,1920);
agid = subs.AgeGroup == ag;
iid = imageIDs(ii);
% load greyscale
GrayImage = imread(fullfile(main_path, ['/stimuli/Pilot_Stimuli/Greyscale/Im_' num2str(iid), '.jpg']));
GrayImage = imresize(GrayImage, [680 NaN]);
GrayImageInsert = insertMatrix(background, GrayImage);
ROI1 = polyshape(images.ROI1Poly{iid});
ROI2 = polyshape(images.ROI2Poly{iid});
%Mean and sigma of age group aiming point for each Grey-scale image
%ROI 1
mugs1 = squeeze(mean(subs.GrayScaleCoord1(agid,ii,:),'omitnan'))';
images.sigmags1x(ii, ag) = cov(subs.GrayScaleCoord1(agid,ii,1));
images.sigmags1y(ii, ag) = cov(subs.GrayScaleCoord1(agid,ii,2));
%ROI 2
mugs2 = squeeze(mean(subs.GrayScaleCoord2(agid,ii,:),'omitnan'))';
images.sigmags2x(ii, ag) = cov(subs.GrayScaleCoord2(agid,ii,1));
images.sigmags2y(ii, ag) = cov(subs.GrayScaleCoord2(agid,ii,2));
% plot Grey-scale distributions
x1 = 0:1920; x2 = 0:1080;
nexttile
imagesc(GrayImageInsert)
colormap(gray)
hold on
plot(ROI1);
hold on
plot(ROI2);
hold on
axis off
title(Ages.GroupNames{ag} + " years")
%Group mean within Polygon?
withinBound1 = inpolygon(mugs1(1),mugs1(2),images.ROI1Poly{iid}(:,1),images.ROI1Poly{iid}(:,2));
withinBound2 = inpolygon(mugs2(1),mugs2(2),images.ROI2Poly{iid}(:,1),images.ROI2Poly{iid}(:,2));
if withinBound1 == 1
scatter(mugs1(1), mugs1(2), 100, [0 0.8 0], 'o', 'filled');
hold on
else
scatter(mugs1(1), mugs1(2), 100, [0.8 0 0], 'o', 'filled');
hold on
end
if withinBound2
scatter(mugs2(1), mugs2(2), 100, [0 0.8 0], 'x', 'Linewidth', 2);
hold on
else
scatter(mugs2(1), mugs2(2), 100, [0.8 0 0], 'x','Linewidth', 2);
hold on
end
%Individual within bound?
for ss = 1 : length(agid)
if agid(ss)
withinBound1 = inpolygon(subs.GrayScaleCoord1(ss,ii,1),subs.GrayScaleCoord1(ss,ii,2),images.ROI1Poly{iid}(:,1),images.ROI1Poly{iid}(:,2));
withinBound2 = inpolygon(subs.GrayScaleCoord2(ss,ii,1),subs.GrayScaleCoord2(ss,ii,2),images.ROI2Poly{iid}(:,1),images.ROI2Poly{iid}(:,2));
if ~isnan(subs.GrayScaleCoord1(ss,ii,1)) && ~isnan(subs.GrayScaleCoord1(ss,ii,2))
subs.GrayScaleCoord1PolyAcc(ss,ii) = double(withinBound1);
else
subs.GrayScaleCoord1PolyAcc(ss,ii) = NaN;
end
if ~isnan(subs.GrayScaleCoord2(ss,ii,1)) && ~isnan(subs.GrayScaleCoord2(ss,ii,2))
subs.GrayScaleCoord2PolyAcc(ss,ii) = double(withinBound2);
else
subs.GrayScaleCoord2PolyAcc(ss,ii) = NaN;
end
%plot ROI 1
if withinBound1 == 1
scatter(subs.GrayScaleCoord1(ss,ii,1), subs.GrayScaleCoord1(ss,ii,2), sizeMark, [0 0.8 0], 'o', 'filled');
hold on
else
scatter(subs.GrayScaleCoord1(ss,ii,1), subs.GrayScaleCoord1(ss,ii,2), sizeMark, [0.8 0 0], 'o', 'filled');
text(subs.TwoToneCoord1(ss,ii,1),subs.TwoToneCoord1(ss,ii,2), string(ss))
hold on
end
%plot ROI 2
if withinBound2
scatter(subs.GrayScaleCoord2(ss,ii,1), subs.GrayScaleCoord2(ss,ii,2), sizeMark, [0 0.8 0], 'x', 'Linewidth', 2);
hold on
else
scatter(subs.GrayScaleCoord2(ss,ii,1), subs.GrayScaleCoord2(ss,ii,2), sizeMark, [0.8 0 0], 'x', 'Linewidth', 2);
text(subs.TwoToneCoord2(ss,ii,1),subs.TwoToneCoord2(ss,ii,2), string(ss))
hold on
end
end
end
end
end
disp('Computing TwoTone Polygon Accuracy');
%define variables
subs.TwoToneCoord1PolyAcc = nan(NumSs,NumIi);
subs.TwoToneCoord2PolyAcc = nan(NumSs,NumIi);
figure
tiledlayout('flow', 'Padding', 'none', 'TileSpacing', 'tight')
for ag = 1:Ages.NumGroups
for ii = 1:NumIi
figure
tiledlayout('flow', 'Padding', 'none', 'TileSpacing', 'tight')
background = NaN(1080,1920);
agid = subs.AgeGroup == ag;
iid = imageIDs(ii);
TwoToneImage = imread(fullfile(main_path, ['/stimuli/Pilot_Stimuli/TwoTone/Im_' num2str(iid), '.jpg']));
TwoToneImage = imresize(TwoToneImage, [680 NaN]);
TwoToneInsert = insertMatrix(background, TwoToneImage);
ROI1 = polyshape(images.ROI1Poly{iid});
ROI2 = polyshape(images.ROI2Poly{iid});
%Mean and sigma of age group aiming point for each Two-Tone image
%ROI 1
mutt1 = squeeze(mean(subs.TwoToneCoord1(agid,ii,:),'omitnan'))';
sigmatt1 = cov(subs.TwoToneCoord1(agid,ii,1), subs.TwoToneCoord1(agid,ii,2));
images.sigmatt1x(ii, ag) = cov(subs.TwoToneCoord1(agid,ii,1));
images.sigmatt1y(ii, ag) = cov(subs.TwoToneCoord1(agid,ii,2));
images.ROI1Area(ii) = area(ROI1);
images.ROI2Area(ii) = area(ROI2);
%ROI 2
mutt2 = squeeze(mean(subs.TwoToneCoord2(agid,ii,:),'omitnan'))';
sigmatt2 = cov(subs.TwoToneCoord2(agid,ii,1), subs.TwoToneCoord2(agid,ii,2));
images.sigmatt2x(ii, ag) = cov(subs.TwoToneCoord2(agid,ii,1));
images.sigmatt2y(ii, ag) = cov(subs.TwoToneCoord2(agid,ii,2));
% plot Two-Tone distributions
x1 = 0:1920; x2 = 0:1080;
nexttile
imagesc(TwoToneInsert)
colormap(gray)
hold on
plot(ROI1);
hold on
plot(ROI2);
hold on
axis off
title(Ages.GroupNames{ag} + " years")
%Group mean within Polygon?
withinBound1 = inpolygon(mutt1(1),mutt1(2),images.ROI1Poly{iid}(:,1),images.ROI1Poly{iid}(:,2));
withinBound2 = inpolygon(mutt2(1),mutt2(2),images.ROI2Poly{iid}(:,1),images.ROI2Poly{iid}(:,2));
if withinBound1 == 1
scatter(mutt1(1), mutt1(2), 100, [0 0.8 0], 'o', 'filled');
else
scatter(mutt1(1), mutt1(2), 100, [0.8 0 0], 'o', 'filled');
end
if withinBound2
scatter(mutt2(1), mutt2(2), 100, [0 0.8 0], 'x', 'Linewidth', 2);
else
scatter(mutt2(1), mutt2(2), 100, [0.8 0 0], 'x','Linewidth', 2);
end
%Individual within bound?
for ss = 1 : length(agid)
if agid(ss)
withinBound1l = NaN;
withinBound2l = NaN;
withinBound1b = NaN;
withinBound2b = NaN;
withinBound1 = inpolygon(subs.TwoToneCoord1(ss,ii,1),subs.TwoToneCoord1(ss,ii,2),images.ROI1Poly{iid}(:,1),images.ROI1Poly{iid}(:,2));
withinBound2 = inpolygon(subs.TwoToneCoord2(ss,ii,1),subs.TwoToneCoord2(ss,ii,2),images.ROI2Poly{iid}(:,1),images.ROI2Poly{iid}(:,2));
if ~isnan(subs.TwoToneCoord1(ss,ii,1)) && ~isnan(subs.TwoToneCoord1(ss,ii,2))
subs.TwoToneCoord1PolyAcc(ss,ii) = double(withinBound1);
else
subs.TwoToneCoord1PolyAcc(ss,ii) = NaN;
end
if ~isnan(subs.TwoToneCoord2(ss,ii,1)) && ~isnan(subs.TwoToneCoord2(ss,ii,2))
subs.TwoToneCoord2PolyAcc(ss,ii) = double(withinBound2);
else
subs.TwoToneCoord2PolyAcc(ss,ii) = NaN;
end
%local polys
if images.ROI1LocalPoly{iid} ~= images.ROI1Poly{iid}
withinBound1l = inpolygon(subs.TwoToneCoord1(ss,ii,1),subs.TwoToneCoord1(ss,ii,2),images.ROI1LocalPoly{iid}(:,1),images.ROI1LocalPoly{iid}(:,2));
if subs.TwoToneCoord1PolyAcc(ss,ii) == 0
withinBound1b = inpolygon(subs.TwoToneCoord1(ss,ii,1),subs.TwoToneCoord1(ss,ii,2),images.ROI1BigPoly{iid}(:,1),images.ROI1BigPoly{iid}(:,2));
else
withinBound1b = NaN;
end
if ~isnan(subs.TwoToneCoord1(ss,ii,1)) && ~isnan(subs.TwoToneCoord1(ss,ii,2))
subs.TwoToneCoord1LocalPolyAcc(ss,ii) = double(withinBound1l);
subs.TwoToneCoord1BigPolyAcc(ss,ii) = double(withinBound1b);
subs.TwoToneCoord1PolyAcc(ss,ii) = double(withinBound1);
else
subs.TwoToneCoord1LocalPolyAcc(ss,ii) = NaN;
subs.TwoToneCoord1BigPolyAcc(ss,ii) = NaN;
end
else
subs.TwoToneCoord1LocalPolyAcc(ss,ii) = NaN;
subs.TwoToneCoord1BigPolyAcc(ss,ii) = NaN;
end
if images.ROI2LocalPoly{iid} ~= images.ROI2Poly{iid}
withinBound2l = inpolygon(subs.TwoToneCoord2(ss,ii,1),subs.TwoToneCoord2(ss,ii,2),images.ROI2LocalPoly{iid}(:,1),images.ROI2LocalPoly{iid}(:,2));
if subs.TwoToneCoord2PolyAcc(ss,ii) == 0
withinBound2b = inpolygon(subs.TwoToneCoord2(ss,ii,1),subs.TwoToneCoord2(ss,ii,2),images.ROI2BigPoly{iid}(:,1),images.ROI2BigPoly{iid}(:,2));
else
withinBound2b = NaN;
end
if ~isnan(subs.TwoToneCoord2(ss,ii,1)) && ~isnan(subs.TwoToneCoord2(ss,ii,2))
subs.TwoToneCoord2LocalPolyAcc(ss,ii) = double(withinBound2l);
subs.TwoToneCoord2BigPolyAcc(ss,ii) = double(withinBound2b);
else
subs.TwoToneCoord2LocalPolyAcc(ss,ii) = NaN;
subs.TwoToneCoord2BigPolyAcc(ss,ii) = NaN;
end
else
subs.TwoToneCoord2LocalPolyAcc(ss,ii) = NaN;
subs.TwoToneCoord2BigPolyAcc(ss,ii) = NaN;
end
%plot ROI 1
if withinBound1 == 1
scatter(subs.TwoToneCoord1(ss,ii,1), subs.TwoToneCoord1(ss,ii,2), sizeMark, [0 0.8 0], 'o', 'filled');
text(subs.TwoToneCoord1(ss,ii,1),subs.TwoToneCoord1(ss,ii,2), string(ss))
hold on
elseif withinBound1l == 1
scatter(subs.TwoToneCoord1(ss,ii,1), subs.TwoToneCoord1(ss,ii,2), sizeMark, [0 0 0.8], 'o', 'filled');
text(subs.TwoToneCoord1(ss,ii,1),subs.TwoToneCoord1(ss,ii,2), string(ss))
hold on
elseif withinBound1b == 1
scatter(subs.TwoToneCoord1(ss,ii,1), subs.TwoToneCoord1(ss,ii,2), sizeMark, [0.8 0 0.8], 'o', 'filled');
text(subs.TwoToneCoord1(ss,ii,1),subs.TwoToneCoord1(ss,ii,2), string(ss))
hold on
else
scatter(subs.TwoToneCoord1(ss,ii,1), subs.TwoToneCoord1(ss,ii,2), sizeMark, [0.8 0 0], 'o', 'filled');
text(subs.TwoToneCoord1(ss,ii,1),subs.TwoToneCoord1(ss,ii,2), string(ss))
hold on
end
%plot ROI 2
if withinBound2 == 1
scatter(subs.TwoToneCoord2(ss,ii,1), subs.TwoToneCoord2(ss,ii,2), sizeMark, [0 0.8 0], 'x', 'Linewidth', 2);
text(subs.TwoToneCoord2(ss,ii,1),subs.TwoToneCoord2(ss,ii,2), string(ss))
hold on
elseif withinBound2l == 1
scatter(subs.TwoToneCoord2(ss,ii,1), subs.TwoToneCoord2(ss,ii,2), sizeMark, [0 0 0.8], 'x', 'Linewidth', 2);
text(subs.TwoToneCoord2(ss,ii,1),subs.TwoToneCoord2(ss,ii,2), string(ss))
hold on
elseif withinBound2b == 1
scatter(subs.TwoToneCoord2(ss,ii,1), subs.TwoToneCoord2(ss,ii,2), sizeMark, [0.8 0 0.8], 'x', 'Linewidth', 2);
text(subs.TwoToneCoord2(ss,ii,1),subs.TwoToneCoord2(ss,ii,2), string(ss))
hold on
else
scatter(subs.TwoToneCoord2(ss,ii,1), subs.TwoToneCoord2(ss,ii,2), sizeMark, [0.8 0 0], 'x', 'Linewidth', 2);
text(subs.TwoToneCoord2(ss,ii,1),subs.TwoToneCoord2(ss,ii,2), string(ss))
hold on
end
end
end
clearvars ROI1l ROI2l
end
end
%% Local polygon barplots
%Figure 3B
%local errors
clearvars locals incorrects
figure
set(gcf,'Color',[1,1,1]) %set figure background to white
set(gcf,'Position',[100,100,500,400]); %specify figure size and location
idx1 = ~isnan(mean(subs.TwoToneCoord1LocalPolyAcc, 'omitnan'));
idx2 = ~isnan(mean(subs.TwoToneCoord2LocalPolyAcc, 'omitnan'));
ags = [4 3 2 1];
for ag = 1:Ages.NumGroups
agid = subs.AgeGroup == ags(ag);
ToExclude = isnan(cell2mat(subs.TwoToneScored(agid,:)))| isnan(cell2mat(subs.GreyScaleScored(agid,:))); %didn't answer both TT & GS
incorrect = cell2mat(subs.GreyScaleScored(agid,:)) == 0;
LocalCorrect1 = subs.TwoToneCoord1LocalPolyAcc(agid,idx1);
LocalCorrect1(ToExclude(:,idx1)) = NaN;
LocalCorrect1(incorrect(:,idx1)) = NaN;
LocalCorrect2 = subs.TwoToneCoord2LocalPolyAcc(agid,idx2);
LocalCorrect2(ToExclude(:,idx2)) = NaN;
LocalCorrect2(incorrect(:,idx2)) = NaN;
locals(ag,:) = sum([LocalCorrect1 LocalCorrect2],'omitnan');
Correct1 = subs.TwoToneCoord1PolyAcc(agid,idx1);
Correct1(ToExclude(:,idx1)) = NaN;
Correct1(incorrect(:,idx1)) = NaN;
Correct2 = subs.TwoToneCoord2PolyAcc(agid,idx2);
Correct2(ToExclude(:,idx2)) = NaN;
Correct2(incorrect(:,idx2)) = NaN;
incorrects(ag,:) = sum([Correct1==0 Correct2==0],'omitnan');
BigPoly1 = subs.TwoToneCoord1BigPolyAcc(agid,:);
BigPoly1(ToExclude) = NaN;
BigPoly1(incorrect) = NaN;
BigPoly2 = subs.TwoToneCoord2BigPolyAcc(agid,:);
BigPoly2(ToExclude) = NaN;
BigPoly2(incorrect) = NaN;
globals(ag,:) = sum([BigPoly1 BigPoly2],'omitnan');
Poly1 = subs.TwoToneCoord1PolyAcc(agid,:);
Poly1(ToExclude) = NaN;
Poly1(incorrect) = NaN;
Poly2 = subs.TwoToneCoord2PolyAcc(agid,:);
Poly2(ToExclude) = NaN;
Poly2(incorrect) = NaN;
totalerr(ag,:) = sum([Poly1==0 Poly2==0],'omitnan');
total(ag,:) = sum([~isnan(Poly1) ~isnan(Poly2)],'omitnan');
end
percentlocals = (locals ./ incorrects)*100;
percentglobals = (globals ./ totalerr)*100;
percenttotals = (totalerr ./ total)*100;
%locals plot
b = bar(mean(percentlocals','omitnan'), 'facecolor', 'flat');
hold on
e = errorbar(b.XEndPoints, b.YEndPoints, std(percentlocals','omitnan')/sqrt(length(~isnan(percentlocals)')),...
'Color', [0 0 0], 'MarkerEdgeColor', [0 0 0], 'LineWidth', 2, 'LineStyle', 'none');
e.CapSize = 10;
b.CData = [MeanColours{2,1}; MeanColours{2,2}; MeanColours{2,3}; MeanColours{2,4}];
b.LineWidth = 2;
set(gca,'xlim', [0.25 4.75]);
set(gca,'ylim', [0 50]);
set(gca,'xticklabels', {'4-5' '7-9' '10-12' 'adult'}, 'FontSize', 25);
ylabel('Local errors (%)', 'FontSize', 25);
ax = gca;
ax.LineWidth = 2;
box off
ax.XAxis.TickLength = [0 0];
%globals plot
figure
set(gcf,'Color',[1,1,1]) %set figure background to white
set(gcf,'Position',[100,100,500,400]); %specify figure size and location
b2 = bar(mean(percentglobals','omitnan'), 'facecolor', 'flat');
hold on
e2 = errorbar(b2.XEndPoints, b2.YEndPoints, std(percentglobals','omitnan')/sqrt(length(~isnan(percentglobals)')),...
'Color', [0 0 0], 'MarkerEdgeColor', [0 0 0], 'LineWidth', 2, 'LineStyle', 'none');
e2.CapSize = 10;
b2.CData = [MeanColours{2,1}; MeanColours{2,2}; MeanColours{2,3}; MeanColours{2,4}];
b2.LineWidth = 2;
set(gca,'xlim', [0.25 4.75]);
set(gca,'ylim', [0 50]);
set(gca,'xticklabels', {'4-5' '7-9' '10-12' 'adult'}, 'FontSize', 25);
%set(gca,'ytick', 0:10:100);
ylabel('Global errors (%)', 'FontSize', 25);
ax = gca;
ax.LineWidth = 2;
box off
ax.XAxis.TickLength = [0 0];
%% Image Analysis
if exist('ImageAn.mat', 'file')
load('ImageAn.mat');
load('CaImageAn.mat');
Catch_TTStats = load(fullfile(main_path, '/scripts/Analysis/CatchTwoToneStatsfovG30_fovB30.mat'));
Catch_GSStats = load(fullfile(main_path, 'scripts/Analysis/CatchGreyScaleStatsfovG30_fovB30.mat'));
TT_Stats = load(fullfile(main_path, 'scripts/Analysis/TwoToneStatsfovG30_fovB30.mat'));
GS_Stats = load(fullfile(main_path, 'scripts/Analysis/GreyScaleStatsfovG30_fovB30.mat'));
else
for ii = 1:NumIi
iid = imageIDs(ii);
background = zeros(1080,1920);
% load two tone
TwoToneImage = imread(fullfile(main_path, ['/stimuli/Pilot_Stimuli/TwoTone/Im_' num2str(iid), '.jpg']));
TwoToneImage = imresize(TwoToneImage, [680 NaN]);
TwoToneInsert = insertMatrix(background, TwoToneImage);
BW1 = edge(TwoToneInsert,'Sobel');
imshowpair(TwoToneInsert,BW1,'montage')
%edges of whole image
imageAn.ID(ii) = iid;
imageAn.size(ii,:)= size(TwoToneImage);
imageAn.edges(ii) = (sum(sum(BW1)))./(BGsize(1)*BGsize(2))*100; %calculate edges as percentage of screen size
imageAn.edges2(ii) = (sum(sum(BW1))./(imageAn.size(ii,1)*imageAn.size(ii,2)))*100; %calculate edges as percentage of image size (edge density)
% load grey scale
GreyImage = imread(fullfile(main_path, ['/stimuli/Pilot_Stimuli/Greyscale/Im_' num2str(iid), '.jpg']));
GreyImage = imresize(GreyImage, [680 NaN]);
GreyImageInsert = insertMatrix(background, GreyImage);
BW2 = edge(GreyImageInsert,'Sobel');
imshowpair(GreyImageInsert,BW2,'montage')
%edges of whole image
imageAn.GSedges(ii) = (sum(sum(BW2)))./(BGsize(1)*BGsize(2))*100; %calculate edges as percentage of screen size
imageAn.GSedges2(ii) = (sum(sum(BW2))./(imageAn.size(ii,1)*imageAn.size(ii,2)))*100; %calculate edges as percentage of image size (edge density)
end
FourierTT = load(fullfile(main_path,'scripts/Analysis/imstats_tessamooneys/fourierproperties_twotones.mat'));
WBstatsTT = load(fullfile(main_path, 'scripts/Analysis/imstats_tessamooneys/WBstatistics_defaultsettings_twotones.mat'));
FourierGS = load(fullfile(main_path, 'scripts/Analysis/imstats_tessamooneys/fourierproperties_grayscale.mat'));
WBstatsGS = load(fullfile(main_path, 'scripts/Analysis/imstats_tessamooneys/WBstatistics_defaultsettings_grayscale.mat'));
for ii = 1:NumIi
for tt = 1:NumIi
if contains(['Im_' num2str(imageAn.ID(ii)) '.jpg'],FourierTT.names(tt))
imageAn.TTFourierIntercept(ii) = FourierTT.intercept(tt);
imageAn.TTFourierSlope(ii) = FourierTT.slope(tt);
end
if contains(['Im_' num2str(imageAn.ID(ii)) '.jpg'],FourierGS.names(tt))
imageAn.GSFourierIntercept(ii) = FourierGS.intercept(tt);
imageAn.GSFourierSlope(ii) = FourierGS.slope(tt);
end
if contains(['Im_' num2str(imageAn.ID(ii)) '.jpg'],WBstatsTT.filenames(tt))
imageAn.TTLGNBeta(ii) = WBstatsTT.LGNBeta(tt); %Beta parameter varies with the range ofcontrast strengths present in the image (Contrast Energy)
imageAn.TTLGNGamma(ii) = WBstatsTT.LGNGamma(tt); % Gammaparameter varies with the degree of correlation between contrasts (Spatial Coherance)
imageAn.TTV1Beta(ii) = WBstatsTT.V1Beta(tt);
imageAn.TTV1Gamma(ii) = WBstatsTT.V1Gamma(tt);
imageAn.TTBeta(ii) = WBstatsTT.Beta(tt);
imageAn.TTGamma(ii) = WBstatsTT.Gamma(tt);
end
if contains(['Im_' num2str(imageAn.ID(ii)) '.jpg'],WBstatsGS.filenames(tt))
imageAn.GSLGNBeta(ii) = WBstatsGS.LGNBeta(tt);
imageAn.GSLGNGamma(ii) = WBstatsGS.LGNGamma(tt);
imageAn.GSV1Beta(ii) = WBstatsGS.V1Beta(tt);
imageAn.GSV1Gamma(ii) = WBstatsGS.V1Gamma(tt);
imageAn.GSBeta(ii) = WBstatsGS.Beta(tt);
imageAn.GSGamma(ii) = WBstatsGS.Gamma(tt);
end
end
end
end
%% LOAD Neural network scores from Scores.xls
NetScores = readtable('Scores.xlsx');
% Load 2nd Image set (ImageNet) scores
ImNet.levels = readtable('ImNetScores.xlsx');
ImNet.Ps = readtable('ImNetScores.xlsx', 'Sheet', 'Participants');
ImNet.P1 = readtable('ImNetScores.xlsx', 'Sheet', 'P1');
ImNet.P2 = readtable('ImNetScores.xlsx', 'Sheet', 'P2');
ImNet.P3 = readtable('ImNetScores.xlsx', 'Sheet', 'P3');
ImNet.P4 = readtable('ImNetScores.xlsx', 'Sheet', 'P4');
ImNet.P5 = readtable('ImNetScores.xlsx', 'Sheet', 'P5');
ImNet.P6 = readtable('ImNetScores.xlsx', 'Sheet', 'P6');
ImNet.P7 = readtable('ImNetScores.xlsx', 'Sheet', 'P7');
ImNet.P8 = readtable('ImNetScores.xlsx', 'Sheet', 'P8');
ImNet.P9 = readtable('ImNetScores.xlsx', 'Sheet', 'P9');
ImNet.NasNet = readtable('ImNetScores.xlsx', 'Sheet', 'NasNet');
ImNet.AlexNet= readtable('ImNetScores.xlsx', 'Sheet', 'AlexNet');
ImNet.CorNet = readtable('ImNetScores.xlsx', 'Sheet', 'CorNet-S');
%extract participant (1:9) and Network (10:11) data
ImNet.Ims = ImNet.P1{4:end-1,3}; %order of images presented (all structs in this order)
for i = 1 : length(ImNet.Ims)
im = ImNet.Ims(i);
ImNet.smooth(i) = ImNet.levels{im,3};
ImNet.thresh(i) = ImNet.levels{im,4};
ImNet.TT1(i,:) = [ImNet.P1{i+3, 6}, ImNet.P2{i+3, 6}, ImNet.P3{i+3, 6}, ImNet.P4{i+3, 6}...
ImNet.P5{i+3, 6} ImNet.P6{i+3, 6} ImNet.P7{i+3, 6} ImNet.P8{i+3, 6} ImNet.P9{i+3, 6} ...