diff --git a/plotstyle.py b/plotstyle.py index add3e40..eb04d7d 100644 --- a/plotstyle.py +++ b/plotstyle.py @@ -282,7 +282,7 @@ def axis_label(label, unit=None): if not unit: return label elif xkcd_style: - return '%s/%s' % (label, unit) + return '%s (%s)' % (label, unit) else: return '%s [%s]' % (label, unit) diff --git a/pointprocesses/exercises/pointprocesses-1.tex b/pointprocesses/exercises/pointprocesses-1.tex index a27704c..7b28e6a 100644 --- a/pointprocesses/exercises/pointprocesses-1.tex +++ b/pointprocesses/exercises/pointprocesses-1.tex @@ -158,20 +158,25 @@ \question \qt{Statistics of spike counts} Now let's have a look at the statistics of the spike counts. \begin{parts} - \part Write a function that counts and returns a vector with the - number of spikes in windows of a given width $W$. + \part \label{counts} Write a function that counts with the number + of spikes in windows of a given width $W$. The spikes are passed + to the function as a cell array containing vectors of spike times. + The function returns a single vector with all the spike counts. + \begin{solution} + \lstinputlisting{counts.m} + \end{solution} - Use this function to generate a properly normalized histogram of - spike counts for the data of the three types of neurons. Use - 100\,ms for the window width. + \part Generate a properly normalized histogram of spike counts for + the data of the three types of neurons. Use 100\,ms for the window + width and the function from (\ref{counts}) for computing the spike + counts. - Compare the distributions with the Poisson distribution expected - for a Poisson spike train: + In addition, compare the distributions with the Poisson + distribution expected for a Poisson spike train: \[ P(k) = \frac{(\lambda W)^ke^{\lambda W}}{k!} \; , \] where $\lambda$ is the rate of the spike train that you should estimate from the data. \begin{solution} - \lstinputlisting{counts.m} \newsolutionpage \lstinputlisting{spikecountshists.m} \colorbox{white}{\includegraphics[width=1\textwidth]{spikecountshists}} diff --git a/pointprocesses/exercises/psth.tex b/pointprocesses/exercises/psth.tex index a9ff599..4cabcf4 100644 --- a/pointprocesses/exercises/psth.tex +++ b/pointprocesses/exercises/psth.tex @@ -14,13 +14,27 @@ \input{../../exercisestitle} \begin{questions} + \question The dataset \code{lifoustim.mat} contains the responses of a (model) neuron to a time-varying stimulus. + The dataset stores three variables: 1st the spike times in different trials, + 2nd the stimulus, and 3rd the temporal resolution of the recording. The total + duration of each trial is 30 seconds. + + \question{} Some trials are different than the others. + \begin{parts} + \part Use a rasterplot to identify them. In which sense + are they different? + \part Extend your program that it saves the figure with the width and height of 8.5\,cm using a fontsize of 10\,pt for labels. + See Chapter 3 in the script, or browse the Matlab help for more + information. Store the figure in pdf format. + + \part Identify those trials in which the spike count + deviates more than $2\sigma$ (twice the standard deviation) from the average. + \end{parts} + \question Plot the time-dependent firing rate of a neuron. Calculate the firing rate from the \emph{instantaneous firing rate} (based on the - interspike interval). Use the \code{lifoustim.mat}. The dataset - contains three variables. 1st the spike times in different trials, - 2nd the stimulus, and 3rd the temporal resolution of the recording. The total - duration of each trial is 30 seconds. + interspike interval). \begin{parts} \part Write a function that takes three arguments: the spike @@ -29,26 +43,18 @@ time-dependent firing rate. \part Write a script that applies the above function to estimate the time-dependent firing rate of each trial. Plot the firing rates of the individual responses - and the average response as a function of time into the same graph. - \part Extend your program that it saves the figure with the width and height of 8.5\,cm using a fontsize of 10\,pt for labels. - See Chapter 3 in the script, or browse the Matlab help for more - information. Store the figure in pdf format. + and the average response as a function of time into the same graph. Save the figure in pdf + format. Use the same figure specifications as above and make sure it is properly labeled. \end{parts} - \question{} As before but use the binning method. + \question{} As before but estimate the "PSTH" using the binning method. \question{} Extend your script that it also plots the interspike interval histogram and the distribution of spike counts into separate figures. Save the figures to file using the pdf format. You may also choose to use subplots instead of individual figures. + - \question{} Some trials are different than the others. - \begin{parts} - \part Use a rasterplot to identify them. In which sense - are they different? Save the rasterplot in pdf - format. Use the same figure specifications as above and make sure it is properly labeled. - \part Identify those trials in which the spike count - deviates more than $2\sigma$ (twice the standard deviation) from the average. - \end{parts} + \end{questions} \end{document} diff --git a/pointprocesses/lecture/rasterexamples.py b/pointprocesses/lecture/rasterexamples.py index 7a9f4f0..3bc6ea5 100644 --- a/pointprocesses/lecture/rasterexamples.py +++ b/pointprocesses/lecture/rasterexamples.py @@ -69,7 +69,9 @@ def plot_homogeneous_spikes(ax): ax.set_title('stationary') ax.set_xlim(0.0, duration) ax.set_ylim(-0.5, trials-0.5) - ax.set_xlabel('Time [s]') + ax.set_xticks([0, 1, 2]) + ax.set_yticks(np.arange(0, trials+1, 5)) + ax.set_xlabel('Time', 's') ax.set_ylabel('Trial') ax.eventplot(homspikes, colors=[lsA['color']], linelength=0.8, lw=1) @@ -79,14 +81,16 @@ def plot_inhomogeneous_spikes(ax): ax.set_title('non-stationary') ax.set_xlim(0.0, duration) ax.set_ylim(-0.5, trials-0.5) - ax.set_xlabel('Time [s]') - ax.set_ylabel('Trial') + ax.set_xticks([0, 1, 2]) + ax.set_yticks(np.arange(0, trials+1, 5)) + ax.set_xlabel('Time', 's') + #ax.set_ylabel('Trial') ax.eventplot(inhspikes, colors=[lsA['color']], linelength=0.8, lw=1) if __name__ == "__main__": fig, (ax1, ax2) = plt.subplots(1, 2) - fig.subplots_adjust(**adjust_fs(fig, left=4.0, right=1.0, top=1.2)) + fig.subplots_adjust(**adjust_fs(fig, left=5.0, right=1.0, top=1.2)) plot_homogeneous_spikes(ax1) plot_inhomogeneous_spikes(ax2) plt.savefig('rasterexamples.pdf')