fixed lif and noisefi projects

This commit is contained in:
2018-01-19 14:54:03 +01:00
parent eca31e3c95
commit c2e37b516e
5 changed files with 71 additions and 41 deletions

View File

@@ -1,8 +1,8 @@
function spikes = lifspikes(trials, input, tmax, D)
function spikes = lifspikes(trials, current, tmax, D)
% Generate spike times of a leaky integrate-and-fire neuron
% trials: the number of trials to be generated
% input: the stimulus either as a single value or as a vector
% tmax: duration of a trial
% current: the stimulus either as a single value or as a vector
% tmax: duration of a trial if input is a single number
% D: the strength of additive white noise
tau = 0.01;
@@ -13,7 +13,11 @@ function spikes = lifspikes(trials, input, tmax, D)
vthresh = 10.0;
dt = 1e-4;
n = ceil(tmax/dt);
n = length( current );
if n <= 1
n = ceil(tmax/dt);
current = zeros( n, 1 ) + current;
end
spikes = cell(trials, 1);
for k=1:trials
times = [];
@@ -21,7 +25,7 @@ function spikes = lifspikes(trials, input, tmax, D)
v = vreset + (vthresh-vreset)*rand();
noise = sqrt(2.0*D)*randn(n, 1)/sqrt(dt);
for i=1:n
v = v + (- v + noise(i) + input)*dt/tau;
v = v + (- v + noise(i) + current(i))*dt/tau;
if v >= vthresh
v = vreset;
times(j) = i*dt;

View File

@@ -7,20 +7,34 @@ figure()
Ds = [0, 0.001, 0.01, 0.1];
for j = 1:length(Ds)
D = Ds(j);
inputs = 0.0:0.5:20.0;
rates = ficurve(trials, inputs, tmax, D);
plot(inputs, rates);
currents = 0.0:0.5:20.0;
rates = ficurve(trials, currents, tmax, D);
plot(currents, rates);
hold on;
end
hold off;
%% spike raster and CVs
input = 12.0;
figure()
current = 12.0;
for j = 1:length(Ds)
D = Ds(j);
spikes = lifspikes(trials, input, tmax, D);
spikes = lifspikes(trials, current, tmax, D);
subplot(4, 2, 2*j-1);
spikeraster(spikes, 0.0, 1.0);
subplot(4, 2, 2*j);
isih(spikes, [0:0.001:0.04]);
end
%% subthreshold resonance:
time = [0.0:0.0001:1.0];
current = 5.0 + 4.0*sin(2.0*pi*5.0*time);
D = 0.1;
spikes = lifspikes(trials, current, tmax, D);
subplot(2, 1, 1);
spikeraster(spikes, 0.0, 1.0);
subplot(2, 1, 2);
plot(time, current);