Math Insight

Video: Neural coding and decoding

Video links

This video is found in the pages

List of all videos

Transcript of video

An introduction to neural encoding and decoding

The simplest idea of neuronal encoding is how sensory neurons encode a stimulus. For example, there is a region of your brain, called the somatosensory cortex that is across the top of your head. Neurons in a particular location of the somatosensory cortex tend to become active when you touch something with the tip of your right forefinger. The approximate area of the brain is shown in this 3D view and in this cross section of the somatosensory cortex. If something touches your nose, neurons in another part of the somatosensory cortex tend to activate.

You can think of neural encoding as the way in which a stimulus (or some other external input or variable) is mapped into the corresponding activity patterns of neurons. If you touch your tongue, or hand, or back, these stimuli will lead to different neural activity patterns. Or, if you touch two spots at once, at least if the two points are sufficiently far apart, the activity pattern will be different from the pattern produced by being touched in just one spot. These different activity patterns are what will allow you to determine where you were touched and if you were touched in one spot or two spots.

In this way, touch stimuli are encoded in the somatosensory cortex. We could apply the same ideas to examine how other types of sensory stimuli are encoded. The details of a visual scene, such as locations, colors, shapes, and movement, are encoded by neurons in your visual cortex. The frequencies and locations of sounds are encoded by neurons in your auditory cortex. Smells and tastes and encoded by neurons in your olfactory and gustatory cortices. Signals having to do with your sense of balance are encoded by neurons in the cerebellum.

The brain can encode other information besides features of a stimulus. Another variable encoded by neural activity that we can observe experimentally is location. It turns out that there are neurons in a part of the brain called the hippocampus whose activity is highly correlated with one's location in an environment.

These neurons that encode location are called place cells. This picture illustrates place cell activity of eight neurons recorded while a rat moved along a track. The rat ran back and forth along this elevated track to get food rewards at each end. As the rat moved, the spikes of eight different neurons were recorded. When a neuron fired a spike, a colored dot was drawn at the location of the rat. The color of the dot represents which of the eight neurons spiked.

Notice how each neuron tends to fire a lot of spikes only when the rat is in a particular location, which we call the neuron's place field. We see that neuron 1, represented by the magenta dots, tends to fire when the rat is near the beginning of the track. Since we don't see many magenta dots further along the track, neuron 1 almost never fired when the rat was anywhere except at the beginning of the track. These magenta dots represent the place field of neuron 1.

The place field of neuron 2 is a little further down the track, as illustrated by the yellow dots. When the rat was in this location, neuron 2 tended to fire a lot of spikes. It was generally silent when the rat was elsewhere.

I numbered these neurons in the order where their place fields occurs. The different colored dots show the place fields of neurons 3, 4, 5, 6,7 and 8. The place fields represent how the neurons' activity encodes the rat's location.

If encoding is how an external variable is represented by neural activity, the idea of decoding is to go in the opposite direction. We observe neural activity and try to infer information about the stimulus, location, or other external variable.

Let's go back to the rat running along the track. Imagine that you cannot see the rat, but can only observe the spiking activity from the eight measured neurons. Your goal is to determine where the rat is.

While you are listening for neural activity, you detect a spike in neuron 5. Does that help you know where the rat is? It would seem neuron 5's spike should be evidence that the rat may be in neuron 5's place field. The spike suggests that the rat might be somewhere over here. But, how much evidence does that single spike observation give? How confident can we be that the rat is in neuron 5's place field? Think about what factors might make you more or less confident.

What if you observe not just one spike in neuron 5, but 3 spikes? Does that increase your confidence that the rat is in neuron 5's place field? What if you observe spikes in both neuron 4 and neuron 5? Maybe the rat is over here, in the location where the place fields of neurons 4 and 5 overlap.

However, what if you observe spikes in both neuron 5 and neuron 8? There doesn't appear to be any overlap in the place fields of neuron 5 and neuron 8? How can we interpret this observation?

