-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_ISIs.m
35 lines (28 loc) · 1000 Bytes
/
plot_ISIs.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
% plot_ISIs.m
% This function makes a histogram of interspike intervals (ISIs) for each
% Neuron in the dataset. It takes a matrix of spike trains (spikes) and the
% max ISI to include in the histogram (threshold) as inputs and returns a
% cell array containing all the ISIs for each neuron.
function ISIs = plot_ISIs(spikes,threshold,binwidth)
n = size(spikes,2);
ISIs = cell(n,1);
figure('units','normalized','outerposition',[0 0.035 1 0.92]);
for i = 1:n,
ISIs{i} = diff(find(spikes(:,i)));
pISI = ISIs{i}(ISIs{i}<=threshold); %Throw out ISIs that are too large (for plotting only)
subplot(2,5,i); grid on; hold on;
histogram(pISI,'BinWidth',binwidth);
if i==ceil(3*n/4)
xlabel('Interspike Interval (ms)');
end
if mod(i,n/2)==1
ylabel('Spike Count');
end
title(['Neuron ' num2str(i)]);
set(gca,'fontsize',20)
xlim([0 600])
ylim([0 300])
end
set(gca,'fontsize',20)
% suptitle('Distribution of Interspike Intervals');
end