top of page

Rat Open Field Navigation: Spike Data

This dataset is from Trettel et al. (2019) (published open source on CRCNS). From the authors' description of the data:

"Data are rat's positional data and recordings obtained from superficial layers of the medial entorhinal cortex (layer II/III).  Data are for 6 rats, from 1-7 sessions each, in which each session contains two "tasks" across two days. The Open Field task required rats to randomly forage around a 100 x 100 cm arena for small cereal rewards."

They classified neurons as either grid cells, which have characteristic firing patterns that grid a contained space (see below), or as non-grid cells. The general idea here is to compare the grid cells and the non-grid cells.

cell1path-scaled1000.jpg

MATLAB Concepts Covered:

working with MATLAB structures, interpolating, making readable plots, iterating

Beginner Project: Plot the positions in an x-y space where grid cells and non-grid cells fired. Compare qualitatively.

1. Load in the data and examine the variables.

Load in the file called rat1.mat. There will be two variables: coords and unit.

coords: has three columns, with time in the first, x position in the second, and y position in the third.

What type of variable is this? (click for answer)

matrix of doubles

unit: has a row for each neuron, with each row containing three fields

  • ID: information about where the electrode was

  • type: grid cell (1) or non-grid cell (2)

  • spkTms: time points at which this neuron spiked

What type of variable is this? (click for answer)

structure (read MATLAB documentation here)

2. Get to know the data.

How many minutes long was the experiment? (click for answer)

20.4421 minutes

How many neurons were recorded from? (click for answer)

13 neurons

What were the rat's (x, y) coordinates one minute into the experiment? This isn't an actual point you can find in the coords array, so find the position at the time point closest to one minute. (click for answer)

(84.1772, 1.5308)

Click for hint.

Find how far each time point in coords is from 60 seconds (remember that it doesn't start at 0).

Potentially helpful Google keywords: minimum, absolute value

Predict the approximate (x, y) coordinates exactly two minutes into the experiment, using the time points that we do have. You can do this with one easy line of code! (click for answer)

(21.9934, 7.8751)

Click for hint.

Potentially helpful Google keywords: interpolation

3. Make a list of information you will need from your data.

Your ultimate goal is to make a plot like the one at the right, with the rat's trajectory traced in blue and the positions at the time the neuron fired in red. Let's start with just one grid cell, the first neuron listed in unit: what information do you need to make a plot like this?

plot1.png

Some of the information you need can be pulled straight from the data (i.e. x position), other information might be a little bit less obvious. Click for the full list of information that I came up with (not exhaustive - you may find other things useful!)

  • all time points

  • x position over time

  • y position over time

  • times at which the neuron fires

  • x position at the neuron's firing times

  • y position at the neuron's firing times

4. For each piece of information, create a variable with that information (either pull the information from the data directly or calculate it).

You should have all of the tools you'll need to create these variables! If you get stuck, look back at the questions in Part 2, or ask me for help. Start keeping track of your work in a script rather than working from the command line at this point. You can organize these variables in whatever way makes sense to you: [time x y] matrices, individual vectors, whatever is easiest to visualize.

5. Plot your data.

The plot() function in MATLAB is a bit finicky but quite flexible – you'll be able to make the entire plot using this function. Open up the documentation to get started. Below, I've listed the steps I took to create the plot shown in Part 3, along with some other parameters you can play around with to get comfortable with the plot() function.

  • Plot the trajectory of the rat over the full time course of the recording.

Can you make it a dotted line instead of a solid line?

Can you make it be black instead of blue?

  • Make sure that you won't erase this line when you plot the next thing with the command hold on.

  • Plot dots at the point where the neuron fired.

This is a little bit different than part I. If you get stuck, look under LineStyle in the documentation.

Can you make the points red?

  • Make your plot more readable – use Google to figure out how to do each of the following:

Add a title

Add x and y labels

Add a legend

Make sure that both the x and y axes are limited by 0 and 100

6. Make a for loop to make a plot like this for each neuron.

7. Test your code: does it work on another rat's data?

Make sure you make a new figure (by using the call figure) so that you don't overwrite your other figures. If you need a for loop refresher, look here.

What should your loop iterate through? (click for answer)

neurons (i.e. 1:13)

Load in the file called rat2.mat. Does your script work for this data as well? Places you might run into trouble are spots where you hard-coded numbers associated with the data (i.e. making a for loop that always goes to 13 instead of flexibly using whatever number of neurons are in a data file. If you run into these sorts of errors, commands like length() and size() might become useful.

Advanced Project Ideas

Familiarize yourself with the data structure from the info above. Then, try replicating some of the methods from Sargolini et al. (2006).

Create a rate map describing the firing rate of a neuron at different points in the open field.

"To characterize firing fields, the position data were sorted into bins of 3 x 3 cm^2 and the firing rate was determined for each bin. A spatial smoothing algorithm was used. The average rate in any bin x was estimated as:

(where g is a smoothing kernel, h is a smoothing factor, n is the number of spikes, si the location of the i-th spike, y(t) the location of the rat at time t, and [0, T] the period of the recording. A Gaussian kernel was used for g and h = 3. In order to avoid error from extrapolation, we considered positions more than 3 cm away from the tracked path as unvisited. [you could ignore this part from now] The peak rate was estimated as the highest firing rate observed in any bin of the smoothed rate map."

Try calculating the "gridness score" of each cell. This is a measure of periodicity, and many papers use either a gridness threshold or bootstrapped gridness statistics to classify cells as grid cells or non-grid cells.

"To determine whether the multiple firing fields of individual cells formed a grid structure, we calculated the spatial autocorrelation for the smoothed rate map of each cell. Autocorrelograms were based on Pearson’s product moment correlation coefficient with corrections for edge effects and unvisited locations. With λ(x, y) denoting the average rate of a cell at location (x, y), the autocorrelation between the fields with spatial lags of τx and τy was estimated as: 

 

 

where the summation is over all n pixels in λ(x, y) for which rate was estimated for both λ(x, y) and λ(x - τx, y - τy).

Screen Shot 2019-09-03 at 11.03.05 PM.pn
Screen Shot 2019-09-03 at 11.13.33 PM.pn
bottom of page