forked from Foztarz/compound-eye-plotting-elife
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlottingCodeForBeeCE.m
3356 lines (2968 loc) · 138 KB
/
PlottingCodeForBeeCE.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
%Written by Gavin Taylor, 2017. MIT License
%%%This file calcualtes and saves plots to describe compound eye vision
%%%calcuated by volumetric analysis, as descrbied in Taylor et al. 2019
%%%% Settings %%%%
%set parameters here before running the script
clear; clc; close all
cd('Add here'); %folder with data file - modfy as needed
sDat = load('DataForPlots.mat'); %file to plot from
toPlotMaps = [1 3]; %indices of specific bees to plot maps for
saveAllThePlots = 0; %set to save all plots to the folder below
saveFolder = 'C:\SaveDirectory'; %folder to save to
numHistBins = 20; %number of bins in histograms (will be num+1)
scaleEyeVols = 1; %will convert eye volumes to um and take cube root
imageConvRes = 1; %resolution of plotted maps in degrees
angStep = 10; %resolution of plotted profiles in degrees
remIrregularSpatialBands = 1;
regressionGroups = {{'AM'},{'BT'}}; %set species groups for performing regression
groupNames = {'Apis','Bombus'}; %set names to plot for species groups
groupLineStyles = {'-','-.'}; %set line type for plotting species groups
groupMarkerStyles = {'o','s'}; %set marker type for plotting species groups
volCols = cool(100); %set color for plotting volumes
plotBinoBorderOnMap = 1; %plot border of binocular field of color maps
plotFOVBorderOnMap = 1; %plot border of FOV on color maps
%parameters for plotting colour maps
t100 = 0:1/101:1;
minRangeIO = 1/180*pi; %set min IO on scale
maxRangeIO = 3/180*pi; %set max IO on scale
IOColMap = flipud([t100'*255 t100'*51 t100'*51]/255); %color map to use
minRangeD = 16; %set min diameter on scale
maxRangeD = 28; %set max diameter on scale
DColMap = [t100'*51 t100'*153 t100'*255]/255;
minRangeRL = 50; %set min retina thickness on scale
maxRangeRL = 350; %set max retina thickness on scale
RLColMap = [t100'*153 t100'*255 t100'*51]/255;
minRangeEyePara = 0.3; %set min P on scale
maxRangeEyePara = 1.5; %set max P on scale
EyeParaColMap = [t100'*255 t100'*153 t100'*51]/255;
minRangeLensT = 20; %set min Lens thickness on scale
maxRangeLensT = 70; %set max lens thickness on scale
LensTColMap = [t100'*51 t100'*255 t100'*255]/255;
minRangeCCT = 25; %set min CC thickness on scale
maxRangeCCT = 75; %set max CC thickness on scale
CCTColMap = [t100'*255 t100'*151 t100'*53]/255;
minRangeCurv = 200; %set min curvature on scale
maxRangeCurv = 1400; %set max curvature on scale
CurvColMap = [t100'*192 t100'*192 t100'*192]/255;
maxRangeScale = 3; %set min scaling coeff on scale
minRangeScale = -1; %set max scaling coeff on scale
ScaleColMap = jet(100);
ScaleColMap(1:25,:) = [];
%%% Note: Other colors and plotting parameters are set in main code
%% end settings, start plotting code
numBees = size(sDat.fullBeeData,2);
if saveAllThePlots
cd(saveFolder);
end
eyeVols = [sDat.fullBeeData.EyeVolume];
if scaleEyeVols
eyeVols = (eyeVols/10^9).^(1/3);
end
volRng = [min(eyeVols) max(eyeVols)];
regGroup = zeros(numBees,1);
%save min and max for histograms
IORange = zeros(numBees,2);
DRange = zeros(numBees,2);
LensLRange = zeros(numBees,2);
CCLRange = zeros(numBees,2);
RetLRange = zeros(numBees,2);
SensRange = zeros(numBees,2);
DensityRange = zeros(numBees,2);
ProjARange = zeros(numBees,2);
%get ranges and single values first
for i = 1:numBees
IORange(i,:) = [min(sDat.fullBeeData(i).calInterO) max(sDat.fullBeeData(i).calInterO)];
DRange(i,:) = [min(sDat.fullBeeData(i).avgDiameter) max(sDat.fullBeeData(i).avgDiameter)];
LensLRange(i,:) = [min(sDat.fullBeeData(i).lensThickness) max(sDat.fullBeeData(i).lensThickness)];
CCLRange(i,:) = [min(sDat.fullBeeData(i).CCThickness) max(sDat.fullBeeData(i).CCThickness)];
RetLRange(i,:) = [min(sDat.fullBeeData(i).RetThickness) max(sDat.fullBeeData(i).RetThickness)];
SensRange(i,:) = [min(sDat.fullBeeData(i).sensitvityApproximation) max(sDat.fullBeeData(i).sensitvityApproximation)];
DensityRange(i,:) = [min(sDat.fullBeeData(i).AxisDensityOnSphere) max(sDat.fullBeeData(i).AxisDensityOnSphere)];
%get what group this bee belongs to
for j = 1:length(regressionGroups)
tempGroup = regressionGroups{j};
for k = 1:length(tempGroup)
if strcmp(sDat.fullBeeData(i).BeeSpecies, tempGroup{k})
regGroup(i) = j;
end
end
end
end
%get approx area per point on sphere
stPPoint = 4*pi/size(sDat.refSphere.X,1);
% resample into facet reference frame - req for histograms and means
facetWeightInds = cell(numBees,1);
projWeightInds = cell(numBees,1);
for i = 1:numBees
facetWeightInds{i} = sDat.fullBeeData(i).NumFacets./sDat.fullBeeData(i).interpFacetArea./sum(1./sDat.fullBeeData(i).interpFacetArea);
projWeightInds{i} = sDat.fullBeeData(i).AxisDensityOnSphere*stPPoint;
end
%% summary plots
% plot of itw vs. vol and surface area
volAllomF = figure;
yyaxis left; hold on
areaCol = [0 0 0]/255;
legPoints = [0,0];
for i = 1:length(regressionGroups)
tempX = [sDat.fullBeeData(regGroup == i).ITW];
tempY = ([sDat.fullBeeData(regGroup == i).lensSurfaceArea]/10^6).^(1/2);
legPoints(i) = plot(tempX, tempY, groupMarkerStyles{i}, 'color', areaCol,'markersize',10,'markerfacecolor','w');
end
ylim([0 3]);
ylabel('Eye Area^0^.^5 (mm)');
set(gca, 'YTick', [0 1 2 3]);
set(gca,'ycolor',areaCol)
%do fit on last one, it is bombus group
%log transform fits log(y) = log(a)+b*log(y)
fitArea = polyfit(log10(tempX),log10(tempY),1);
fitArea(2) = 10.^fitArea(2);
plotX = min(tempX):0.001:max(tempX);
legLine1 = plot(plotX, fitArea(2)*plotX.^fitArea(1),'color',areaCol,'linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(3, 1,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitArea(2),fitArea(1), R(2)^2, P(2)),'color', areaCol, 'Interpreter', 'none')
uistack(legLine1,'down');
yyaxis right; hold on
volCol = [51 153 255]/255;
for i = 1:length(regressionGroups)
tempX = [sDat.fullBeeData(regGroup == i).ITW];
tempY = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3); % retinaVolume
hl = plot(tempX,tempY, groupMarkerStyles{i}, 'color', volCol,'markerfacecolor','w','markersize',10);
end
ylabel('Eye Volume^0^.^3 (mm)'); xlabel('ITW (mm)');
fitVol = polyfit(log10(tempX),log10(tempY),1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLine2 = plot(plotX, fitVol(2)*plotX.^fitVol(1),'color',volCol, 'linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(1.5, 0.8,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', volCol, 'Interpreter', 'none')
%uistack does not work on second y axis...
delete(hl)
plot(tempX,tempY, groupMarkerStyles{i}, 'color', volCol,'markerfacecolor','w','markersize',10)
legend([legPoints], {groupNames{1}, groupNames{2}},'Location','SouthWest');
ylabel('Volume^0^.^3 (mm)');
xlim([1 7]); ylim([0 1]);
set(gca, 'YTick', [0 0.25 0.5 0.75 1]);
set(gca,'XTick',[1 3 5 7],'TickDir','out');
set(gca,'ycolor',volCol)
set(gcf, 'Position', [50 50 500*1.04 500/1.61]);
% plot of vol vs facets
facetAllomF = figure; hold on
facetCol = [0 0 0]/255;
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
tempY = ([sDat.fullBeeData(regGroup == i).NumFacets]);
plot(tempX,tempY, groupMarkerStyles{i}, 'color', facetCol,'markerfacecolor','w','markersize',10);
end
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('# Facets');
fitVol = polyfit(log10(tempX),log10(tempY),1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLine = plot(plotX, fitVol(2)*plotX.^fitVol(1),'color',facetCol, 'linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.6,3000,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', facetCol, 'Interpreter', 'none')
uistack(legLine,'down');
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1)';
for j = 1:length(inds)
[~,binoRefInds] = intersect(sDat.fullBeeData(inds(j)).inFOV, sDat.fullBeeData(inds(j)).inFOVBino);
tempY(j) = sum(sDat.fullBeeData(inds(j)).AxisDensityOnSphere(binoRefInds)*stPPoint);
end
plot(tempX,tempY, groupMarkerStyles{i}, 'color', facetCol,'markerfacecolor','w','markersize',10);
end
% legend(groupNames);
xlim([0.5 0.9]); ylim([0 8000]);
set(gca, 'YTick', [0 2000 4000 6000 8000]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
set(gcf, 'Position', [50 50 500 500/1.61]);
% plot sensitivty
sensAllomF = figure; hold on
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1)';
for j = 1:length(inds)
tempY(j) = wmean(sDat.fullBeeData(inds(j)).sensitvityApproximation,facetWeightInds{inds(j)});
end
legs3 = plot(tempX,tempY, groupMarkerStyles{i}, 'color', facetCol,'markerfacecolor','w','markersize',10);
end
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('Sensitvity (um.str)');
% legend(groupNames);
xlim([0.5 0.9]); ylim([0 0.2]);
set(gca, 'YTick', [0 0.05 0.1 0.15 0.2]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
set(gcf, 'Position', [50 50 500 500/1.61]);
% plot for area/fov ratio and eye paramter for comp
fovRatioAndEyeP = figure;
yyaxis left; hold on
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('Eye proportion (um/rad)');
ylim([0 1200]);
set(gca, 'YTick', [0 400 800 1200]);
facetCol = [0 0 0];
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1)';
for j = 1:length(inds)
tempY(j) = 1./wmean((sDat.fullBeeData(inds(j)).projectedAngle).^0.5,facetWeightInds{inds(j)});
end
legs2 = plot(tempX,tempY, groupMarkerStyles{i}, 'color', facetCol,'markerfacecolor','w','markersize',10);
end
fitVol = polyfit(log10(tempX),log10(tempY),1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLine = plot(plotX, fitVol(2)*plotX.^fitVol(1),'color',facetCol, 'linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.55,1100,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', facetCol, 'Interpreter', 'none')
uistack(legLine,'down');
set(gca,'ycolor','k')
facetCol = [102 102 255]/255;
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
tempY = (([sDat.fullBeeData(regGroup == i).lensSurfaceArea])./(([sDat.fullBeeData(regGroup == i).fovFilledFromIntegral]*4*pi))).^0.5;
legs1 = plot(tempX,tempY, groupMarkerStyles{i}, 'color', facetCol,'markerfacecolor',facetCol,'markersize',8);
end
yyaxis right; hold on
facetCol = [255 153 51]/255;
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1)';
for j = 1:length(inds)
tempY(j) = wmean(sDat.fullBeeData(inds(j)).calInterO.*sDat.fullBeeData(inds(j)).avgDiameter,facetWeightInds{inds(j)});
end
legs3 = plot(tempX,tempY, groupMarkerStyles{i}, 'color', facetCol,'markerfacecolor','w','markersize',10);
end
ylabel('Eye parameter (um.rad)');
ylim([0 1]);
set(gca, 'YTick', [0 0.25 0.5 0.75 1]);
fitVol = polyfit(log10(tempX),log10(tempY),1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLine = plot(plotX, fitVol(2)*plotX.^fitVol(1),'color',facetCol, 'linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.65,0.5,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', facetCol, 'Interpreter', 'none')
delete(hl)
plot(tempX,tempY, groupMarkerStyles{i}, 'color', facetCol,'markerfacecolor','w','markersize',10);
legend([legs2, legs1, legs3], {'Global eye ratio','Average eye ratio','Eye parameter'},'Location','SouthWest');
xlim([0.5 0.9]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
set(gca,'ycolor',facetCol)
set(gcf, 'Position', [50 50 500 500/1.61]);
%plot for combined and binocular fov
fovAllomF = figure;
yyaxis left; hold on
monFOVCol = [102 102 255]/255;
legPoints = [0,0];
%%%fov is in square radians, but should not need to normalize with sqrt?
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
tempY = (([sDat.fullBeeData(regGroup == i).fovFilledFromIntegral])*4*pi);
legPoints(i) = plot(tempX, tempY, groupMarkerStyles{i}, 'color', monFOVCol,'markerfacecolor','w','markersize',10);
end
fitArea = polyfit(log10(tempX),log10(tempY),1);
fitArea(2) = 10.^fitArea(2);
plotX = min(tempX):0.001:max(tempX);
legLines1 = plot(plotX, fitArea(2)*plotX.^fitArea(1),'-','color',monFOVCol,'linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.51,4,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitArea(2),fitArea(1), R(2)^2, P(2)),'color', monFOVCol, 'Interpreter', 'none')
uistack(legLines1,'down');
set(gca,'ycolor',[0 0 0]);
BinoFOVCol = [102 255 102]/255;
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1)';
for j = 1:length(inds)
tempY(j) = (length(sDat.fullBeeData(inds(j)).inFOVBino)./size(sDat.refSphere.X,1)*4*pi);
end
plot(tempX, tempY, groupMarkerStyles{i}, 'color', BinoFOVCol,'markerfacecolor','w','markersize',10);
end
fitArea = polyfit(log10(tempX),log10(tempY),1);
fitArea(2) = 10.^fitArea(2);
plotX = min(tempX):0.001:max(tempX);
legLines2 = plot(plotX, fitArea(2)*plotX.^fitArea(1),'-','color',BinoFOVCol,'linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.51,1.5,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitArea(2),fitArea(1), R(2)^2, P(2)),'color', BinoFOVCol, 'Interpreter', 'none')
uistack(legLines2,'down');
CompFOVCol = [255 102 102]/255;
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1)';
for j = 1:length(inds)
tempY(j) = (length(unique([sDat.fullBeeData(inds(j)).inFOV' sDat.fullBeeData(inds(j)).inFOVRight']))./size(sDat.refSphere.X,1)*4*pi);
end
plot(tempX,tempY, groupMarkerStyles{i}, 'color', CompFOVCol,'markerfacecolor','w','markersize',10);
end
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('Corneal FOV (str)');
fitVol = polyfit(log10(tempX),log10(tempY),1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLines3 = plot(plotX, fitVol(2)*plotX.^fitVol(1),'-','color',CompFOVCol,'linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.51,6.5,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', CompFOVCol, 'Interpreter', 'none')
uistack(legLines3,'down');
legend([legPoints, legLines3, legLines1, legLines2], {groupNames{1}, groupNames{2}, 'Complete', 'Monocular', 'Binocular'});
xlim([0.5 0.9]); ylim([0 7]);
set(gca, 'YTick', [0 1 2 3 4 5 6 7]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9 1],'TickDir','out');
yyaxis right; hold on;
ylim([0 7]/(4*pi)*100);
set(gca, 'YTick', [0 0.1 0.2 0.3 0.4 0.5]*100);
set(gca,'ycolor',[0 0 0]);
ylabel('% of total visual field');
set(gcf, 'Position', [50 50 500*1.02 500/1.61*2*1.06]);
%% plot indvidual of means and violin hists
%for IO
IOHistsF = figure; hold on
smthL = 3; %smooth histogram over this num of bins
HistBins = 0:0.1:5;
flipChange = [0 0 1 0 0 0 0 0]; %bit of a fudge, indicate which to flip if needed
histCol = [0.5 0.5 0.5];
%histograms are scalled up to hist width, such that hist cal would equal hist width
histW = 0.018;
histCal = 0.1;
labels = zeros(length(regressionGroups),1);
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1);
tempY2 = sqrt(23818./[sDat.fullBeeData(regGroup == i).NumFacets]);
tempY3 = sqrt([sDat.fullBeeData(regGroup == i).fovFilledFromIntegral]*4*pi./[sDat.fullBeeData(regGroup == i).NumFacets])/pi*180;
tempY4 = zeros(length(inds),1);
for j = 1:length(inds)
tempY(j) = wmean(sDat.fullBeeData(inds(j)).calInterO,facetWeightInds{inds(j)})/pi*180;
tempY4(j) = max(sDat.fullBeeData(inds(j)).calInterO)/pi*180;
[n,x] = histwc(sDat.fullBeeData(inds(j)).calInterO/pi*180,facetWeightInds{inds(j)},HistBins);
relN = smooth(n/sum(n),smthL);
%adjust for diff between max n range and intended cal
xAdj = (max(relN)/histCal);
if ~flipChange(inds(j))
dirToP = 'left';
histWToUse = histW*xAdj;
xToP = tempX(j)-histWToUse/2;
else
dirToP = 'right';
histWToUse = histW*xAdj;
xToP = tempX(j)+histWToUse/2;
end
%note, most options for calculaiton don't seem to work well with weighted histogram?
distributionPlot({[x',relN]}, 'xValues', xToP,'distWidth', histWToUse, 'showMM',0,'histOri',dirToP,'globalNorm',3,'color',histCol)
end
labels(i) = plot(tempX, tempY, groupMarkerStyles{i}, 'color', 'k', 'markersize',10,'markerfacecolor','w');
label2 = plot(tempX, tempY2, groupMarkerStyles{i}, 'color', [204 102 0]/255, 'markersize',5,'markerfacecolor',[204 102 0]/255);
label3 = plot(tempX, tempY3, groupMarkerStyles{i}, 'color', [102 102 255]/255, 'markersize',5,'markerfacecolor',[102 102 255]/255);
end
fitVol = polyfit(log10(tempX),log10(tempY)',1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLines3 = plot(plotX, fitVol(2)*plotX.^fitVol(1),'-','color','k','linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.51,3.5,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', 'k', 'Interpreter', 'none')
uistack(legLines3,'down',3); %get behind other three markers
xlim([0.5 0.9]); ylim([0 4]);
set(gca, 'YTick', [0 1 2 3 4]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('Corneal interommatidial angle (^o)');
legend([labels(1) labels(2) label2 label3], {groupNames{1}, groupNames{2},'HemiApprox','FOVApprox'});
% title('Magenta are from hemisphere div num eqn - blue are from fov div');
set(gcf, 'Position', [50 50 500 500/1.61]);
% plot summary for facet d
DiamHistsF = figure; hold on
HistBins = 0:0.25:30;
labels = zeros(length(regressionGroups),1);
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1);
tempY2 = zeros(length(inds),1);
for j = 1:length(inds)
tempY(j) = wmean(sDat.fullBeeData(inds(j)).avgDiameter,facetWeightInds{inds(j)});
tempY2(j) = max(sDat.fullBeeData(inds(j)).avgDiameter);
[n,x] = histwc(sDat.fullBeeData(inds(j)).avgDiameter,facetWeightInds{inds(j)},HistBins);
relN = smooth(n/sum(n),smthL);
%adjust for diff between max n range and intended cal
xAdj = (max(relN)/histCal);
if ~flipChange(inds(j))
dirToP = 'left';
histWToUse = histW*xAdj;
xToP = tempX(j)-histWToUse/2;
else
dirToP = 'right';
histWToUse = histW*xAdj;
xToP = tempX(j)+histWToUse/2;
end
distributionPlot({[x',relN]}, 'xValues', xToP,'distWidth', histWToUse, 'showMM',0,'histOri',dirToP,'globalNorm',3,'color',histCol)
end
labels(i) = plot(tempX, tempY, groupMarkerStyles{i}, 'color', 'k', 'markersize',10,'markerfacecolor','w');
end
fitVol = polyfit(log10(tempX),log10(tempY)',1);
fitVol(2) = 10.^fitVol(2);
fitVol2 = polyfit(log10(tempX),log10(tempY2)',1);
fitVol2(2) = 10.^fitVol2(2);
plotX = min(tempX):0.001:max(tempX);
legLines3 = plot(plotX, (fitVol(2)*plotX.^fitVol(1)),'-','color','k','linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.6,10,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', 'k','Interpreter', 'none')
uistack(legLines3,'down');
xlim([0.5 0.9]); ylim([0 30]);
set(gca, 'YTick', [0 10 20 30]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('Facet diameter (um)');
legend(labels, groupNames,'Location','South');
set(gcf, 'Position', [50 50 500 500/1.61 ]);
% plot summary for rhabdoms thickness
RhabdomsHistsF = figure; hold on
HistBins = 0:5:500;
labels = zeros(length(regressionGroups),1);
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1);
for j = 1:length(inds)
tempY(j) = wmean(sDat.fullBeeData(inds(j)).RetThickness,facetWeightInds{inds(j)});
[n,x] = histwc(sDat.fullBeeData(inds(j)).RetThickness,facetWeightInds{inds(j)},HistBins);
relN = smooth(n/sum(n),smthL);
%adjust for diff between max n range and intended cal
xAdj = (max(relN)/histCal);
if ~flipChange(inds(j))
dirToP = 'left';
histWToUse = histW*xAdj;
xToP = tempX(j)-histWToUse/2;
else
dirToP = 'right';
histWToUse = histW*xAdj;
xToP = tempX(j)+histWToUse/2;
end
distributionPlot({[x',relN]}, 'xValues', xToP,'distWidth', histWToUse, 'showMM',0,'histOri',dirToP,'globalNorm',3,'color',histCol)
end
labels(i) = plot(tempX, tempY, groupMarkerStyles{i}, 'color', 'k', 'markersize',10,'markerfacecolor','w');
end
fitVol = polyfit(log10(tempX),log10(tempY)',1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLines3 = plot(plotX, (fitVol(2)*plotX.^fitVol(1)),'-','color','k','linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.6,350,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', 'k','Interpreter', 'none')
uistack(legLines3,'down');
xlim([0.5 0.9]); ylim([0 500]);
set(gca, 'YTick', [0 100 200 300 400 500]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('Retina Thickness (um)');
legend(labels, groupNames,'Location','NorthWest');
set(gcf, 'Position', [50 50 500 500/1.61 ]);
% plot summary for cornea thickness
corneaHistF = figure; hold on
HistBins = 0:1:100;
labels = zeros(length(regressionGroups),1);
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1);
for j = 1:length(inds)
tempY(j) = wmean(sDat.fullBeeData(inds(j)).lensThickness,facetWeightInds{inds(j)});
[n,x] = histwc(sDat.fullBeeData(inds(j)).lensThickness,facetWeightInds{inds(j)},HistBins);
relN = smooth(n/sum(n),smthL);
%adjust for diff between max n range and intended cal
xAdj = (max(relN)/histCal);
if ~flipChange(inds(j))
dirToP = 'left';
histWToUse = histW*xAdj;
xToP = tempX(j)-histWToUse/2;
else
dirToP = 'right';
histWToUse = histW*xAdj;
xToP = tempX(j)+histWToUse/2;
end
distributionPlot({[x',relN]}, 'xValues', xToP,'distWidth', histWToUse, 'showMM',0,'histOri',dirToP,'globalNorm',3,'color',histCol)
end
labels(i) = plot(tempX, tempY, groupMarkerStyles{i}, 'color', 'k', 'markersize',10,'markerfacecolor','w');
end
fitVol = polyfit(log10(tempX),log10(tempY)',1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLines3 = plot(plotX, (fitVol(2)*plotX.^fitVol(1)),'-','color','k','linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.51,90,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', 'k','Interpreter', 'none')
uistack(legLines3,'down');
xlim([0.5 0.9]); ylim([0 100]);
set(gca, 'YTick', [0 25 50 75 100]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('Lens Thickness (um)');
legend(labels, groupNames);
set(gcf, 'Position', [50 50 500 500/1.61 ]);
% plot summary for CC thickness
CCHistF = figure; hold on
HistBins = 0:1:100;
labels = zeros(length(regressionGroups),1);
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1);
for j = 1:length(inds)
tempY(j) = wmean(sDat.fullBeeData(inds(j)).CCThickness,facetWeightInds{inds(j)});
[n,x] = histwc(sDat.fullBeeData(inds(j)).CCThickness,facetWeightInds{inds(j)},HistBins);
relN = smooth(n/sum(n),smthL);
%adjust for diff between max n range and intended cal
xAdj = (max(relN)/histCal);
if ~flipChange(inds(j))
dirToP = 'left';
histWToUse = histW*xAdj;
xToP = tempX(j)-histWToUse/2;
else
dirToP = 'right';
histWToUse = histW*xAdj;
xToP = tempX(j)+histWToUse/2;
end
distributionPlot({[x',relN]}, 'xValues', xToP,'distWidth', histWToUse, 'showMM',0,'histOri',dirToP,'globalNorm',3,'color',histCol)
end
labels(i) = plot(tempX, tempY, groupMarkerStyles{i}, 'color', 'k', 'markersize',10,'markerfacecolor','w');
end
fitVol = polyfit(log10(tempX),log10(tempY)',1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLines3 = plot(plotX, (fitVol(2)*plotX.^fitVol(1)),'-','color','k','linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.51,90,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', 'k','Interpreter', 'none')
uistack(legLines3,'down');
xlim([0.5 0.9]); ylim([0 100]);
set(gca, 'YTick', [0 25 50 75 100]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('CC Thickness (um)');
legend(labels, groupNames);
set(gcf, 'Position', [50 50 500 500/1.61 ]);
% plot summary for curvature
curvHistF = figure; hold on
HistBins = 0:40:2000;
labels = zeros(length(regressionGroups),1);
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1);
for j = 1:length(inds)
tempY(j) = wmean(sDat.fullBeeData(inds(j)).avgRadius,facetWeightInds{inds(j)});
[n,x] = histwc(sDat.fullBeeData(inds(j)).avgRadius,facetWeightInds{inds(j)},HistBins);
relN = smooth(n/sum(n),smthL);
%adjust for diff between max n range and intended cal
xAdj = (max(relN)/histCal);
if ~flipChange(inds(j))
dirToP = 'left';
histWToUse = histW*xAdj;
xToP = tempX(j)-histWToUse/2;
else
dirToP = 'right';
histWToUse = histW*xAdj;
xToP = tempX(j)+histWToUse/2;
end
distributionPlot({[x',relN]}, 'xValues', xToP,'distWidth', histWToUse, 'showMM',0,'histOri',dirToP,'globalNorm',3,'color',histCol)
end
labels(i) = plot(tempX, tempY, groupMarkerStyles{i}, 'color', 'k', 'markersize',10,'markerfacecolor','w');
end
fitVol = polyfit(log10(tempX),log10(tempY)',1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLines3 = plot(plotX, (fitVol(2)*plotX.^fitVol(1)),'-','color','k','linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.51,1700,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', 'k','Interpreter', 'none')
uistack(legLines3,'down');
xlim([0.5 0.9]); ylim([0 2000]);
set(gca, 'YTick', [0 500 1000 1500 2000]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('Curvature (um)');
legend(labels, groupNames);
set(gcf, 'Position', [50 50 500 500/1.61 ]);
% plot summary for eye parameter
eyeParamHistF = figure; hold on
HistBins = 0:0.025:2;
labels = zeros(length(regressionGroups),1);
for i = 1:length(regressionGroups)
tempX = ([sDat.fullBeeData(regGroup == i).EyeVolume]/10^9).^(1/3);
inds = find(regGroup == i);
tempY = zeros(length(inds),1);
for j = 1:length(inds)
tempY(j) = wmean(sDat.fullBeeData(inds(j)).calInterO.*sDat.fullBeeData(inds(j)).avgDiameter,facetWeightInds{inds(j)});
[n,x] = histwc(sDat.fullBeeData(inds(j)).calInterO.*sDat.fullBeeData(inds(j)).avgDiameter,facetWeightInds{inds(j)},HistBins);
relN = smooth(n/sum(n),smthL);
%adjust for diff between max n range and intended cal
xAdj = (max(relN)/histCal);
if ~flipChange(inds(j))
dirToP = 'left';
histWToUse = histW*xAdj;
xToP = tempX(j)-histWToUse/2;
else
dirToP = 'right';
histWToUse = histW*xAdj;
xToP = tempX(j)+histWToUse/2;
end
distributionPlot({[x',relN]}, 'xValues', xToP,'distWidth', histWToUse, 'showMM',0,'histOri',dirToP,'globalNorm',3,'color',histCol)
end
labels(i) = plot(tempX, tempY, groupMarkerStyles{i}, 'color', 'k', 'markersize',10,'markerfacecolor','w');
end
fitVol = polyfit(log10(tempX),log10(tempY)',1);
fitVol(2) = 10.^fitVol(2);
plotX = min(tempX):0.001:max(tempX);
legLines3 = plot(plotX, (fitVol(2)*plotX.^fitVol(1)),'-','color','k','linewidth',2);
[R,P] = corrcoef(log10(tempX),log10(tempY));
text(0.51,1.75,sprintf('Y=%.2fX^%.2f R^2=%.2f, p=%.3f',fitVol(2),fitVol(1), R(2)^2, P(2)),'color', 'k','Interpreter', 'none')
uistack(legLines3,'down');
xlim([0.5 0.9]); ylim([0 2]);
set(gca, 'YTick', [0 0.5 1 1.5 2]);
set(gca,'XTick',[0.5 0.6 0.7 0.8 0.9],'TickDir','out');
xlabel('Eye Volume^0^.^3 (mm)'); ylabel('Eye parameter (um.rad)');
legend(labels, groupNames);
set(gcf, 'Position', [50 50 500 500/1.61 ]);
%% map fov onto sphere and then onto projections
% make world plots on sphere showing borders of fov for mono, bino and full, and integrate across visual space.
smoothRngFOV = 3;
%map original sphere to az and el - generic
sphereEls = acos(sDat.refSphere.X(:,2))/pi*180-90;
sphereAzs = -atan2(sDat.refSphere.X(:,1),-sDat.refSphere.X(:,3))/pi*180; %note that this is negated to get correct az in image
topInd = find(sphereEls == 90);
azBins = -180:angStep:180;
elBins = -90:angStep:90;
azSumT = zeros(length(azBins)-1,1);
elSumT = zeros(length(elBins)-1,1);
for j = 1:length(azBins)-1
azSumT(j) = length(find(sphereAzs > azBins(j) & sphereAzs <= azBins(j+1)));
end
for j = 1:length(elBins)-1
elSumT(j) = length(find(sphereEls > elBins(j) & sphereEls <= elBins(j+1)));
end
% plot full fov on sphere
worldSphereF = figure;
set(gcf, 'Position', [50 50 850 850]);
hold on; axis off
patch('Faces',sDat.refSphere.Triangulation,'Vertices',sDat.refSphere.X,'FaceAlpha',0.8,'EdgeAlpha',0,'FaceColor',[0.95 0.95 0.95]);
view([0, -90]); axis equal
set(gcf,'color','w');
for i = [-180 -150 -120 -90 -30 -60 0 30 60 90 120 150 180]
azs = i*ones(1,361);
els = -180:180;
if i == 180 | i == 0
lw = 3;
else
lw = 1.5;
end
plot3( sin(els/180*pi).*sin(azs/180*pi), cos(els/180*pi),sin(els/180*pi).*cos(azs/180*pi) , '-','color', [0.75 0.75 0.75],'linewidth',lw)
end
for i = [-90 -60 -30 0 30 60 90]
azs = -180:180;
els = i*ones(1,361);
if i == 0
lw = 4;
else
lw =1.5;
end
plot3( sin(els/180*pi).*sin(azs/180*pi),cos(els/180*pi),sin(els/180*pi).*cos(azs/180*pi), '-','color', [0.75 0.75 0.75],'linewidth',lw)
%do second half of hemisphere
if i < 0
els = (i-90)*ones(1,361);
else
els = (i+90)*ones(1,361);
end
plot3( sin(els/180*pi).*sin(azs/180*pi),cos(els/180*pi),sin(els/180*pi).*cos(azs/180*pi),'-', 'color', [0.75 0.75 0.75],'linewidth',lw)
end
for i = 1:8
if regGroup(i) == 1
beeCol = 'k';
else
beeCol = volCols(round((eyeVols(i)-volRng(1))./(volRng(2)-volRng(1))*(size(volCols,1)-1))+1,:);
end
%remove last ind (the closing one) before smooth then add after, otherwise smooth opens it up again
tempSubs = [circularSmooth(sDat.fullBeeData(i).inFOVBorderSubs(1:end-1,1)',smoothRngFOV), circularSmooth(sDat.fullBeeData(i).inFOVBorderSubs(1:end-1,2)',smoothRngFOV), circularSmooth(sDat.fullBeeData(i).inFOVBorderSubs(1:end-1,3)',smoothRngFOV)];
tempSubs = vertcat(tempSubs,tempSubs(1,:));
plot3(tempSubs(:,1), tempSubs(:,2), tempSubs(:,3),'-','color',beeCol','linewidth',4);
end
%plot full FOV on proj
projFullFov = figure;
hold on; xlim([-180 180]); ylim([-90 90]);
xlabel('Azimuth (^o)');
ylabel('Elevation (^o)');
set(gcf, 'Position', [50 50 1000 500]); axis off
set(gca, 'YTick', [],'XTick',[]);
for i = [-180 -150 -120 -90 -30 -60 0 30 60 90 120 150 180]
plot((i*ones(1,181)).*cos((-90:90)/180*pi), -90:90, '-','color', [0.75 0.75 0.75],'linewidth',1.5)
end
for i = [-90 -60 -30 0 30 60 90]
plot((-180:180)*cos(i/180*pi), i*ones(361,1), '-','color', [0.75 0.75 0.75],'linewidth',1.5)
end
%add some labels to the meridians
for i = [-180 -120 -60 0 60 120 180]
text(i,0,sprintf('%i^o',i));
end
for i = [-90 -60 -30 30 60 90]
text(-180*cos(i/180*pi),i,sprintf('%i^o',i));
end
for i = 1:8
if regGroup(i) == 1
beeCol = 'k';
else
beeCol = volCols(round((eyeVols(i)-volRng(1))./(volRng(2)-volRng(1))*(size(volCols,1)-1))+1,:);
end
tempSubs = [circularSmooth(sDat.fullBeeData(i).inFOVBorderSubs(1:end-1,1)',smoothRngFOV), circularSmooth(sDat.fullBeeData(i).inFOVBorderSubs(1:end-1,2)',smoothRngFOV), circularSmooth(sDat.fullBeeData(i).inFOVBorderSubs(1:end-1,3)',smoothRngFOV)];
tempSubs = vertcat(tempSubs,tempSubs(1,:));
lineEls = acos(tempSubs(:,2))/pi*180-90;
lineAzs = -atan2(tempSubs(:,1),-tempSubs(:,3))/pi*180;
%check if line crosses top of pole and insert 90o point if so
if sum(sDat.fullBeeData(i).inFOV == topInd)
%if so find point on left of linkage
tempInds = find(lineAzs < 0);
[~,leftLink] = max(lineEls(tempInds));
leftLink = tempInds(leftLink);
%and then on right
tempInds = find(lineAzs >= 0);
[~,rightLink] = max(lineEls(tempInds));
rightLink = tempInds(rightLink);
if rightLink > leftLink
lineEls = [lineEls(1:leftLink)' 90 lineEls(rightLink:end)'];
lineAzs = [lineAzs(1:leftLink)' 0 lineAzs(rightLink:end)'];
else
lineEls = [lineEls(1:rightLink)' 90 lineEls(leftLink:end)'];
lineAzs = [lineAzs(1:rightLink)' 0 lineAzs(leftLink:end)'];
end
end
plot(lineAzs.*cos(lineEls/180*pi),lineEls,'-','color',beeCol','linewidth',2);
end
minDst = 0;
for i = round(1:size(sDat.refSphere.X,1)/50:size(sDat.refSphere.X,1));
toTest = 1:size(sDat.refSphere.X,1); toTest(i) = [];
minDst = minDst + min(sqrt((sDat.refSphere.X(i,1) - sDat.refSphere.X(toTest,1)).^2 + (sDat.refSphere.X(i,2) - sDat.refSphere.X(toTest,2)).^2 + (sDat.refSphere.X(i,3) - sDat.refSphere.X(toTest,3)).^2));
end
minDst = minDst/length(1:100:size(sDat.refSphere.X,1));
% plot bincular FOV on projection
projBinoFOV = figure;
hold on; xlim([-180 180]); ylim([-90 90]);
xlabel('Azimuth (^o)');
ylabel('Elevation (^o)');
set(gcf, 'Position', [50 50 1000 500]); axis off
set(gca, 'YTick', [],'XTick',[]);
for i = [-180 -150 -120 -90 -30 -60 0 30 60 90 120 150 180]
plot((i*ones(1,181)).*cos((-90:90)/180*pi), -90:90, '-','color', [0.75 0.75 0.75],'linewidth',1.5)
end
for i = [-90 -60 -30 0 30 60 90]
plot((-180:180)*cos(i/180*pi), i*ones(361,1), '-','color', [0.75 0.75 0.75],'linewidth',1.5)
end
%add some labels to the meridians
for i = [-180 -120 -60 0 60 120 180]
text(i,0,sprintf('%i^o',i));
end
for i = [-90 -60 -30 30 60 90]
text(-180*cos(i/180*pi),i,sprintf('%i^o',i));
end
mapResultsForBees = cell(8,1);
numRegionsForBees = zeros(8,1);
for i = 1:8
if regGroup(i) == 1
beeCol = 'k';
else
beeCol = volCols(round((eyeVols(i)-volRng(1))./(volRng(2)-volRng(1))*(size(volCols,1)-1))+1,:);
end
%get iso line
tempFOV = zeros(size(sDat.refSphere.X,1),1); tempFOV(sDat.fullBeeData(i).inFOVBino) = 1;
%account for holes
[leftMapResults, numLeftReg] = calculateRegionsInMap( sDat.refSphere.X, tempFOV, minDst*4 );
mapResultsForBees{i} = leftMapResults;
numRegionsForBees(i) = numLeftReg;
for j = 1:numLeftReg
tempSubs = leftMapResults{j,1};
tempSubs = [circularSmooth(tempSubs(1:end-1,1)',smoothRngFOV), circularSmooth(tempSubs(1:end-1,2)',smoothRngFOV), circularSmooth(tempSubs(1:end-1,3)',smoothRngFOV)];
tempSubs = vertcat(tempSubs,tempSubs(1,:));
lineEls = acos(tempSubs(:,2))/pi*180-90;
lineAzs = -atan2(tempSubs(:,1),-tempSubs(:,3))/pi*180;
%check if line crosses top of pole and insert 90o point if so
if sum(leftMapResults{j,3} == topInd)
%if so find point on left of linkage
tempInds = find(lineAzs < 0);
[~,leftLink] = max(lineEls(tempInds));
leftLink = tempInds(leftLink);
%and then on right
tempInds = find(lineAzs >= 0);
[~,rightLink] = max(lineEls(tempInds));
rightLink = tempInds(rightLink);
if rightLink > leftLink
lineEls = [lineEls(1:leftLink)' 90 lineEls(rightLink:end)'];
lineAzs = [lineAzs(1:leftLink)' 0 lineAzs(rightLink:end)'];
else
lineEls = [lineEls(1:rightLink)' 90 lineEls(leftLink:end)'];
lineAzs = [lineAzs(1:rightLink)' 0 lineAzs(leftLink:end)'];
end
end
plot(lineAzs.*cos(lineEls/180*pi),lineEls,'-','color',beeCol','linewidth',2);
end
end
%% plot profiles across entire mono fov
%integration of FULL FOV
azIntFullFOVF = figure; hold on
for i = [-180 -150 -120 -90 -30 -60 0 30 60 90 120 150 180]
line([i i], [0 100], 'color', [0.75 0.75 0.75],'linewidth',1.5)
end
ylabel('% Az. band in FOV');
xlabel('Azimuth band (^o)');
xlim([-180 180]); ylim([0 100]);
set(gca, 'YTick', [0 25 50 75 100]);
set(gca,'XTick',[-180 -120 -60 0 60 120 180],'TickDir','out');
set(gcf, 'Position', [50 50 1000 300]);
elIntFullFOVF = figure; hold on
for i =[-90 -60 -30 0 30 60 90]
line([0 100], [i i], 'color', [0.75 0.75 0.75],'linewidth',1.5)
end
set(gca, 'YTick', [-90 -60 -30 0 30 60 90]);
xlim([0 100]); ylim([-90 90]);
set(gca,'XTick',[0 20 50 75 100],'TickDir','out');
set(gcf, 'Position', [50 50 300 500]);
xlabel('% El. band in FOV');
ylabel('Elevation band (^o)');
for i = 1:8
if regGroup(i) == 1
beeCol = 'k';
else
beeCol = volCols(round((eyeVols(i)-volRng(1))./(volRng(2)-volRng(1))*(size(volCols,1)-1))+1,:);
end
pointEls = acos(sDat.refSphere.X(sDat.fullBeeData(i).inFOV,2))/pi*180-90;
pointAzs = -atan2(sDat.refSphere.X(sDat.fullBeeData(i).inFOV,1),-sDat.refSphere.X(sDat.fullBeeData(i).inFOV,3))/pi*180;
azSum = zeros(length(azBins)-1,1);
for j = 1:length(azBins)-1
azSum(j) = length(find(pointAzs > azBins(j) & pointAzs <= azBins(j+1)))./azSumT(j)*100;
end
elSum = zeros(length(elBins)-1,1);
for j = 1:length(elBins)-1
elSum(j) = length(find(pointEls > elBins(j) & pointEls <= elBins(j+1)))./elSumT(j)*100;
end
figure(azIntFullFOVF);
plot(azBins(1:end-1)+angStep/2, azSum, '-','color',beeCol, 'linewidth',2);
figure(elIntFullFOVF);
plot(elSum,elBins(1:end-1)+angStep/2, '-','color',beeCol','linewidth',2);
end
% integration across bino fov
azIntBinoFOVF = figure; hold on
for i = [-180 -150 -120 -90 -30 -60 0 30 60 90 120 150 180]
line([i i], [0 100], 'color', [0.75 0.75 0.75],'linewidth',1.5)
end
ylabel('% Az. band in Binocular FOV');
xlabel('Azimuth band (^o)');
xlim([-180 180]); ylim([0 100]);
set(gca, 'YTick', [0 25 50 75 100]);
set(gca,'XTick',[-180 -120 -60 0 60 120 180],'TickDir','out');
set(gcf, 'Position', [50 50 1000 300]);
elIntBinoFOVF = figure; hold on
for i =[-90 -60 -30 0 30 60 90]
line([0 100], [i i], 'color', [0.75 0.75 0.75],'linewidth',1.5)
end
set(gca, 'YTick', [-90 -60 -30 0 30 60 90]);
xlim([0 100]); ylim([-90 90]);
set(gca,'XTick',[0 20 50 75 100],'TickDir','out');
set(gcf, 'Position', [50 50 300 500]);
xlabel('% El. band in Binocular FOV');
ylabel('Elevation band (^o)');
for i = 1:8
if regGroup(i) == 1
beeCol = 'k';
else
beeCol = volCols(round((eyeVols(i)-volRng(1))./(volRng(2)-volRng(1))*(size(volCols,1)-1))+1,:);
end
pointEls = acos(sDat.refSphere.X(sDat.fullBeeData(i).inFOVBino,2))/pi*180-90;
pointAzs = -atan2(sDat.refSphere.X(sDat.fullBeeData(i).inFOVBino,1),-sDat.refSphere.X(sDat.fullBeeData(i).inFOVBino,3))/pi*180;