finished fano tim eproject

This commit is contained in:
Jan Benda 2017-01-21 12:20:24 +01:00
parent 52b7d39712
commit b874b62dde
3 changed files with 65 additions and 64 deletions

View File

@ -51,83 +51,88 @@
%%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%
\begin{questions}
\question You are recording the activity of a neuron in response to
two different stimuli $I_1$ and $I_2$ (think of them, for example,
of two light intensities with different intensities $I_1$ and $I_2$
and the activity of a ganglion cell in the retina). Within an
observation time of duration $W$ the neuron responds stochastically
with $n$ spikes.
\question An important property of sensory systems is their ability
to discriminate similar stimuli. For example, to discriminate two
colors, light intensities, pitch of two tones, sound intensity, etc.
Here we look at the level of a single neuron. What does it mean that
two similar stimuli can be discriminated given the spike train
responses that have been evoked by the two stimuli?
You are recording the activity of a neuron in response to two
different stimuli $I_1$ and $I_2$ (think of them, for example, of
two light intensities with different intensities $I_1$ and $I_2$ and
the activity of a ganglion cell in the retina). The neuron responds
to a stimulus with a number of spikes. You (an upstream neuron) can
count the number of spikes of this response within an observation
time of duration $T$. For perfect discrimination, the number of
spikes evoked by the stronger stimulus within $T$ is larger than for
the smaller stimulus. The situation is more complicated, because the
number of spikes evoked by one stimulus is not fixed but varies.
How well can an upstream neuron discriminate the two
stimuli based on the spike counts $n$? How does this depend on the
duration $W$ of the observation time? How is this related to the fano factor
(the ratio between the variance and the mean of the spike counts)?
duration $T$ of the observation time?
The neuron is implemented in the file \texttt{lifadaptspikes.m}.
Call it with the following parameters:
The neuron is implemented in the file \texttt{lifspikes.m}.
Call it like this:
\begin{lstlisting}
trials = 10;
tmax = 50.0;
input = 65.0;
Dnoise = 0.1;
adapttau = 0.2;
adaptincr = 0.5;
spikes = lifadaptspikes( trials, input, tmax, Dnoise, adapttau, adaptincr );
input = 15.0;
spikes = lifspikes(trials, input, tmax);
\end{lstlisting}
The returned \texttt{spikes} is a cell array with \texttt{trials}
elements, each being a vector of spike times (in seconds) computed
for a duration of \texttt{tmax} seconds.
for a duration of \texttt{tmax} seconds. The intensity of the stimulus
is given by \texttt{input}.
Think of calling the \texttt{lifadaptspikes()} function as a
Think of calling the \texttt{lifspikes()} function as a
simple way of doing an electrophysiological experiment. You are
presenting a stimulus with a constant intensity $I$ that you set. The
presenting a stimulus with an intensity $I$ that you set. The
neuron responds to this stimulus, and you record this
response. After detecting the timepoints of the spikes in your
recordings you get what the \texttt{lifadaptspikes()} function
returns. The advantage over real data is, that you have the
possibility to simply modify the properties of the neuron via the
\texttt{Dnoise}, \texttt{adapttau}, and
\texttt{adaptincr} parameter.
response. After detecting the time points of the spikes in your
recordings you get what the \texttt{lifspikes()} function
returns.
For the two inputs $I_1$ and $I_2$ use
\begin{lstlisting}
input = 65.0; % I_1
input = 75.0; % I_2
input = 14.0; % I_1
input = 15.0; % I_2
\end{lstlisting}
\begin{parts}
\part
Show two raster plots for the responses to the two different stimuli.
Show two raster plots for the responses to the two different
stimuli. Find an appropriate time window and an appropriate
number of trials for the spike raster.
Just by looking at the raster plots, can you discriminate the two
stimuli? That is, do you see differences between the two
responses?
\part Generate properly normalized histograms of the spike counts
within $T$ (use $T=100$\,ms) of the responses to the two different
stimuli. Do the two histograms overlap? What does this mean for
the discriminability of the two stimuli?
\part Generate histograms of the spike counts within $W$ of the
responses to the two different stimuli. How do they depend on the
observation time $W$ (use values between 1\,ms and 1\,s)?
How do the histograms depend on the observation time $T$ (use
values of 10\,ms, 100\,ms, 300\,ms and 1\,s)?
\part Think about a measure based on the spike count histograms
\part Think about a measure based on the spike-count histograms
that quantifies how well the two stimuli can be distinguished
based on the spike counts. Plot the dependence of this measure as
a function of the observation time $W$.
a function of the observation time $T$.
For which observation times can the two stimuli perfectly discriminated?
For which observation times can the two stimuli perfectly
discriminated?
\underline{Hint:} A possible readout is to set a threshold
$n_{thresh}$ for the observed spike count. Any response smaller
than the threshold assumes that the stimulus was $I_1$, any
response larger than the threshold assumes that the stimulus was
$I_2$. For a given $W$ find the threshold $n_{thresh}$ that
results in the best discrimination performance.
\part Also plot the Fano factor as a function of $W$. How is it
related to the discriminability?
\uplevel{If you still have time you can continue with the
following question:}
\part You may change the two stimuli $I_1$ and $I_2$ and the
intrinsic noise of the neuron via \texttt{Dnoise} (change it in
factors of ten, higher values will make the responses more
variable) and repeat your analysis.
$I_2$. For a given $T$ find the threshold $n_{thresh}$ that
results in the best discrimination performance. How can you
quantify ``best discrimination'' performance?
\end{parts}

