Acquisition and Analysis of Neural Data: Analytical Problem Set 1
Acquisition and Analysis of Neural Data: Analytical Problem Set 1
Please scan and upload your solution on Moodle as a single PDF file by the due date. Each student must submit their
own solution. Do not forget to write your name and to mention if you collaborated with someone. Please specify how
much time you needed to finish the exercise.
Convolution is used widely in mathematics, physics, and engineering, e.g., in signal processing and linear systems’
analysis. In neuroscience, it could be used to estimate firing rates from discrete spike times. With the following
exercises, you will get an intuitive understanding of the convolution operation.
(a) Sketch x(t − s) and h(s) as a function of s for a fixed, generic value of t. Identify the intervals of t where the
system has a stereotypical response. For each interval, sketch again x(t − s) and h(s) as a function of s.
R∞
(b) Compute the system’s response A(t) = −∞ x(t − s)h(s) ds and sketch the result.
where ∗ stands for convolution. Hint: use the definition of the convolution and change of variables.
Please upload your solution on Moodle by the due date. Return both a Python code file (or notebook) and a PDF file
including figures and code. Please use clear, descriptive variable names and comments. Each student must submit
their own files. Do not forget to write your name and to mention if you cooperated with someone. Please also indicate
how much time you needed to complete the exercise.
This .dat-file can be loaded in Python with the numpy function loadtxt(). The file contains a variable named Spike-
Times, which is a vector of spike times ti (in ms) with i = 1, 2, . . . , n in response to a stimulus with a duration of
T = 4000 ms. The temporal resolution of the spike times is 0.1 ms. Hint: it is convenient to convert the data in
seconds. Here, as in all other exercises, use numpy arrays and avoid loops as much as possible.
Your task is to estimate the firing rate with different methods. Hint: Your plots should be organized similar to Fig. 1.4
on page 12 of the Dayan and Abbott book.
(a) (1 point) Plot the raw spike train. Have a look at the pyplot function eventplot. You may need to set the axes
limits manually for correct visualization.
(b) (3 points) Construct spike-count histograms with non-overlapping bins of widths ∆t = 20, 50 and 150 ms, and
normalize them to obtain a firing rate in spikes/s. Hint: Have a look at the pyplot function hist and the weights
parameter.
(c) (5 points) Use the window functions defined below to estimate an approximate firing rate
n Z T
rapprox (t) = ∑ w(t − ti ) = dτ w(t − τ)ρ(τ)
i=1 0
where ρ(t) := ∑ni=1 δ(t − ti ) is the neural response function and T is the trial length. Hint: Have a look at
the analytical exercises on the convolution and the Dirac delta on this sheet. You can use the numpy function
convolve. Make sure you understand the differences between the convolution modes full and same, particularly
regarding time offsets and boundary effects. You could plot the spikes on top of the rates to check that you
obtained the correct time offset. Firing rates shall be plotted in units of spikes/s.
(i.) Estimate the rate with a rectangular window
(
1/∆t if − ∆t/2 ≤ τ < ∆t/2
w(τ) =
0 otherwise
with widths of ∆t = 20, 50 and 150 ms. The rectangular window is centered at each spike, i.e., the filtering
is non causal.
(ii.) Estimate the rate with a Gaussian window
τ2
1
w(τ) = √ exp − 2
2πσw 2σw
with σw = 10, 20 and 50 ms. Here the Gaussian is centered at each spike (non causal filtering).
(iii.) Estimate the rate with an alpha function
w(τ) = α2 τ exp(−ατ) +
where 1/α is a time scale and [x]+ is the half-wave rectification function. Use 1/α = 10, 20 and 50 ms.
Here the rate starts rising only after a spike is emitted, i.e., the filter is causal. Why would one want to use
a causal rather than a non-causal filter?
n 1 RT
(d) (1 point) Calculate the spike count-rate r = T = T 0 dt ρ(t) .
(a) (1 extra point) Estimate firing rates for the spike data in ExampleSpikeTimes2.dat to see if your code is flexible
enough to handle it. Spike timings are in milliseconds, the trial length is T = 10 s, and the resolution is 0.1 ms.
(b) (2 extra points) Download ExampleSpikeTimes3.dat and calculate first the trial-averaged neural response and
then the trial-averaged firing rate (only one convolution). You can use a filter of your choice. Load the data using
the numpy function loadtxt() with the keyword parameter delimiter=’;’. The file contains a matrix of spike times
in milliseconds. The dimensions are [m x n, where m=100 is the maximum spike-time index and n=1000 is the
number of trials. Note: each trial has a different number of spikes, the remaining entries are filled with nan. The
trial length is T = 1 s, the resolution is 0.1 ms.
Paula Kuokkanen Phone: 2093 98407 Email: paula.kuokkanen at hu-berlin.de Office: Haus 4, Room 107
Tiziano D’Albis Phone: 2093-98413 Email: tiziano.dalbis at hu-berlin.de Office: Haus 4, Room 013