-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowPSTH.m
48 lines (40 loc) · 999 Bytes
/
showPSTH.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
function [psth bounds] = showPSTH(spikeTimes,bounds,sigma,color,display)
%function psth = showPSTH(spikeTimes,bounds,sigma)
%
% spikeTimes is a cell of spikeTimes (in ms)
% bounds in ms
% spikeTimes is a cell array and all values inside are pooled
%
% sigma is the standard deviation of the gaussian smoothing window
%
% modifed from showPSTH Corentin CNBC 03/17/2013
sampling = 1000;% i.e1/0.001
spikeTimes = reshape(spikeTimes,numel(spikeTimes),1);
ntrials = length(spikeTimes);
%cell2mat
for i = 1:ntrials
spikeTimes{i} = spikeTimes{i}(:);
end
spikeTimes = cell2mat(spikeTimes);
%bounds
if isempty(bounds)
if max(spikeTimes)>0,
bounds=[0 max(spikeTimes)];
else
bounds=[0 1];
end
end
%psth histogram
psth = hist(spikeTimes,bounds(1):bounds(2));
%smoothing
psth = gaussSmooth(psth,sigma);
%normalization
psth = psth*sampling/ntrials;
%plot
if display,
if sigma==1
plot(psth)
else
plot(psth,color,'Linewidth',1)
end
end