-
Notifications
You must be signed in to change notification settings - Fork 1
/
ContoursCalPSTH.m
73 lines (65 loc) · 2.87 KB
/
ContoursCalPSTH.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
function psth = ContoursCalPSTH(spikes,binsize)
%ContoursCalPSTH Calculate PSTHs for a session
% PSTH = ContoursCalPSTH(SPIKES,BINSIZE)
saliencesteps = size(spikes.contour,2);
clusters=size(spikes.contour(1).repetition(1).cluster,2);
timebins = 0:binsize:spikes.duration*1000;
% save timebins in data structure so we can plot data more easily
psth.timebins = timebins;
for si=1:saliencesteps
reps = size(spikes.contour(si).repetition,2);
for cl=1:clusters
psth.contour(si).cluster(cl).spikes = [];
for ri=1:reps
psth.contour(si).cluster(cl).spikes = [psth.contour(si).cluster(cl).spikes spikes.contour(si).repetition(ri).cluster(cl).spikes];
end
% psth.contour(si).cluster(cl).spikes = sort(psth.contour(si).cluster(cl).spikes);
psth.contour(si).cluster(cl).psth = hist(psth.contour(si).cluster(cl).spikes,timebins)/reps;
end
end
for si=1:saliencesteps
reps = size(spikes.control(si).repetition,2);
for cl=1:clusters
psth.control(si).cluster(cl).spikes = [];
for ri=1:reps
psth.control(si).cluster(cl).spikes = [psth.control(si).cluster(cl).spikes spikes.control(si).repetition(ri).cluster(cl).spikes];
end
% psth.control(si).cluster(cl).spikes = sort(psth.control(si).cluster(cl).spikes);
psth.control(si).cluster(cl).psth = hist(psth.control(si).cluster(cl).spikes,timebins)/reps;
end
end
if isfield(spikes,'catchcontour')
reps = size(spikes.catchcontour.repetition,2);
for cl=1:clusters
psth.catchcontour.cluster(cl).spikes = [];
for ri=1:reps
psth.catchcontour.cluster(cl).spikes = [psth.catchcontour.cluster(cl).spikes spikes.catchcontour.repetition(ri).cluster(cl).spikes];
end
% psth.catchcontour.cluster(cl).spikes = sort(psth.catchcontour.cluster(cl).spikes);
psth.catchcontour.cluster(cl).psth = hist(psth.catchcontour.cluster(cl).spikes,timebins)/reps;
end
catchreps = reps;
reps = size(spikes.catchcontrol.repetition,2);
for cl=1:clusters
psth.catchcontrol.cluster(cl).spikes = [];
for ri=1:reps
psth.catchcontrol.cluster(cl).spikes = [psth.catchcontrol.cluster(cl).spikes spikes.catchcontrol.repetition(ri).cluster(cl).spikes];
end
% psth.catchcontrol.cluster(cl).spikes = sort(psth.catchcontrol.cluster(cl).spikes);
psth.catchcontrol.cluster(cl).psth = hist(psth.catchcontrol.cluster(cl).spikes,timebins)/reps;
end
% catchreps = catchreps + reps;
% for cl=1:clusters
% psth.allcatch.cluster(cl).psth = hist([psth.catchcontour.cluster(cl).spikes psth.catchcontrol.cluster(cl).spikes],timebins)/catchreps;
% end
if isfield(spikes,'allcatch')
reps = size(spikes.allcatch.repetition,2);
for cl=1:clusters
psth.allcatch.cluster(cl).spikes = [];
for ri = 1:reps
psth.allcatch.cluster(cl).spikes = [psth.allcatch.cluster(cl).spikes spikes.allcatch.repetition(ri).cluster(cl).spikes];
end
psth.allcatch.cluster(cl).psth = hist(psth.allcatch.cluster(cl).spikes,timebins)/reps;
end
end
end