-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubfunction_plot_pupil.m
129 lines (126 loc) · 5.39 KB
/
Subfunction_plot_pupil.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
function Subfunction_plot_pupil(data1, data2, data3, data4, stat_clu, stat_clu2, legnames, titl, makeitguapo, loc, stats, interaction)
%% Set colors
analysis_path = ' ';
addpath([analysis_path '/Tools-master_AU/plotting']);
addpath([analysis_path '/Tools-master_AU/plotting/cbrewer'])
set(groot, 'DefaultAxesTickDir', 'out');
set(groot, 'DefaultAxesTickDirMode', 'manual');
set(groot, ...
'DefaultFigureColorMap', linspecer, ...
'DefaultFigureColor', 'w', ...
'DefaultAxesLineWidth', 0.8, ...
'DefaultAxesXColor', 'k', ...
'DefaultAxesYColor', 'k', ...
'DefaultAxesFontUnits', 'points', ...
'DefaultAxesFontSize', 16, ...
'DefaultAxesFontName', 'Helvetica', ...
'DefaultLineLineWidth', 1, ...
'DefaultTextFontUnits', 'Points', ...
'DefaultTextFontSize', 16, ...
'DefaultTextFontName', 'Helvetica', ...
'DefaultAxesBox', 'off', ...
'DefaultAxesTickLength', [0.02 0.025]);
colors1 = cbrewer('qual', 'Set1', 2);
black = [0.25, 0.25, 0.25]; red = [1, 0, 0]; blue = [0, 0.4470, 0.7410];
colors = [red; blue; black]
%% PLOT
time = linspace(min(data1.time), max(data1.time), numel(data1.time));
fsample = 100;
switch interaction
case 0
enc = boundedline(time, data1.avg, data1.var, ...
time, data2.avg, data2.var, ...
time, data3.avg, data3.var, ...
'cmap', colors, 'transparency', 0.1);
hold on
ylims = get(gca, 'ylim');
hold on;
i = 0.01
if sum(stat_clu.mask == 1) > 0
% sig=find(stat_clu.mask==1)/fsample;
sig = time(find(stat_clu.mask == 1))
line([sig(1) sig(end)], [ylims(1) + i ylims(1) + i], 'LineWidth', 1, 'Color', 'k');
text(sig(1), ylims(1) - 0.03, 'p < .05', 'FontSize', 12);
else
line([0 time(end)], [ylims(1) + i ylims(1) + i], 'LineWidth', 1, 'Color', 'k');
text(time(end) - 0.1, ylims(1) + 0.05, 'n.s.', 'FontSize', 12);
end
lh = legend(enc);
for i = 1:length(legnames),
str{i} = ['\' sprintf('color[rgb]{%f,%f,%f} %s', colors(i, 1), colors(i, 2), colors(i, 3), legnames{i})];
end
lh.String = str;
lh.Box = 'off';
lh.FontSize = 12;
if loc == 1
lh.Location = 'NorthWest';
else
lh.Location = 'South';
end
lpos = lh.Position;
lpos(1) = lpos(1) - makeitguapo
lh.Position = lpos
ylims = get(gca, 'ylim');
axis tight;
ylim([min(ylims) max(ylims)]);
xvals = time(1):.5:time(end);
xlim([min(xvals) max(xvals)]); % some space at the sides
xlabel('Time'); set(gca, 'xtick', xvals);
ylabel('Pupil response (z)');
xlims = get(gca, 'xlim')
t = title(titl)
t.FontSize = 18
% Case 1 for interactions between Memory and Sound for 2T seqs
case 1
colors = cbrewer('qual', 'Paired', 8);
colors = colors([1:2, 5:6], :)
enc = boundedline(time, data1.avg, data1.var, ...
time, data2.avg, data2.var, ...
time, data3.avg, data3.var, ...
time, data4.avg, data4.var, ...
'cmap', colors, 'transparency', 0.1); %eA)
ylims = get(gca, 'ylim');
hold on;
i = 0.02
if sum(stat_clu.mask == 1) > 0
sig = time(find(stat_clu.mask == 1))
line([sig(1) sig(end)], [ylims(1) + i ylims(1) + i], 'LineWidth', 1, 'Color', 'k');
text(sig(1), ylims(1) - 0.01, 'Main effect of sound: p < .05', 'FontSize', 16);
else
disp('no significant main effect of sound');
end
i = 0.04
if sum(stat_clu2.mask == 1) > 0
sig = time(find(stat_clu2.mask == 1))
line([sig(1) sig(end)], [ylims(1) + i ylims(1) + i], 'LineWidth', 1, 'Color', 'k');
text(sig(1), ylims(1) + i - 0.03, 'Main effect of memory: p < .05', 'FontSize', 16);
else
disp('no significant main effect of memory');
end
lh = legend(enc);
for i = 1:length(legnames),
str{i} = ['\' sprintf('color[rgb]{%f,%f,%f} %s', colors(i, 1), colors(i, 2), colors(i, 3), legnames{i})];
end
lh.String = str;
lh.Box = 'off';
lh.FontSize = 16;
if loc == 1
lh.Location = 'NorthEast';
else
lh.Location = 'South';
end
lpos = lh.Position;
lpos(1) = lpos(1) - makeitguapo
lh.Position = lpos
ylims = get(gca, 'ylim');
axis tight;
ylim([min(ylims) max(ylims)]);
xvals = time(1):.5:time(end);
xlim([min(xvals) max(xvals)]); % some space at the sides
xlabel('Time'); set(gca, 'xtick', xvals);
ylabel('Pupil response (z)');
xlims = get(gca, 'xlim')
t = title(titl)
t.FontSize = 18
end
end