To complete the tasks below, write Python scripts that will reproduce your results and the corresponding result figures when you run them next time. We recommend to use ipython with the pylab option. Comment your scripts ! Use your scripts for notes, e.g. on different parameters that you have used or observations you have made. Print each of your result figures to an image file (using the Python 'savefig' command) and incorporate them in your final protocol. Write an appropriate figure caption for each figure, which must be incorporated in the protocol; axes labels need dimension and units; figure captions should include all relevant parameter values of the respective analysis. You may write the figure captions after you have finished an exercise or a section and before you start with a new section and new exercises. Please number the tasks in your protocol and answer all questions. In the protocol, describe with few sentences what you did to achieve each of the tasks.
Exercises
You may choose to either complete the exercises 1.1. or, alternatively, the exercises 1.2. Both exercises deal with the time-resolved estimation of the neuronal firing rate.
Data
For firing rate estimation, I provide two files that contain output spike trains from a model neuron. The model neuron is a conductance-based leaky-integrate and fire neuron which includes a phenomenological model of spike frequency adaptation [2,8].
The model neuron adapts to changes in its input. The simulation data assumes that after 3s of spontaneous input the neuron receives an increased input (stimulus) which lasts for 2s (stimulus duration), before it returns to the spontaneous level. The input was modeled by a Poisson process realization, which followed an intensity that stepped from an initial low value to a much higher value after 3s (cf. Fig. 7a-c in [8]). The simulation was run with a time resolution of 0.1ms (corresponding to a sample frequency of 10kHz).
In [5]:
# Please choose the right path to the data and the dataset here
spikes_sfa_200 = loadtxt('data/SFA_reg_1.2q_200tau_mn.gdf')
spikes_sfa_400 = loadtxt('data/SFA_reg_1.5q_400tau_mn.gdf')
The PSTH is the classical tool for visualizing and analyzing time-varying firing rates of neurons (e.g. [3,4,1]).
In [11]:
data = spikes_sfa_200
print len(data), 'spikes have been recorded in total'
In [18]:
trial_n = data[:,0]
spike_times = data[:,1]
# you need to construct s from spike_times as described above.
# the ids are stored in the variable spike_times
Raster display: Your first task is to visualize the spike trains – one for each experimental trial – in a so-called 'raster display' or 'dot display'.
Design Figure 1 for 3 panels which are arranged in one column. Open a new figure and use the below command to open the top axes. For the raster diagram plot spike times (x-axis) against the corresponding trial numbers (y-axis) such that each spike is represented by either a single point or by a small vertical line element. Set the limits of the x-axis such that the full stimulus duration is covered.
In [3]:
subplot(3,1,1)
Out[3]:
In [ ]:
# you need to contruct binarray first
h, bins = numpy.histogram(s, binarray)
Visualize the PSTH in the second panel of Figure 1 using the pylab.bar
command (see below):
You can change settings of the bar plot by accessing the object b and using the 'setp' function. This way, you may for example change the properties of the bar histogram in order to generate a uniformly colored surface (cf. Appendix):
In [20]:
# Example Code
bins = arange(-3,4,1) #star,stop,step
dat = randn(1000)
#calculate the histogram
h, bins = numpy.histogram(dat, bins)
#plotting
b = bar(bins[0:h.size], h)
_ = setp(b, width=1)
In [21]:
# Aternatively, use hist to contruct the histogram and plot in one step
h,bins,_ = hist(dat, bins)