This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/spike_trains/code/psths.m
2015-10-30 19:16:36 +01:00

87 lines
1.7 KiB
Matlab

%% Instantaneous rate
clear
clc
close all
load 'lifoustim.mat'
t_max = 30;
rates = zeros(length(spikes), 30/dt);
for i = 1:length(spikes)
[t, rates(i,:)] = instantaneous_rate(spikes{i}, dt, t_max);
end
f = figure();
set(f, 'paperunits', 'centimeters')
set(f, 'papersize', [10, 10])
set(f, 'paperposition', [0 0 10 10])
hold on
plot(t, rates(1,:), 'displayname', 'trial 1')
plot(t, mean(rates,1), 'displayname', 'average rate')
xlabel('time [s]', 'fontsize', 10)
ylabel('firing rate [Hz]','fontsize', 10)
legend('show')
box('off')
saveas(gcf, 'instantaneous_rate', 'pdf')
%% Binning Method
clear
clc
close all
load 'lifoustim.mat'
t_max = 30;
rates = zeros(length(spikes), 30/dt);
for i = 1:length(spikes)
[t, rates(i,:)] = binned_rate(spikes{i}, 0.05, dt, t_max);
end
f = figure();
set(f, 'paperunits', 'centimeters')
set(f, 'papersize', [10, 10])
set(f, 'paperposition', [0 0 10 10])
hold on
plot(t, rates(1,:), 'displayname', 'trial 1')
plot(t, mean(rates,1), 'displayname', 'average rate')
xlabel('time [s]', 'fontsize', 10)
ylabel('firing rate [Hz]','fontsize', 10)
legend('show')
box('off')
saveas(gcf, 'binned_rate', 'pdf')
%% Convolution Method
clear
clc
close all
load 'lifoustim.mat'
t_max = 30;
rates = zeros(length(spikes), 30/dt);
for i = 1:length(spikes)
[t, rates(i,:)] = convolution_rate(spikes{i}, 0.05, dt, t_max);
end
f = figure();
set(f, 'paperunits', 'centimeters', 'papersize', [10, 10], 'paperposition', [0 0 10 10])
hold on
plot(t, rates(1,:), 'displayname', 'trial 1')
plot(t, mean(rates,1), 'displayname', 'average rate')
xlabel('time [s]', 'fontsize', 10)
ylabel('firing rate [Hz]','fontsize', 10)
legend('show')
box('off')
saveas(gcf, 'convolved_rate', 'pdf')