-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEagleDBAnalysis73013.m
executable file
·1146 lines (842 loc) · 35.6 KB
/
EagleDBAnalysis73013.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
% it was then updated with some user ids
load EaglemanColoredAlphabets.mat
% whos
% Name Size Bytes Class Attributes
%
% READ_ME 1x106 212 char
% ans 1x49 98 char
% labels 26x1 52 char
% u_rab 6588x3x26 4110912 double
% u_rgb 6588x4x26 5481216 double
% u_rlab 6588x4x26 5481216 double
% userid 6588x1 52704 double
% some usefuls stuff
letters = ['A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'];
names = {...
'black' ...
'white' ...
'red' ...
'green' ...
'yellow' ...
'blue' ...
'brown' ...
'purple' ...
'pink' ...
'orange' ...
'grey'...
'none',...
};
histcolors = [ 0 0 0;
1 1 1;
1 0 0;
0 1 0;
1 1 0;
0 0 1;
.8 .4 .12;
.8 0 .8;
1 .1 .55;
1 .6 0;
.5 .5 .5;
0 0 0;
];
% show me the nans in the database
s_nansdistribution
% AboutPtCols'
% ans =
%
% 'users_id'
% 'BatteryId'
% 'txtAge'
% 'optGender'
% 'txtMotherTongue'
% 'optSynInFamily'
% 'optHandedness'
% 'optMusicPitch'
% etc....
LoadAboutPt
% whos
% Name Size Bytes Class Attributes
%
% AboutPt 54450x31 107375498 cell
% AboutPtCols 1x31 2674 cell
% visualize the whole database
fp_visualizeEagDB
% suppose we wanted to something weird, like estimate the expected
% proportions of colors from the labeled database. that is, what
% percentage of the space is black etc....
load lRGBnathan.mat;
per_colorspace=[];
for i=0:11
per_colorspace = [per_colorspace length(find(labeledRGB == i))];
end
% check that it adds up to 972
% sum(per_colorspace)
disp('labeled rgb space color proportions');
for i=1:length(names)
disp([names{i} ' ' num2str(per_colorspace(i)/sum(per_colorspace),'%0.2f')]);
end
% %
% just brings out the things that can be seen from the full dataset.
% A is red more than 50% of the time
% B is blue more than 40% of the time
% c is yellow around 38% of the time
% D has no obvious hue preference
% E does seem to be dominated by blues yellows and greens not sure why.
% G is green about 37% of the time
% h is orange about 30% of the time
% I is black or white about 58% of the time but mostly black
% L has a slight tendency towards yellow or blue
% M is red about 30% of the time
% N is orange about 22 % of the time
% O is black or white about 60 % of the time
% R is red about 38% of the time
% X is blacke about 39% of the time
% Y is yellow about 42% of the time
% Z is black about 38% of the time
% next we would like to find out how many synesthetes in the database were
% likely to have had the magnet set. running this script generates a
% number of useful figures
% s_fpEaglemanMatches
s_fpRichAndEaglemanMatches
% to obtain an actual probability, let's shuffle the data set many times
% and count the probability of observing n or more matches
s_pNorMoreMatchestoMagnets
% the first three figures show variations on the number of subjects with n matches to the
% letter set ranging from 0 to 26 letters. this was done by assigning
% each match to a color label by comparing it to a labeled rgb cube (which
% might still need some work). the green line shows the number of
% subjects with n matches to the set when the data is shuffled. the two
% lines begin to diverge by 8 letters but there are only 10 subjects with
% 10 matches to the letter set when the data is shuffled, but 100 when not
% shuffled for the same number of matches. there are no subjects which
% have more than 10 matches when the shuffled data set is compared to the magnets
% while there are hundreds when using the unshuffled data
% there are about 400 or so if one strictly counts more than 10 matches.
% of course even 8 matches is unlikely, at least if one views the problem
% as a series of independent random draws with 11 choices and with
% replacement. so the question is, is the green line a fair null
% distribution? one question is if it matters that some of the bins
% repeat. i.e. there are 4 red letters. given that a sizeable percentage
% of the subjects appear to have had the magnet set, does that skew the
% green distribution rightward? that might happen because those subjects
% have ideally only 6 different colors of letters and also only 6 bins. in
% any case, the number of matches expected in that case would be much
% higher than when thought about as a binomial distribution.
% the fourth figure shows that the real data and the shuffled data show the
% same distribution of matches to a shuffled data set. which is to be
% expected.
fp_visualizeShuffledEagDB
% or, suppose we pulled out those that have more than 10 matches to the
% fridge magnets and shuffled the remainder. what does that distribution
% look like? have to make up those 500 subjects unless the curves are
% normalized.
% another thing is to run this same analysis but comparing subjects to the
% strong group level frequencies in the data.
% s_gtEaglemanMatches
s_fqEaglemanMatches
% this also reminds me that perhaps we should look for subjects who give
% the same color for most letters. that would be a likely sign of fraud or
% at least unverifiability, and would impact the shuffling in a weird way
% if there were a lot of them.
% we should probably see if we can assign each synesthete to a group and
% generate separate plots for each. really the point is to analyze the
% subjects left after you take out the frequent template group and the
% magnet group
syntype = zeros(length(dbLabeled),1);
% num of matches needed to be in group
magnetthreshold = 10;
fqthreshold = 10;
% code for labels variable is in s_fpEaglemanMatches but in this script
% should be in workspacelabels.
magmatches = labels.eagleman == labels.magnet;
fqmatches = labels.eagleman == labels.fq;
% let's set the fq first
syntype(find(sum(fqmatches,2)>=fqthreshold))=1;
% then magnet.
syntype(find(sum(magmatches,2)>=magnetthreshold))=2;
% maybe want to find those that are in both groups?
%% plot colors for matches that are close to magnet set
% % % whole data set with modes for each letter
figure('name', 'whole database', 'Color', [1 1 1],'Position',get(0,'ScreenSize'));
% make a graphical legend 10% as tall as the result
theLegend = rgb.fq(1:length(syntype)/10,:,:);
theResult = rgb.eagle;
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]))
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18)
box off;
% let's plot each group
% magnets
% matches
figure('name', [ num2str(length(find(syntype==2))) ...
' subjects with more than ' num2str(magnetthreshold) ...
' matches to letter set'], 'Color', [1 1 1],'Position',get(0,'ScreenSize'));
subplot(1,3,1);
% make a graphical legend 10% as tall as the result
theLegend = rgb.magnets(1:length(find(syntype==2))/10,:,:);
theResult = rgb.eagle(find(syntype==2),:,:);
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]))
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18)
title([ num2str(length(find(syntype==2))) ...
' subjects with more than ' num2str(magnetthreshold) ...
' matches to letter set'])
% if you wanted to compare it to the earlier figure, you would shuffle the
% data instead of the magnet set and then sort. the magnet set is just one
% throw instead of n?
% would be better to use the rich, but don't have rgb values, just
% simulated labels
% All the shuffled matches
% figure('name', ['top ' num2str(length(find(syntype==2))) ' shuffled matches to letter set'], 'Color', [1 1 1]);
subplot(1,3,3);
% [Y, ranking] = sort(nummatches.eagleShuffle2magnet, 'descend');
% this is now
[Y, ranking] = sort(nummatches.eagleShuffleByCol, 'descend');
best = ranking(1:length(find(syntype==2)));
% make a graphical legend 10% as tall as the result
theLegend = rgb.magnets(1:round(length(find(syntype==2))/10),:,:);
theResult = rgb.eagleShuffledByCol(best,:,:);
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]))
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18)
title('All col shuffled matches to magnet set')
subplot(1,3,2);
% [Y, ranking] = sort(nummatches.eagleShuffle2magnet, 'descend');
% this is now
[Y, ranking] = sort(nummatches.eagleShuffleByRow, 'descend');
best = ranking(1:length(find(syntype==2)));
% make a graphical legend 10% as tall as the result
theLegend = rgb.magnets(1:round(length(find(syntype==2))/10),:,:);
theResult = rgb.eagleShuffledByRow(best,:,:);
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]))
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18)
title('All row shuffled matches to magnet set')
%
% % makes this into a nice sfn figure
% fsize=get(gcf,'Position');
% set(gcf,'Position',[5 5 5*fsize(3) 5*fsize(4)]);
% saveas(gcf,'magnetsAndShuffledRGB.jpg','jpg');
%
% how are nans distributed across letters for this subset?
magsubindx = find(syntype==2);
figure('Name','distribution of nans across letters','Color',[1 1 1]);
subplot(1,2,1);
% figure where nans are black and color matches are white
% get one rgb column of data for subs x letters
imagesc(nansmatrix(magsubindx,:));
colormap(bone);
box off;
xlabel('letters');
ylabel('subjects');
set(gca,'XTick',[1:26],'XTickLabel',letters);
% let's look at the distribution across letters
subplot(1,2,2);
bar(sum(nansmatrix(magsubindx,:))/length(magsubindx));;
box off;
xlabel('letters');
ylabel('number of times not matched');
set(gca,'XTick',[1:26],'XTickLabel',letters);
% histogram
% colors come from fp_visualizeEagDB
makeLetterXColorHist(dbNumbered(find(syntype==2),:));
set(gcf,'Name','just magnet syns');
% want to slip a table in here too in the command window
disp('magnet proportions');
disp(['letter black white red green yellow blue brown purple pink orange grey']);
for i=1:26
[counts, bins]=hist(dbNumbered(find(syntype==2),i),11);
counts = counts/length(find(syntype==2));
disp([letters(i) ' ' num2str(counts,'%0.2f ')]);
end
% high fq
figure('name', [ num2str(length(find(syntype==1))) ...
' subjects with more than ' num2str(fqthreshold) ...
' matches to high fq template'], 'Color', [1 1 1],'Position',get(0,'ScreenSize'));
subplot(1,3,1);
% make a graphical legend 10% as tall as the result
theLegend = rgb.fq(1:length(find(syntype==1))/10,:,:);
theResult = rgb.eagle(find(syntype==1),:,:);
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]));
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18)
title([ num2str(length(find(syntype==1))) ...
' subjects with more than ' num2str(magnetthreshold) ...
' matches to high fq template']);
% if you wanted to compare it to the earlier figure, you would shuffle the
% data instead of the magnet set and then sort. the magnet set is just one
% throw instead of n? would be good to use rich, but it is only simulated
% labels, not really good to simulate rgb values, though we could
% All the shuffled matches
% figure('name', ['top ' num2str(length(find(syntype==1))) ' shuffled matches to high fq template'], 'Color', [1 1 1]);
subplot(1,3,3);
% [Y, ranking] = sort(nummatches.eagleShuffle2magnet, 'descend');
% is now
[Y, ranking] = sort(nummatches.eagleShuffleByCol, 'descend');
best = ranking(1:length(find(syntype==1)));
% make a graphical legend 10% as tall as the result
theLegend = rgb.fq(1:round(length(find(syntype==1))/10),:,:);
theResult = rgb.eagleShuffledByCol(best,:,:);
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]));
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18);
title(['top ' num2str(length(find(syntype==1))) ' col shuffled matches to high fq template']);
subplot(1,3,2);
% [Y, ranking] = sort(nummatches.eagleShuffle2magnet, 'descend');
% is now
[Y, ranking] = sort(nummatches.eagleShuffleByRow, 'descend');
best = ranking(1:length(find(syntype==1)));
% make a graphical legend 10% as tall as the result
theLegend = rgb.fq(1:round(length(find(syntype==1))/10),:,:);
theResult = rgb.eagleShuffledByRow(best,:,:);
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]));
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18);
title(['top ' num2str(length(find(syntype==1))) ' row shuffled matches to high fq template']);
%
% % makes this into a nice sfn figure
% fsize=get(gcf,'Position');
% set(gcf,'Position',[5 5 5*fsize(3) 5*fsize(4)]);
% saveas(gcf,'svgplots/SFN2013AndShuffledRGB.jpg','jpg');
%
% how are nans distributed across letters for this subset?
fqsubindx = find(syntype==1);
figure('Name','distribution of nans across letters for fq syns','Color',[1 1 1],'Position',get(0,'ScreenSize'));
subplot(1,2,1);
% figure where nans are black and color matches are white
% get one rgb column of data for subs x letters
imagesc(nansmatrix(fqsubindx,:));
colormap(bone);
box off;
xlabel('letters');
ylabel('subjects');
set(gca,'XTick',[1:26],'XTickLabel',letters);
% let's look at the distribution across letters
subplot(1,2,2);
bar(sum(nansmatrix(fqsubindx,:))/length(fqsubindx));
box off;
xlabel('letters');
ylabel('number of times not matched');
set(gca,'XTick',1:26,'XTickLabel',letters);
% histogram
% colors come from fp_visualizeEagDB
makeLetterXColorHist(dbNumbered(find(syntype==1),:));
set(gcf,'Name','just high fq syns');
% want to slip a table in here too in the command window
disp('high fq proportions');
disp(['letter black white red green yellow blue brown purple pink orange grey']);
for i=1:26
[counts, bins]=hist(dbNumbered(find(syntype==1),i),11);
counts = counts/length(find(syntype==1));
disp([letters(i) ' ' num2str(counts,'%0.2f ')]);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % NO GROUP MATCHES AND SHUFFLING
% remainder
figure('name', [ num2str(length(find(syntype==0))) ...
' subjects with no group'], 'Color', [1 1 1]);
subplot(1,3,1);
% make a graphical legend 10% as tall as the result
% theLegend = rgb.fq(1:length(find(syntype==2))/10,:,:);
theResult = rgb.eagle(find(syntype==0),:,:);
theLegend = rgb.fq(1:round(length(find(syntype==0))/10),:,:);
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]));
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18)
title([ num2str(length(find(syntype==0))) ...
' subjects with no group']);
% All the shuffled matches
% figure('name', ['top ' num2str(length(find(syntype==1))) ' shuffled matches to high fq template'], 'Color', [1 1 1]);
subplot(1,3,3);
% [Y, ranking] = sort(nummatches.eagleShuffle2magnet, 'descend');
% is now
[Y, ranking] = sort(nummatches.eagleShuffleByCol, 'descend');
best = ranking(1:length(find(syntype==0)));
% make a graphical legend 10% as tall as the result
theLegend = rgb.fq(1:round(length(find(syntype==0))/10),:,:);
theResult = rgb.eagleShuffledByCol(best,:,:);
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]));
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18);
title(['top ' num2str(length(find(syntype==1))) ' col shuffled matches to high fq template']);
subplot(1,3,2);
% [Y, ranking] = sort(nummatches.eagleShuffle2magnet, 'descend');
% is now
[Y, ranking] = sort(nummatches.eagleShuffleByRow, 'descend');
best = ranking(1:length(find(syntype==0)));
% make a graphical legend 10% as tall as the result
theLegend = rgb.fq(1:round(length(find(syntype==0))/10),:,:);
theResult = rgb.eagleShuffledByRow(best,:,:);
theStack = [theResult; theLegend];
imagesc(permute(theStack, [1 3 2]));
set(gca, 'XTick', 1:26, 'XTickLabel', letters, 'YTick', [1 n], 'FontSize', 18);
title(['top ' num2str(length(find(syntype==1))) ' row shuffled matches to high fq template']);
% how are nans distributed across letters for this subset?
ngsubindx = find(syntype==0);
figure('Name','distribution of nans across letters for no group syns','Color',[1 1 1],'Position',get(0,'ScreenSize'));
subplot(1,2,1);
% figure where nans are black and color matches are white
% get one rgb column of data for subs x letters
imagesc(nansmatrix(ngsubindx,:));
colormap(bone);
box off;
xlabel('letters');
ylabel('subjects');
set(gca,'XTick',[1:26],'XTickLabel',letters);
% let's look at the distribution across letters
subplot(1,2,2);
bar(sum(nansmatrix(ngsubindx,:))/length(ngsubindx));;
box off;
xlabel('letters');
ylabel('number of times not matched');
set(gca,'XTick',[1:26],'XTickLabel',letters);
% histogram
% colors come from fp_visualizeEagDB
% histogram
% colors come from fp_visualizeEagDB
makeLetterXColorHist(dbNumbered(find(syntype==0),:));
set(gcf,'Name','no group syns');
% do a histogram of just the labels that don't come from the magnet
% synesthetes
makeLetterXColorHist(dbNumbered(find(syntype~=1),:));
set(gcf,'Name','non magnet syns');
format short g;
% want to slip a table in here too in the command window
disp('no group proportions');
disp(['letter black white red green yellow blue brown purple pink orange grey']);
for i=1:26
[counts, bins]=hist(dbNumbered(find(syntype==0),i),11);
counts = counts/length(find(syntype==0));
disp([letters(i) ' ' num2str(counts,'%0.2f ')]);
end
% want to slip a table in here too in the command window
disp('magnet proportions');
disp(['letter black white red green yellow blue brown purple pink orange grey']);
for i=1:26
[counts, bins]=hist(dbNumbered(find(syntype==2),i),11);
counts = counts/length(find(syntype==2));
disp([letters(i) ' ' num2str(counts,'%0.2f ')]);
end
% want to slip a table in here too in the command window
disp('high fq proportions');
disp(['letter black white red green yellow blue brown purple pink orange grey']);
for i=1:26
[counts, bins]=hist(dbNumbered(find(syntype==1),i),11);
counts = counts/length(find(syntype==1));
disp([letters(i) ' ' num2str(counts,'%0.2f ')]);
end
% correlation of nans among the subgroups
figure('Name','Correlation of non matches to letters across groups','Color',[1 1 1],'Position',get(0,'ScreenSize'));
% values to correlate
fqnans=sum(nansmatrix(fqsubindx,:)/length(fqsubindx));
magnans=sum(nansmatrix(magsubindx,:)/length(magsubindx));
ngnans=sum(nansmatrix(ngsubindx,:)/length(ngsubindx));
subplot(1,3,1);
scatter(fqnans,magnans);
text(fqnans,magnans,letters,'FontSize',14);
hold on;
plot(0:.01:.2,0:.01:.2,'k--');
set(gca,'YLim',[0 .2],'XLim',[0 .2],'YTick',0:.05:.2,'XTick',0:.05:.2);
xlabel('proportion nans in fq group');
ylabel('proportion nans in magnet group');
box off;
axis square;
subplot(1,3,2);
scatter(fqnans,ngnans);
text(fqnans,ngnans,letters,'FontSize',14);
hold on;
plot(0:.01:.2,0:.01:.2,'k--');
set(gca,'YLim',[0 .2],'XLim',[0 .2],'YTick',0:.05:.2,'XTick',0:.05:.2);
xlabel('proportion nans in fq group');
ylabel('proportion nans in non group');
box off;
axis square;
subplot(1,3,3);
scatter(ngnans,magnans);
hold on;
plot(0:.01:.2,0:.01:.2,'k--');
text(ngnans,magnans,letters,'FontSize',14);
set(gca,'YLim',[0 .2],'XLim',[0 .2],'YTick',0:.05:.2,'XTick',0:.05:.2);
xlabel('proportion nans in no group');
ylabel('proportion nans in magnet group');
box off;axis square;
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % do age analysis
load('AgeMatrix.mat');
% loads variable called AgeMatrix
% columns are subjectid batteryid YOB agein2014
% should be able to search through this using USERID which i think
% corresponds to batterid for the subset of our subjects with age data
% userid is the same length as the data so has the same index
for i=1:length(userid)
% see if gc synesthete gave a usable age
indx = find(AgeMatrix(:,2)==userid(i));
% if not then record a nan for age and dob
if isempty(indx)
subage(i) = nan;
subdob(i) = nan;
else
% record 2014 age and dob
subage(i) = AgeMatrix(indx,4);
subdob(i) = AgeMatrix(indx,3);
end
end
% make some figures
% histograms of subjects by year, fq subs by year, and mag subs by year
figure('name','subject date of birth data','Color', [1 1 1],'Position',get(0,'ScreenSize'))
% allsubjects
subplot(1,3,1);
hist(subdob,1930:5:2010);
box off;
ylabel('num subjects');
xlabel('year born');
title('all subjects');
set(gca,'YLim',[0 1800]);
% fq subjects
subplot(1,3,2);
hist(subdob(syntype==1),1930:5:2010)
box off;
ylabel('num subjects');
xlabel('year born');
title('fq subjects');
set(gca,'YLim',[0 1800]);
% magnet subjects
subplot(1,3,3);
hist(subdob(syntype==2),1930:5:2010)
box off;
ylabel('num subjects');
xlabel('year born');
title('magnet subjects');
set(gca,'YLim',[0 1800]);
% analyse the proportion of the database having magnets overtime
magdob = subdob(syntype==2);
notmagdob = subdob(syntype~=2);
fqdob = subdob(syntype==1);
% how many are there?
nummag = sum(~isnan(magdob));
numnotmag = sum(~isnan(notmagdob));
% histogram data in 5 year intervals
bins = 1925:5:2005;
maghist = histc(magdob,bins);
notmaghist = histc(notmagdob,bins);
allhist = histc(subdob,bins);
fqhist = histc(fqdob,bins);
figure('name','prevalance of magnet synesthetes over time','Color',[1 1 1],'Position',get(0,'ScreenSize'));
plot(bins,maghist./allhist,'ro-','MarkerFaceColor',[1 0 0]);
box off;
xlabel('subjects born in 5 years after...');
ylabel('proportion of subjects >=10 matches to magnets');
plot2svg('prevalenceOverTimeFull.svg',gcf,'svg');
% this might look better as a bar chart
figure('name','prevalance of magnet synesthetes over time','Color',[1 1 1],'Position',get(0,'ScreenSize'));
bar(bins,maghist./allhist,1);
box off;
set(gca,'XTick',bins);
xlabel('year subjects with 10 or more matches were born');
ylabel('proportion of subjects >=10 matches to magnets');
plot2svg('prevalenceOverTimeFullBars.svg',gcf,'svg');
figure('name','prevalance of fq and mag synesthetes over time','Color',[1 1 1],'Position',get(0,'ScreenSize'));
plot(bins,maghist./allhist,'ro-','MarkerFaceColor',[1 0 0]);
hold on;
plot(bins,fqhist./allhist,'ko-','MarkerFaceColor',[0 0 0]);
box off;
xlabel('subjects born in 5 years after...');
ylabel('proportion of subjects >=10 matches to magnets');
plot2svg('prevalenceOverFQvsMAG.svg',gcf,'svg');
% suppose we want confidence intervals on the histograms. its weird to say
% that because we only have the one measure, but very different amounts of
% data to work with over the years (very few subjects in their 80s or under
% the age of 10) many in the 30-50 range
% [bins' allhist' fqhist' maghist']
%
% 1925 0 0 0
% 1930 6 0 0
% 1935 8 0 0
% 1940 27 3 0
% 1945 42 6 0
% 1950 71 10 0
% 1955 104 19 0
% 1960 126 8 0
% 1965 186 27 13
% 1970 293 24 41
% 1975 535 76 80
% 1980 981 142 126
% 1985 1460 284 77
% 1990 1632 389 36
% 1995 607 147 8
% 2000 128 23 4
% 2005 14 2 1
% so the algorithm is to randomly sample with replacement from our
% distribution many times and then generate statistics across the bins
% so our subject ages are in subdob
nbstraps = 1000;
fqstraps = [];
mgstraps = [];
% histogram data in 5 year intervals
bins = 1925:5:2005;
% probably doesn't need to be a for loop?
% for each bootstrap
for i=1:nbstraps
% get index to our random sample
rsample = randi(length(subdob),[length(subdob),1]);
% get type of synesthete for sample index
rsampsyntype = syntype(rsample);
% get dobs for sample index
rsampsubdob = subdob(rsample)';
% turn these into binned data for different types of synesthetes
rsampallhist = histc(rsampsubdob,bins);
rsampfqhist = histc(rsampsubdob(rsampsyntype==1),bins);
rsampmaghist = histc(rsampsubdob(rsampsyntype==2),bins);
% now into proportions which we will store
fqstraps(i,:) = rsampfqhist./rsampallhist;
mgstraps(i,:) = rsampmaghist./rsampallhist;
end
% figure with all our bootstraps
figure('Name','All bootstraps of fq and mag','Color',[1 1 1],'Position',get(0,'ScreenSize'));
plot(bins(1:15), fqstraps(:,1:15),'k--');
hold on;
plot(bins(1:15), mgstraps(:,1:15), 'r--');
xlabel('year born');
ylabel('perecent of population');
% figure with shaded 95% confidence intervals
% get intervals
fqci = prctile(fqstraps,[2.5 97.5]);
mgci = prctile(mgstraps,[2.5 97.5]);
% errorbars use differences from mean not actual values
fqmed = nanmedian(fqstraps);%median bootstrapped high frequency syns
fqer(1,:) = abs(fqmed - fqci(1,:));
fqer(2,:) = abs(fqmed + fqci(2,:));
mgmed = nanmedian(mgstraps);%median bootstrapped magnet syns
mger(1,:) = abs(mgmed - mgci(1,:));
mger(2,:) = abs(mgmed + mgci(2,:));
figure('Name','95% ci of bootstraps of fq and mag','Color',[1 1 1],'Position',get(0,'ScreenSize'));
whichbins = [3:15];
errorbar3(bins(whichbins),fqmed(whichbins),fqci(:,whichbins),1,'k');
hold on;
plot(bins(whichbins),fqmed(whichbins),'k');
errorbar3(bins(whichbins),mgmed(whichbins),mgci(:,whichbins),1,'r');
plot(bins(whichbins),mgmed(whichbins),'r');
axis on;
box on;
% grid on;
% another way to do this is to bootstrap the mean or confidence interval within
% each bin
% plot2svg('../PrevalenceOfLearning/JustTheMagnets/psychsci/prevalenceOverFQvsMAGbootstrapped.svg',gcf,'svg');
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % analysis of scores for different groups
LoadColorSequenceScores
% loads a matrix
%<pre>
% This export generated on 2014-03-06
% Fields are: users_id, BatteryId, LCAvgScore, NCAvgScore, GCAvgScore,
% WCAvgScore, MCAvgScore, SCNumCorrect, SCNumIncorrect, SCNumTotal, SCAccuracyPercent, SCMeanRTCorrect, SCMeanRTIncorrect, SCMeanRTTotal
% matrix has a lot of subjects, so once again we want to find ours. this time all of them should be in here somewhere
% 50868 14
% oddly, batteryID again appears to correspond to the variable userid we
% already have
% matrix to hold our behavior
behavior = zeros(6588,14);
for i=1:length(userid)
% find each subject
indx = find(ColorSequenceScores(:,2)==userid(i));
% add their behavior to our matrix
behavior(i,:) = ColorSequenceScores(indx,:);
end
% color matching distance threshold is 1
% median dist for magnet syns
magcdist = median(behavior(find(syntype==2),3));
% 95% confidence interval for magnet syns
% [magcdistci, magcdiststat] = bootci(5000,{@nanmedian,behavior(find(syntype==2),3)});
magcdistci = bootci(5000,{@nanmedian,behavior(find(syntype==2),3)});
% everyone else
notmagcdist = median(behavior(find(syntype~=2),3));
notmagcdistci = bootci(5000,@median,behavior(find(syntype~=2),3));
% everyone
allcdist = median(behavior(:,3));
allcdistci = bootci(5000,@median,behavior(:,3));
% make plot and do a ttest
[hcdist pcdist pci pstats] = ttest2(behavior(find(syntype==2),3),behavior(find(syntype~=2),3))
figure('Name','magnet vs nonmagnet color matching scores','Color',[1 1 1],'Position',get(0,'ScreenSize'));
bar(1:2,[magcdist, notmagcdist]);
hold on;
box off;
% confidence intervals
errorbar2(1:2,[magcdist,notmagcdist],[magcdistci notmagcdistci],1,'k');
set(gca,'XTickLabel',{'magnet syns','rest of pop'});
ylabel('color matching score');
title(['t = ' num2str(pstats.tstat) ', p = ' num2str(pcdist)]);
% speeded classification accuracy
% median acc for magnets accuracy is column ll
magacc=median(behavior(find(syntype==2),11));
magaccci = bootci(5000,@median,behavior(find(syntype==2),11));
% median acc for not magnets
notmagacc=median(behavior(find(syntype~=2),11));
notmagaccci = bootci(5000,@median,behavior(find(syntype~=2),11));
% median acc for everything
allacc = median(behavior(:,11));
allaccci = bootci(5000,@median,behavior(:,11));
% make plot and do a ttest
[hcacc pcacc pci pstats] = ttest2(behavior(find(syntype==2),11),behavior(find(syntype~=2),11))
figure('Name','magnet vs nonmagnet color matching scores','Color',[1 1 1],'Position',get(0,'ScreenSize'));
bar(1:2,[magacc, notmagacc]);
hold on;
box off;
% confidence intervals
errorbar2(1:2,[magacc,notmagacc],[magaccci notmagaccci],1,'k');
set(gca,'XTickLabel',{'magnet syns','rest of pop'});
ylabel('speeded classification accuracy');
title(['t = ' num2str(pstats.tstat) ', p = ' num2str(pcacc)]);
% speeded classification correct rts
% median magnets
magrt=median(behavior(find(syntype==2),12));
% bootstrap 95% ci
magrtci = bootci(5000,@median,behavior(find(syntype==2),12));
% median not magnets
notmagrt=median(behavior(find(syntype~=2),12));
notmagrtci = bootci(5000,@median,behavior(find(syntype~=2),12));
% all subjects
allcrt=median(behavior(:,12));
allcrtci = bootci(5000,@median,behavior(:,12));
% make plot and do a ttest
[hcrt pcrt pci pstats] = ttest2(behavior(find(syntype==2),12),behavior(find(syntype~=2),12))
figure('Name','magnet vs nonmagnet color matching scores','Color',[1 1 1],'Position',get(0,'ScreenSize'));
bar(1:2,[magrt, notmagrt]);
hold on;
box off;
% confidence intervals
errorbar2(1:2,[magrt,notmagrt],[magrtci notmagrtci],1,'k');