changes
This commit is contained in:
@@ -4,48 +4,57 @@ max_time = 0;
|
||||
for i = 1:size(times,2)
|
||||
max_time = max([max_time, max(times{i})]);
|
||||
end
|
||||
fig = figure();
|
||||
set(gcf,'Color', 'white')
|
||||
%% create PSTH on the basis of the interspike intervals
|
||||
subplot(3,1,1)
|
||||
hold on
|
||||
% 1. get the interspike intervals for each trial
|
||||
for i = 1:size(times,2)
|
||||
t = times{i};
|
||||
isi = diff(t);
|
||||
plot(t(2:end), 1./isi)
|
||||
t = times{1};
|
||||
firing_rate = [0 1./diff(t)];
|
||||
start = 1;
|
||||
resp = zeros(1, round(max_time * sample_rate));
|
||||
for i = 1:length(t)
|
||||
resp(1,start:round(t(i) * sample_rate)) = firing_rate(i);
|
||||
start = round(t(i) * sample_rate);
|
||||
end
|
||||
|
||||
fig = figure();
|
||||
set(gcf, 'PaperUnits', 'centimeters');
|
||||
set(gcf, 'PaperSize', [11.7 9.0]);
|
||||
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
|
||||
set(gcf,'Color', 'white')
|
||||
plot((1/sample_rate:1/sample_rate:max_time), resp)
|
||||
xlabel('time [s]')
|
||||
ylabel('firing rate [Hz]')
|
||||
box('off')
|
||||
ylim([0 300])
|
||||
xlim([0 1])
|
||||
title('instanataneous firing rate')
|
||||
|
||||
%% create PSTH using the binning method
|
||||
subplot(3,1,2)
|
||||
box('off')
|
||||
bin_width = 0.02; % s
|
||||
bin_width = 0.0125; % s
|
||||
edges = 0:bin_width:max_time;
|
||||
firing_rate = [];
|
||||
for i = 1:size(times,2)
|
||||
t = times{i};
|
||||
[n, t] = hist(t, edges);
|
||||
[n, time] = hist(t, edges);
|
||||
if isempty(firing_rate)
|
||||
firing_rate = n / bin_width;
|
||||
firing_rate = n / bin_width / size(times,2);
|
||||
else
|
||||
firing_rate = firing_rate + (n / bin_width / size(times,2));
|
||||
end
|
||||
end
|
||||
plot(t,firing_rate)
|
||||
fig = figure();
|
||||
set(gcf, 'PaperUnits', 'centimeters');
|
||||
set(gcf, 'PaperSize', [11.7 9.0]);
|
||||
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
|
||||
set(gcf,'Color', 'white')
|
||||
plot(time, firing_rate)
|
||||
ylim([0 300])
|
||||
xlim([0 1])
|
||||
xlabel('time [s]')
|
||||
ylabel('firing rate [Hz]')
|
||||
title('binning method')
|
||||
|
||||
%% create PSTH using the kernel-convolution method
|
||||
subplot(3,1,3)
|
||||
kernel_width = 0.0125; %s
|
||||
binary_spikes = zeros(size(times,2), round(max_time*sample_rate));
|
||||
resps = zeros(size(binary_spikes));
|
||||
window = hann(bin_width/4*sample_rate,'symmetric');
|
||||
window = hann(kernel_width*sample_rate,'symmetric');
|
||||
window = window/sum(window);
|
||||
|
||||
for i = 1:size(times,2)
|
||||
@@ -55,6 +64,16 @@ for i = 1:size(times,2)
|
||||
temp(1) = 1;
|
||||
end
|
||||
binary_spikes(i, temp) = 1;
|
||||
resps(i,:) = conv(binary_spikes(i,:), window, 'same');
|
||||
resps(i,:) = conv(binary_spikes(i,:), window, 'same')*sample_rate;
|
||||
end
|
||||
plot((0:1/sample_rate:max_time), mean(resps,2))
|
||||
fig = figure();
|
||||
set(gcf, 'PaperUnits', 'centimeters');
|
||||
set(gcf, 'PaperSize', [11.7 9.0]);
|
||||
set(gcf, 'PaperPosition',[0.0 0.0 11.7 9.0]);
|
||||
set(gcf,'Color', 'white')
|
||||
plot((1/sample_rate:1/sample_rate:max_time), mean(resps,1))
|
||||
ylim([0 300])
|
||||
xlim([0 1])
|
||||
xlabel('time [s]')
|
||||
ylabel('firing rate [Hz]')
|
||||
title('convolution method')
|
||||
|
||||
Reference in New Issue
Block a user