-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowTonsetByCue.m
76 lines (66 loc) · 2.29 KB
/
showTonsetByCue.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
function [f, avgTonsetByCue, winSamps_tonsetByCue] = showTonsetByCue(t_r, ...
y_r, cardinalDir, catEvTimes, dd, psthNames, figTWin, onlySuccess)
% [f, avgTOnsetByCue, winSamps_tonsetByCue] = showTonsetByCue(t_r, ...
% y_r, cardinalDir, catEvTimes, dd, psthNames, figTWin)
% returns target onset response avg across success&fail trials
%
% [~] = showTonsetByCue(t_r, ...
% y_r, cardinalDir, catEvTimes, dd, psthNames, figTWin, 1)
% returns avg across success trials
if nargin < 8
onlySuccess = 0;
end
% created from resp_cueConditions
onset = catEvTimes.tOnset;
% y_r = cat(1,PSTH_f',PSTH_ff', predicted_all, predicted, pdiam_r)
for icue = 1:2
validEvents = intersect(find(~isnan(onset)), find(dd.cueOn==icue-1));
%< this condition only includes all trials irrespective of the trial outcome
if onlySuccess
validEvents = intersect(validEvents, find(~isnan(dd.cOnset)));
end
onsetTimes = onset(validEvents);
tgtDir = getTgtDir(dd.targetloc(validEvents), cardinalDir);
[~,dirIdx]=intersect(cardinalDir, unique(tgtDir));
[avgTonsetByCue(dirIdx,:,:,icue), winSamps_tonsetByCue] ...
= eventLockedAvg(y_r', t_r, onsetTimes, tgtDir, figTWin);
end
%% w vs wo cue
colormap('parula');
f = figure('position',[0 0 1400 1000]);
for icue = 1:3
nvars = size(avgTonsetByCue,2);
switch icue
case {1,2}
crange = prctile(avgTonsetByCue(:),[0 100]);
case 3
cache = abs(diff(avgTonsetByCue,1,4));
crange = [-prctile(cache(:),99) prctile(cache(:),99)];
end
for ivar = 1:nvars
if icue <3
thisData = squeeze(avgTonsetByCue(:,ivar,:,icue));
elseif icue ==3
thisData = squeeze(diff(avgTonsetByCue(:,ivar,:,:),1,4));
end
subplot(nvars, 3, 3*(ivar-1)+icue);
imagesc(winSamps_tonsetByCue, cardinalDir, thisData);
set(gca, 'ytick',cardinalDir);
if icue==1
ylabel(psthNames{ivar});
end
caxis(crange);
mcolorbar;
if ivar == 1
if icue==1
title('wo cue');
elseif icue ==2
title('w cue');
elseif icue == 3
title('wcue-wocue');
end
end
end
%mcolorbar;
end
xlabel(['time from tOnset [s]']);