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 %%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%
\begin{questions} \begin{questions}
\question You are recording the activity of a neuron in response to \question An important property of sensory systems is their ability
two different stimuli $I_1$ and $I_2$ (think of them, for example, to discriminate similar stimuli. For example, to discriminate two
of two light intensities with different intensities $I_1$ and $I_2$ colors, light intensities, pitch of two tones, sound intensity, etc.
and the activity of a ganglion cell in the retina). Within an Here we look at the level of a single neuron. What does it mean that
observation time of duration $W$ the neuron responds stochastically two similar stimuli can be discriminated given the spike train
with $n$ spikes. 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 How well can an upstream neuron discriminate the two
stimuli based on the spike counts $n$? How does this depend on the 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 duration $T$ of the observation time?
(the ratio between the variance and the mean of the spike counts)?
The neuron is implemented in the file \texttt{lifadaptspikes.m}. The neuron is implemented in the file \texttt{lifspikes.m}.
Call it with the following parameters: Call it like this:
\begin{lstlisting} \begin{lstlisting}
trials = 10; trials = 10;
tmax = 50.0; tmax = 50.0;
input = 65.0; input = 15.0;
Dnoise = 0.1; spikes = lifspikes(trials, input, tmax);
adapttau = 0.2;
adaptincr = 0.5;
spikes = lifadaptspikes( trials, input, tmax, Dnoise, adapttau, adaptincr );
\end{lstlisting} \end{lstlisting}
The returned \texttt{spikes} is a cell array with \texttt{trials} The returned \texttt{spikes} is a cell array with \texttt{trials}
elements, each being a vector of spike times (in seconds) computed 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 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 neuron responds to this stimulus, and you record this
response. After detecting the time points of the spikes in your response. After detecting the time points of the spikes in your
recordings you get what the \texttt{lifadaptspikes()} function recordings you get what the \texttt{lifspikes()} function
returns. The advantage over real data is, that you have the returns.
possibility to simply modify the properties of the neuron via the
\texttt{Dnoise}, \texttt{adapttau}, and
\texttt{adaptincr} parameter.
For the two inputs $I_1$ and $I_2$ use For the two inputs $I_1$ and $I_2$ use
\begin{lstlisting} \begin{lstlisting}
input = 65.0; % I_1 input = 14.0; % I_1
input = 75.0; % I_2 input = 15.0; % I_2
\end{lstlisting} \end{lstlisting}
\begin{parts} \begin{parts}
\part \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 How do the histograms depend on the observation time $T$ (use
responses to the two different stimuli. How do they depend on the values of 10\,ms, 100\,ms, 300\,ms and 1\,s)?
observation time $W$ (use values between 1\,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 that quantifies how well the two stimuli can be distinguished
based on the spike counts. Plot the dependence of this measure as 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 \underline{Hint:} A possible readout is to set a threshold
$n_{thresh}$ for the observed spike count. Any response smaller $n_{thresh}$ for the observed spike count. Any response smaller
than the threshold assumes that the stimulus was $I_1$, any than the threshold assumes that the stimulus was $I_1$, any
response larger than the threshold assumes that the stimulus was response larger than the threshold assumes that the stimulus was
$I_2$. For a given $W$ find the threshold $n_{thresh}$ that $I_2$. For a given $T$ find the threshold $n_{thresh}$ that
results in the best discrimination performance. results in the best discrimination performance. How can you
quantify ``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.
\end{parts} \end{parts}

View File

@ -1,13 +1,12 @@
%% general settings for the model neuron: %% general settings for the model neuron:
trials = 10; trials = 10;
tmax = 50.0; tmax = 50.0;
D = 0.01;
%% generate and plot spiketrains for two inputs: %% generate and plot spiketrains for two inputs:
I1 = 14.0; I1 = 14.0;
I2 = 15.0; I2 = 15.0;
spikes1 = lifspikes(trials, I1, tmax, D); spikes1 = lifspikes(trials, I1, tmax);
spikes2 = lifspikes(trials, I2, tmax, D); spikes2 = lifspikes(trials, I2, tmax);
subplot(1, 2, 1); subplot(1, 2, 1);
tmin = 10.0; tmin = 10.0;
spikeraster(spikes1, tmin, tmin+2.0); spikeraster(spikes1, tmin, tmin+2.0);
@ -18,7 +17,7 @@ title(sprintf('I_2=%g', I2))
%savefigpdf(gcf(), 'spikeraster.pdf') %savefigpdf(gcf(), 'spikeraster.pdf')
%% spike count histograms: %% spike count histograms:
Ts = [0.01 0.1 0.5 1.0]; Ts = [0.01 0.1 0.3 1.0];
cmax = 100; cmax = 100;
figure() figure()
for k = 1:length(Ts) for k = 1:length(Ts)
@ -36,7 +35,7 @@ end
%% discrimination measure: %% discrimination measure:
T = 0.1; T = 0.1;
cmax = 20; cmax = 15;
[d, thresholds, true1s, false1s, true2s, false2s, pratio] = discriminability(spikes1, spikes2, tmax, T, cmax); [d, thresholds, true1s, false1s, true2s, false2s, pratio] = discriminability(spikes1, spikes2, tmax, T, cmax);
figure() figure()
subplot(1, 3, 1); subplot(1, 3, 1);
@ -45,6 +44,7 @@ hold on;
plot(thresholds, true2s, 'b'); plot(thresholds, true2s, 'b');
plot(thresholds, false1s, 'r'); plot(thresholds, false1s, 'r');
plot(thresholds, false2s, 'r'); plot(thresholds, false2s, 'r');
xlim([0 cmax])
hold off; hold off;
% Ratio: % Ratio:
subplot(1, 3, 2); subplot(1, 3, 2);
@ -57,7 +57,7 @@ plot(false2s, true1s);
%% discriminability: %% discriminability:
Ts = 0.01:0.01:1.0; Ts = 0.01:0.01:1.0;
cmax = 100; cmax = 100;
ds = zeros(length(Ts), 1) ds = zeros(length(Ts), 1);
for k = 1:length(Ts) for k = 1:length(Ts)
T = Ts(k); T = Ts(k);
[c1, b1] = counthist(spikes1, 0.0, tmax, T, cmax); [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. % Generate spike times of a leaky integrate-and-fire neuron.
% trials: the number of trials to be generated % trials: the number of trials to be generated
% input: the stimulus either as a single value or as a vector % input: the stimulus intensity
% tmaxdt: in case of a single value stimulus the duration of a trial % tmax: the duration of a trial
% in case of a vector as a stimulus the time step
% D: the strength of additive white noise % D: the strength of additive white noise
tau = 0.01; tau = 0.01;
@ -12,21 +11,18 @@ function spikes = lifspikes(trials, input, tmaxdt, D)
end end
vreset = 0.0; vreset = 0.0;
vthresh = 10.0; vthresh = 10.0;
D = 0.01;
dt = 5e-5; dt = 5e-5;
if max(size(input)) == 1 n = ceil(tmax/dt);
input = input * ones(ceil(tmaxdt/dt), 1);
else
dt = tmaxdt;
end
spikes = cell(trials, 1); spikes = cell(trials, 1);
for k=1:trials for k=1:trials
times = []; times = [];
j = 1; j = 1;
v = vreset + (vthresh-vreset)*rand(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) 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 if v >= vthresh
v = vreset; v = vreset;
spiketime = i*dt; spiketime = i*dt;