View File

@ -1,13 +1,12 @@
%% general settings for the model neuron:
trials = 10;
tmax = 50.0;
D = 0.01;
%% generate and plot spiketrains for two inputs:
I1 = 14.0;
I2 = 15.0;
spikes1 = lifspikes(trials, I1, tmax, D);
spikes2 = lifspikes(trials, I2, tmax, D);
spikes1 = lifspikes(trials, I1, tmax);
spikes2 = lifspikes(trials, I2, tmax);
subplot(1, 2, 1);
tmin = 10.0;
spikeraster(spikes1, tmin, tmin+2.0);
@ -18,7 +17,7 @@ title(sprintf('I_2=%g', I2))
%savefigpdf(gcf(), 'spikeraster.pdf')
%% spike count histograms:
Ts = [0.01 0.1 0.5 1.0];
Ts = [0.01 0.1 0.3 1.0];
cmax = 100;
figure()
for k = 1:length(Ts)
@ -36,7 +35,7 @@ end
%% discrimination measure:
T = 0.1;
cmax = 20;
cmax = 15;
[d, thresholds, true1s, false1s, true2s, false2s, pratio] = discriminability(spikes1, spikes2, tmax, T, cmax);
figure()
subplot(1, 3, 1);
@ -45,6 +44,7 @@ hold on;
plot(thresholds, true2s, 'b');
plot(thresholds, false1s, 'r');
plot(thresholds, false2s, 'r');
xlim([0 cmax])
hold off;
% Ratio:
subplot(1, 3, 2);
@ -57,7 +57,7 @@ plot(false2s, true1s);
%% discriminability:
Ts = 0.01:0.01:1.0;
cmax = 100;
ds = zeros(length(Ts), 1)
ds = zeros(length(Ts), 1);
for k = 1:length(Ts)
T = Ts(k);
[c1, b1] = counthist(spikes1, 0.0, tmax, T, cmax);

View File

@ -1,9 +1,8 @@
function spikes = lifspikes(trials, input, tmaxdt, D)
function spikes = lifspikes(trials, input, tmax)
% 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
% tmaxdt: in case of a single value stimulus the duration of a trial
% in case of a vector as a stimulus the time step
% input: the stimulus intensity
% tmax: the duration of a trial
% D: the strength of additive white noise
tau = 0.01;
@ -12,21 +11,18 @@ function spikes = lifspikes(trials, input, tmaxdt, D)
end
vreset = 0.0;
vthresh = 10.0;
D = 0.01;
dt = 5e-5;
if max(size(input)) == 1
input = input * ones(ceil(tmaxdt/dt), 1);
else
dt = tmaxdt;
end
n = ceil(tmax/dt);
spikes = cell(trials, 1);
for k=1:trials
times = [];
j = 1;
v = vreset + (vthresh-vreset)*rand(1);
noise = sqrt(2.0*D)*randn(length(input), 1)/sqrt(dt);
noise = sqrt(2.0*D)*randn(n, 1)/sqrt(dt);
for i=1:length(noise)
v = v + (- v + noise(i) + input(i))*dt/tau;
v = v + (- v + noise(i) + input)*dt/tau;
if v >= vthresh
v = vreset;
spiketime = i*dt;