-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo_plots.m
141 lines (134 loc) · 5.23 KB
/
demo_plots.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
%% fetch
data(1) = fetch(firefly.StatsBehaviour...
& 'monk_name = "Bruno"'...
& 'session_id = 41' ...
& 'trial_type = "fireflyoff"','*');
data(2) = fetch(firefly.StatsBehaviour...
& 'monk_name = "Schro"'...
& 'session_id = 35' ...
& 'trial_type = "fireflyoff"','*');
data(3) = fetch(firefly.StatsBehaviour...
& 'monk_name = "Quigley"'...
& 'session_id = 149' ...
& 'trial_type = "fireflyoff"','*');
%% define colors
numdata = numel(data);
cmap = brewermap(numdata,'Set1');
% cmap = [[31 39 154]/255; ...
% [154 121 31]/255; ...
% [154 31 63]/255];
% cmap = [[137 185 24]/255; ...
% [24 142 185]/255; ...
% [169 24 185]/255];
%% plot distance and angle scatter
figure; hold on;
% distance scatter
subplot(1,2,1); hold on;
maxdist = 400;
% sample 500 trials
for i=1:numdata
outliers = (data(i).monkey_rf./data(i).firefly_r < prctile(data(i).monkey_rf./data(i).firefly_r,0.5));
data(i).firefly_r(outliers) = []; data(i).monkey_rf(outliers) = [];
Ntot = numel(data(i).firefly_r);
indx = randsample(Ntot,500);
firefly_r(i,:) = data(i).firefly_r(indx);
monkey_rf(i,:) = data(i).monkey_rf(indx);
end
% plot
numsplits = 50; % split each dataset to prevent occluding when plotting
for j=1:numsplits
for i=1:numdata
plot(firefly_r(i,end*((j-1)/numsplits)+1:end*(j/numsplits)),...
monkey_rf(i,end*((j-1)/numsplits)+1:end*(j/numsplits)),...
'o','Color',cmap(i,:),'MarkerFaceColor',[.8 .8 .8],'MarkerSize',2);
end
end
plot(0:maxdist,0:maxdist,'k');
% axis labels and title
axis([0 maxdist 0 maxdist]);
set(gca,'XTick',0:100:maxdist,'XTickLabel',0:maxdist/100);
set(gca,'YTick',0:100:maxdist,'YTickLabel',0:maxdist/100);
xlabel('Target (m)','Fontname','Arial');
ylabel('Response (m)','Fontname','Arial');
title('Radial distance','Fontname','Arial');
set(gca,'FontSize',14,'Fontname','Arial');
%angle scatter
subplot(1,2,2); hold on;
maxangle = 40;
% sample 500 trials
for i=1:numdata
outliers = (data(i).monkey_thf./data(i).firefly_th < prctile(data(i).monkey_thf./data(i).firefly_th,1));
data(i).firefly_th(outliers) = []; data(i).monkey_thf(outliers) = [];
Ntot = numel(data(i).firefly_th);
indx = randsample(Ntot,500);
firefly_th(i,:) = data(i).firefly_th(indx);
monkey_thf(i,:) = data(i).monkey_thf(indx);
end
% plot
numsplits = 50; % split each dataset to prevent occluding when plotting
for j=1:numsplits
for i=1:numdata
plot(firefly_th(i,end*((j-1)/numsplits)+1:end*(j/numsplits)),...
monkey_thf(i,end*((j-1)/numsplits)+1:end*(j/numsplits)),...
'o','Color',cmap(i,:),'MarkerFaceColor',[.8 .8 .8],'MarkerSize',2);
end
end
plot(-maxangle:maxangle,-maxangle:maxangle,'k');
% axis labels and title
axis([-maxangle maxangle -maxangle maxangle]);
xlabel('Target (m)','Fontname','Arial');
ylabel('Response (m)','Fontname','Arial');
title('Angular eccentricity','Fontname','Arial');
set(gca,'FontSize',14,'Fontname','Arial');
hline(0,'k'); vline(0,'k');
%% stopping distances
% fetch
data_off{1} = fetch(firefly.StatsBehaviour...
& 'monk_name = "Bruno"'...
& 'trial_type = "fireflyoff"','*');
data_off{2} = fetch(firefly.StatsBehaviour...
& 'monk_name = "Schro"'...
& 'trial_type = "fireflyoff"','*');
data_off{3} = fetch(firefly.StatsBehaviour...
& 'monk_name = "Quigley"'...
& 'trial_type = "fireflyoff"','*');
data_on{1} = fetch(firefly.StatsBehaviour...
& 'monk_name = "Bruno"'...
& 'trial_type = "fireflyon"','*');
data_on{2} = fetch(firefly.StatsBehaviour...
& 'monk_name = "Schro"'...
& 'trial_type = "fireflyon"','*');
data_on{3} = fetch(firefly.StatsBehaviour...
& 'monk_name = "Quigley"'...
& 'trial_type = "fireflyon"','*');
% plot
figure; hold on;
dist2firefly = cell2mat({[data_off{1}.dist2firefly] [data_off{1}.dist2firefly_shuffled] [data_on{1}.dist2firefly] ...
[data_off{2}.dist2firefly] [data_off{2}.dist2firefly_shuffled] [data_on{2}.dist2firefly] ...
[data_off{3}.dist2firefly] [data_off{3}.dist2firefly_shuffled] [data_on{3}.dist2firefly]});
trialtype = [repmat({'1'},1,numel([data_off{1}.dist2firefly]))...
repmat({'2'},1,numel([data_off{1}.dist2firefly_shuffled]))...
repmat({'3'},1,numel([data_on{1}.dist2firefly]))...
repmat({'4'},1,numel([data_off{2}.dist2firefly]))...
repmat({'5'},1,numel([data_off{2}.dist2firefly_shuffled]))...
repmat({'6'},1,numel([data_on{2}.dist2firefly]))...
repmat({'7'},1,numel([data_off{3}.dist2firefly]))...
repmat({'8'},1,numel([data_off{3}.dist2firefly_shuffled]))...
repmat({'9'},1,numel([data_on{3}.dist2firefly]))];
violinplot(dist2firefly,trialtype);
% axis labels and title
ylim([0 250]); hline(60,'k');
set(gca,'XTick',[],'YTick',0:100:200,'YTicklabel',0:2);
ylabel('Stopping distance (m)');
%% area under the curve
data_off{1} = fetch(firefly.StatsBehaviour...
& 'monk_name = "Bruno"'...
& 'trial_type = "fireflyoff"','*');
data_off{2} = fetch(firefly.StatsBehaviour...
& 'monk_name = "Schro"'...
& 'trial_type = "fireflyoff"','*');
data_off{3} = fetch(firefly.StatsBehaviour...
& 'monk_name = "Quigley"'...
& 'trial_type = "fireflyoff"','*');
% plot
figure; hold on;