Notes, assignments, and code for NEUROBIO 735 (Spring 2018).
1/10 – 2/8:
Wednesday, Thursday
3:00 – 4:30
DIBS conference room
Data recorded from (extracellular) single unit electrophysiology are typically recorded as time series of voltages, but one is typically only interested in the times at which action potentials occur. Thus, after spike detection and sorting, the resulting data are a list of timestamps for each putative neuron, which we’ll refer to as a unit. Data that come in the form of event timestamps are known as point process data, and this week, we’ll work on reproducing some standard methods for exploring and analyzing them.
This week’s data are available for download on GitHub. The data are recordings from three units in macaque frontal eye field (FEF) recorded by Tim Darlington in Lisberger Lab. The data are in Matlab’s own .mat
format and consist of three variables:
spikes
: a cell array in which each cell contains an array of spike timestamps (trials x units)H
and V
: horizontal and vertical eye positions (trials x time points)Often, we need to convert from a list of event times to a time series representation of the same data. For instance, rather than listing all times at which a spike occurred, we might want to know how many spikes occurred at each moment in time. That is, we’d like to make a histogram of spike counts using some small bin size.
Matlab used to have two histogram functions, hist
and histc
that overlapped in function and were called with different conventions. They still exist, but are being deprecated in favor of the newer, more unified, histcounts
and histogram
. The former produces counts, the latter plots.
To perform the conversion, we’ll start by taking only a small subset of the data, spikes for a single unit on a single trial, and converting that list to a time series.
Now that you have code that works on a single list, you can generalize to code that works on multiple trials and multiple units.
Once we have a pattern in code we know we’ll be repeating, it’s helpful to pull it into a function for several reasons:
spikes
variable, a minimum, and a maximum time, and return the same kind of spike count array as before.There are plenty of cases where we’d like to get spike counts over larger bins.
The most common plot in single unit electrophysiology is the peri-stimulus or peri-event time histogram (PSTH/PETH), which displays firing activity time-locked to some event of experimental importance. Most commonly, PSTHs are constructed as raster plots, in which each row represents one trial, time increases along the horizontal axis, and events are indicated by dots or tick marks.
With our array of spike counts in time, we have all we need to construct the simplest version of this plot. If we think of the first two dimensions of the count array (time and trial) as dimensions of an image, we can plot one image per unit by taking a slice of the count array and using plotting the result as pixels.
imagesc
scales the colormap to the range of data.)We might also like to compare spiking with behavior. We can use the subplot
command to make multipanel figures that facilitate comparisons between the two. Let’s make a figure with three rows and a single column that plot spiking, the horizontal, and the vertical eye positions as a function of time.
xlim
and ylim
to adjust for alignment and better readability.) Eye traces should all be plotted in the same color. Each panel should be titled.For plots we make often, it can be useful to repackage code into a function.