-
Notifications
You must be signed in to change notification settings - Fork 1
/
ContoursPlotResultSpikes.m
137 lines (126 loc) · 4.54 KB
/
ContoursPlotResultSpikes.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
function ContoursPlotResultSpikes(markers,result,spikes,cluster,target,argcatch)
%ContoursPlotResultSpikes Plot spike trains according to salience
%conditions and result of the trial
% ContoursPlotResultSpikes(MARKERS,RESULT,SPIKES,CLUSTER,TARGET,
% CATCH) creates rasterplots of the response grouped according to
% salience values and the RESULT ('correct' or 'incorrect') of
% the trial found in MARKERS. TARGET is either 'contour' for the
% contour target, or 'control' for the control target. CATCH is
% either 'catch', which means to plot the responses to the catch
% trials, or 'nocatch' which means not to plot the responses to
% the catch trials.
% e.g. ContoursPlotResultSpikes(annie042401s08g01umarkers,
% 'correct',annie042401s08g01us,1,'contour','catch') plots
% the spikes in cluster number 1 for the trials where the
% target was at the contour location and the response of
% the animal was correct. The response to the catch trials
% are also plottted.
% check to see if we need to plot catch trials
if strcmp(argcatch,'catch')
plotcatch = 1;
elseif strcmp(argcatch,'nocatch')
plotcatch = 0;
elseif strcmp(argcatch,'allcatch')
plotcatch = 2;
else
fprintf('Unknown CATCH argument\n');
return
end
% check to see if we want to plot correct trials or incorrect trials
if strcmp(result,'correct')
plotresult = 1;
elseif strcmp(result,'incorrect')
plotresult = 0;
end
% clear the current figure
clf
saliencesteps = size(spikes.contour,2);
reps = size(spikes.contour(1).repetition,2);
catchreps = reps / 2;
y = 0;
salienceboundary = [];
if strcmp(target,'contour')
% plot contour conditions
for si=1:saliencesteps
for ri=1:reps
if markers.contour(si).repetition(ri).response==plotresult
yend = y + 0.75;
for spi=1:spikes.contour(si).repetition(ri).cluster(cluster).spikecount
spiketime = spikes.contour(si).repetition(ri).cluster(cluster).spikes(spi);
line([spiketime spiketime],[y yend])
end
y = y + 1;
end
end
salienceboundary = [salienceboundary y];
end
if plotcatch==1
for ri=1:catchreps
if markers.catchcontour.repetition(ri).response==plotresult
yend = y + 0.75;
for spi=1:spikes.catchcontour.repetition(ri).cluster(cluster).spikecount
spiketime = spikes.catchcontour.repetition(ri).cluster(cluster).spikes(spi);
line([spiketime spiketime],[y yend])
end
y = y + 1;
end
end
salienceboundary = [salienceboundary y];
end
elseif strcmp(target,'control')
% plot control conditions
for si=1:saliencesteps
for ri=1:reps
if markers.control(si).repetition(ri).response==plotresult
yend = y + 0.75;
for spi=1:spikes.control(si).repetition(ri).cluster(cluster).spikecount
spiketime = spikes.control(si).repetition(ri).cluster(cluster).spikes(spi);
line([spiketime spiketime],[y yend])
end
y = y + 1;
end
end
salienceboundary = [salienceboundary y];
end
if plotcatch==1
for ri=1:catchreps
if markers.catchcontrol.repetition(ri).response==plotresult
yend = y + 0.75;
for spi=1:spikes.catchcontrol.repetition(ri).cluster(cluster).spikecount
spiketime = spikes.catchcontrol.repetition(ri).cluster(cluster).spikes(spi);
line([spiketime spiketime],[y yend])
end
y = y + 1;
end
end
salienceboundary = [salienceboundary y];
end
end
if plotcatch==2
for ri=1:catchreps
if markers.catchcontour.repetition(ri).response==plotresult
yend = y + 0.75;
for spi=1:spikes.catchcontour.repetition(ri).cluster(cluster).spikecount
spiketime = spikes.catchcontour.repetition(ri).cluster(cluster).spikes(spi);
line([spiketime spiketime],[y yend])
end
y = y + 1;
end
end
for ri=1:catchreps
if markers.catchcontrol.repetition(ri).response==plotresult
yend = y + 0.75;
for spi=1:spikes.catchcontrol.repetition(ri).cluster(cluster).spikecount
spiketime = spikes.catchcontrol.repetition(ri).cluster(cluster).spikes(spi);
line([spiketime spiketime],[y yend])
end
y = y + 1;
end
end
end
% get axis values so we can draw the lines separating conditions
axi = axis;
bsteps = size(salienceboundary,2);
for si=1:bsteps
line([axi(1) axi(2)],[salienceboundary(si) salienceboundary(si)])
end