-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowKernel_pop.m
139 lines (125 loc) · 3.82 KB
/
showKernel_pop.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
function [fig, kernel_avg,prefdir, prefdirPval] = showKernel_pop(kernel_pop, ...
tlags, cardinalDir, centering, tgtRange)
% fig = showKernel_pop(kernel_pop, tlags, cardinalDir, centering)
useSameYrange = true;
prefDirOption = 0;%
%very slow in option=1
%something is not right in option=2
[ncol, nrow] = size(kernel_pop);
nUnits = nrow;%size(kernel_pop{1,1},2);
kernel_avg = [];prefdir=[];prefdirPval=[];
for col = 1:ncol %predictor type
if centering && col<=3
allmatrix = reshape(zeros(size(kernel_pop{col,1})),[],1);
for row = 1:nrow %unit
allmatrix(:,row) = reshape(kernel_pop{col,row},1,[]);
end
orisize = size(kernel_pop{col,1});
allmatrix = reshape(allmatrix, orisize(1), orisize(2),[]);
tgtTimes = intersect(find(tlags{col}(:,1)>tgtRange(col,1)), ...
find(tlags{col}(:,1)<tgtRange(col,2)));
[directions, allmatrix_c, prefdir{col}, prefdirPval{col}] = ...
alignMtxDir(allmatrix, tgtTimes, cardinalDir, prefDirOption );
kernel_avg{col} = squeeze(mean(allmatrix_c,3));
else
if ~centering
directions = cardinalDir;
end
allmatrix = reshape(zeros(size(kernel_pop{col,1})),[],1);
for row = 1:nrow
allmatrix(:,row) = reshape(kernel_pop{col,row},1,[]);
end
kernel_avg{col} = reshape(mean(allmatrix,2),size(kernel_pop{col,row}));
end
end
if useSameYrange
absMax = max(cellfun(@(x)abs(max(x(:))), kernel_avg));
end
% created rom showKernel
fig = figure('position',[1 41 1440 783]);
a2=subplot(3,2,1);
thisIm = kernel_avg{1}';
crange = prctile(abs(thisIm(:)),99);
if useSameYrange
crange = absMax;
end
imagesc(tlags{1}(:,1), directions, thisIm);
vline(0);
if centering
hline(0);
end
clim([-crange crange]);
set(gca,'ytick',directions);
xlabel('time from targetOnset [s]');
mcolorbar(a2,.5);
title(['n=' num2str(nUnits)]);
set(gca,'tickdir','out');
a3=subplot(3,2,3);
thisIm = kernel_avg{2}';
crange = prctile(abs(thisIm(:)),99);
%crange = prctile(thisIm(:),[1 99]);
if useSameYrange
crange = absMax;
end
imagesc(tlags{2}(:,1),directions, thisIm);
vline(0);
if centering
hline(0);
end
clim([-crange crange]);
set(gca,'ytick',directions);
xlabel('time from eye movement [s]');
mcolorbar(a3,.5);
set(gca,'tickdir','out');
if size(kernel_avg{3},2)>1
a4=subplot(3,2,5);
thisIm = kernel_avg{3}';
crange = prctile(abs(thisIm(:)),99);
%crange = prctile(thisIm(:),[1 99]);
if useSameYrange
crange = absMax;
end
imagesc(tlags{3}(:,1),directions, thisIm);
vline(0);
if centering
hline(0);
end
caxis([-crange crange]);
set(gca,'ytick',directions);
set(gca,'tickdir','out');
xlabel('time from eye movement [s]');
mcolorbar(a4,.5);
a5=subplot(3,2,2);
plot(tlags{4}, [kernel_pop{4,:}],'color',[.7 .7 .7]);
hold on
plot(tlags{4}, kernel_avg{4}','k','linewidth',2);
vline(0);
xlabel('time from pupil dilation [s]');
set(gca,'tickdir','out');
axis tight;
a6=subplot(3,2,4);
plot(tlags{5}, [kernel_pop{5,:}],'color',[.7 .7 .7]);
hold on
plot(tlags{5}, kernel_avg{5}','k','linewidth',2);
vline(0);
xlabel('time from blink [s]');
set(gca,'tickdir','out');
axis tight;
% a7=subplot(3,2,6);
% plot(tlags{6}, [kernel_pop{6,:}],'color',[.7 .7 .7]);
% hold on
% plot(tlags{6}, kernel_avg{6}','k','linewidth',2);
% vline(0);
% xlabel('time from fixation onset [s]');
% axis tight;
linkaxes([a2 a3 a4 a5 a6],'x');
else
%NOT YET
a4=subplot(5,1,4);
boundedline(tlags{3}, kernel_avg{3}', kernel_se{3}');hold on
boundedline(tlags{4}, kernel_avg{4}', kernel_se{4}');hold on
vline(0);
xlabel('time from pupil dilation/blink [s]');
axis tight;
linkaxes([a2 a3 a4],'x');
end