Would your answer to any of these questions change if I told you that the rat spends 90% of its time near the ends of the track, either over here at the beginning or over here at the end. The rat races from one end of the track to the other, then hangs out at the end for awhile before racing back to the other end. Does that information change what you would infer from a single spike in neuron 5?

Let's try to quantify some of these questions in a simpler setting. Imagine this rectangle corresponds to the track and that we are observing a single neuron whose place field is on this part of the track. Let's say that we first conducted a bunch of experiments while simultaneously observing the rat's location and the neuron's activity in order to characterize this place field. Each experiment was an observation over a short period of time, let's say over a 10 ms window. And in such a window, you'd observe either 0 or 1 spike from the neuron.

The results of the experiments are as follows.

When the rat in the place field, the neuron has a 10% chance of firing a spike during a 10 ms window. When the rat is outside the place field, the neuron has a 1% chance of firing a spike during the window.

After these preliminary experiments, you run the real experiment. Now, you can observe only the spikes of the neuron but you cannot see the rat. To keep the math simple, we're going to analyze the data from each 10 ms window in isolation.

If, in one of these windows, you observe that the neuron spiked, what can you conclude about the likelihood of the rat being in the neuron's place field during that time window?

Is the likelihood that the rat is in the place field A. 10%, B. 1%, C. 90% of the time, or D., do you not have enough information?

Its answer might not be readily obvious from intuition alone. We can get more insight by formulating this question mathematically.

The first step is to define the events of the experiment so that we can mathematically represent their probabilities.

Let F be the event that the rat is in the neuron's place field. Let T be the event that the rat is anywhere else on the track outside the neuron's place field.

We'll denote the events involving the spike in a different manner. Let R be the number of spikes that the neuron fired in the 10 ms time window. Since we assume the neuron fired at most once in the window, there are only two possibilities for the value of R, which correspond to two events: the event R=1 that the neuron fired a spike, and the event R=0 that the neuron did not fire a spike in the window.

In the example, where I observed a spike and asked for the likelihood that the rat was in the place field, what probability was I asking for? Was it A. P(F), B. P(R=1, F), C. P(R=1|F), or D. P(F|R=1)?

Since we observed a spike, we are conditioning on the event R=1, and so would like to calculate D. P(F|R=1).

Which probabilities do we have from our initial experiments?

We observed that, when the rat was in the place field, the probability that a spike occurred was 10%, i.e., P(R=1 | F) = 0.1. We also observed that the probability of a spike dropped to 1% when the rat was outside the place field, i.e., P(R = 1| T) = 0.01.

It looks like we can use Bayes' Theorem to write down an expression for P(F|R=1) involving some of these observed probabilities. Pause the video to write down Bayes' Theorem and see if you get the answer that I do.

Bayes' theorem for our desired conditional probability is

P(F|R=1) = P(R=1|F) P(F)/P(R=1)

We are given P(R=1|F), but Bayes' theorem also depends on P(F), or the probability that the rat is in the place field without regard to the neuron's activity. We call this the prior probability of being in the place field. Without this prior probability, we have no way of estimating the probability of being in the place field conditioned on observing the spike.

For example, if the rat rarely dared venture away from the ends of the track and so rarely crossed through the place field, we'd get one answer. But, if for some reason, the rat enjoyed spending lots of time in the place field, we'd get a very different answer. Using Bayes' theorem is critically dependent on the prior probability P(F).

Bayes' theorem also contains the probability P(R=1) that the neuron fires a spike in any given window. We don't need additional data, though. If we have the prior probability P(F), along with the probabilities of spiking conditioned on being inside or outside the place field, we can calculate the spiking probability P(R=1).

In summary, if you have the prior probability of being in the place field, along with the spiking probabilities conditioned on the rat's location, you can use Bayes' theorem to make inferences about the rat's location from observations of the neuron's activity. We seem to be reading the rat's mind to determine where it is!