Math Insight

Neural decoding and mind reading project, part 2

Name:
Group members:
Section:
Total points: 30

A rat is wandering along a linear track, In its wanderings, the rat spends 50% of the time at the two ends of the track (evenly divided between the two ends) and spends the remaining 50% of the time being equally likely to be anywhere along the rest of the track.

During these wanderings, you record the spiking activity of different neurons. You find two neurons whose firing activity appears to be strongly modulated by the location of the rat along the track. You discover that these neurons are much more likely to fire when the rat is at certain locations along track. The goal of this project is to determine how well you can decode the rat's location by recording the neurons' spikes.

  1. Step 1: map from biology to math
    1. Divide the track into ten equally spaced regions, numbered from 1 to 10, where region 1 and region 10 are the two ends of the track. For $j=1,2, \ldots, 10$, let $A_j$ denote the event that the rat is in region $j$. We assume that the rat is in one those 10 regions.

      What is the probability that the rat is in each of the regions? In other words, determine each $P(A_j)$.

    2. You measure the spikes of neurons 1 and 2 in a 10 ms window. During this length of the time, you measure either 0 or 1 spikes. Let $R_1$ be the number of spikes recorded from neuron 1 and $R_2$ be the number of spikes recorded from neuron 2. Then, $R_1=1$ is the event that neuron 1 fired a spike, and $R_2=1$ is the event that neuron 2 fired a spike.

      By measuring the spiking activity while the rat is wandering the maze, you have determined that, when the rat is in most regions of the track, neuron 1 has about a 5% chance of firing in any 10 ms window. However, when the rat is in regions 3-5, the spiking probability is higher. During any 10 ms window, neuron 1 has a 10% chance of firing when the rat is in region 3, a 20% chance of firing when the rat is in region 4, and a 15% chance of firing when the rat is in region 5. Based on this information, determine the conditional probabilities $P(R_1=1 \,|\, A_j)$ of the event $R_1=1$, conditioned on the events $A_j$, for $j=1,2, \ldots, 10$.

    3. Similarly, you determine that neuron 2 has about a 1% chance of firing in a 10 ms window when the rat is in most regions of the track. Its firing probability is elevated in regions 5-7. During any 10 ms window, neuron 2 has a 4% chance of firing when the rat is in region 5, a 6% chance of firing when the rat is in region 6, and a 3% chance of firing when the rat is in region 7. Based on this information, determine the conditional probabilities $P(R_2=1 \,|\, A_j)$ of the event $R_2=1$, conditioned on the events $A_j$.

  2. Step 2: analyze the model
    1. As a first step toward decoding the rat's location from the spikes, determine the probability $P(R_1=1)$ that neuron 1 fires a spike in any 10 ms window. (We often refer to this as the marginal probability that $R_1=1$, as we are averaging over all locations $A_j$ for $j=1,2,\ldots, 10$.) Similarly, compute $P(R_2=1)$.

      You are welcome to do these computations by hand, though it would involve a lot of tedious calculations. An R program would greatly reduce the tedium, especially if you used vectors. Imagine, for example, that you created a vector P_A with 10 elements to store all the $P(A_j)$ and a vector P_R1_1_given_A with 10 elements to store all the $P(R_1=1 \,|\, A_j)$. Then, if for some reason, you wanted to multiply the first component of P_A (i.e., $P(A_1)$) with the first component of P_R1_1_given_A (i.e., $P(R=1 \,|\, A_1)$), do the same for all ten components, and then add the total up, you could do this in R with the command sum(P_A*P_R1_given_A). That's easier than computing 10 products by hand and then adding them up.

      If you calculate these quantities with an R script, you can turn in your script as a way to show your work for the calculations.

    2. Now that you computed $P(R_1=1)$ and you already know both $P(A_j)$ and $P(R_1=1 \,|\, A_j)$ for $j=1,2,\ldots, 10$, use Bayes' theorem 10 times (once for each value of $j$) to compute $P(A_j \,|\, R_1=1)$.

      Again, an R program could save you some tedious calculations. If you had two 10 element vectors v1 and v2, as well as a scalar (single number) u, then the expression v1*v2/u in R would result in a 10 element vector whose first element, for example, would be the first element of v1 times the first element of v2 divided by u.

    3. In a similar manner, use Bayes' theorem to compute $P(A_j \,|\, R_2=1)$.

  3. Step 3: interpret the model analysis biologically
    1. To decode the rat's location, we are primarily interested in three probability distributions over regions $A_j$: the prior distribution $P(A_j)$, the distribution of $A_j$ conditioned on a neuron 1 spike $P(A_j \,|\, R_1=1)$, and the distribution of $A_j$ conditioned on a neuron 2 spike $P(A_j \,|\, R_2=1)$. Sketch bar graphs of these probability distributions.

      In R, you can use the barplot to create these bar graphs. To make the labeling easy, you can create a vector of region names with the command region_names = paste("A", 1:10, sep="") (look at the variable region_names to see what the paste command did). If you created the vectors suggested above, then the following command will plot a bar graph of the prior distribution:

      barplot(P_A, col="darkgreen", names.arg=region_names, 
              ylab="Probability", main="Prior distribution", ylim=c(0,0.25))
      

      Here we made the maximum value of the $y$-axis be 0.25. You can adjust that number as you see fit. Similar commands will plot the remaining probability distributions.

    2. Let $E$ be the event that the rat is in one of the two end regions of the track (region 1 or 10). Without measuring a spike from any neuron, in which two regions is the rat mostly likely to be? What is the probability that the rat is in one of those two regions? Also, express that probability in symbols, in terms of the event $E$.

    3. If you measure a spike from neuron 1 in a 10 ms window, in which region(s) is the rat most likely to be? The most interesting one is the region that was not an endpoint. Let $B_1$ be the event that the rat is in that region or one of its neighboring regions on either side. What is $P(B_1 \,|\, R_1=1)$? Compare that proability to $P(E \,|\, R_1=1)$.

    4. If you measure a spike from neuron 2 in a 10 ms window, in which region is the rat most likely to be? Let $B_2$ be the event that the rat is in that region or one of its neighboring regions on either side. What is $P(B_2 \,|\, R_2=1)$? Compare that proability to $P(E \,|\, R_2=1)$.

    5. From which neuron can you better decode the rat's location? Justify your answer.

    6. What properties of that neuron lead to the better decoding? (Hint look at $P(R_1=1)$ and $P(R_2=1)$ compared to the probability of $R_1=1$ or $R_2=1$ when the rat is in the regions corresponding to $B_1$ or $B_2$.)

  4. Step 4: Decode from two neurons simultaneously
    1. If we assume that, when the rat is any particular region, the spikes of neuron 1 and neuron 2 are independent, then it's easy to determine the probability that both neurons spiked in a 10 ms window, conditioned on the rat being an region. For $j=1,2,\ldots, 10$, let $P(R_1=1, R_2=1 \,|\, A_j)$ denote the probability that both $R_1=1$ and $R_2=1$ when the rat is in region $j$. If the events $R_1=1$ and $R_2=1$ are independent in each region, then these probabilities are just the products of the probabilities of the individual spiking events: $$P(R_1=1, R_2=1 \,|\, A_j) = P(R_1=1 \,|\, A_j)P(R_2=1 \,|\, A_j).$$ Calculate the 10 probabilities $P(R_1=1, R_2=1 \,|\, A_j)$.

      Once you have calculated these ten probabilities, you can treat the event of the simultaneous spike $R_1=1$ and $R_2=2$ just like the individual events $R_1=1$ and $R_2=1$. In what follows, you'll just repeat the above calculations for these simultaneous spike events.

    2. Calculate the (marginal) probability of observing simultaneous spikes, $P(R_1=1,R_2=2)$. (The calculation should be exactly the same as for calculating $P(R_1=1)$, except that you use the 10 numbers $P(R_1=1,R_2=1 \,|\, A_j)$ instead of the 10 numbers $P(R_1=1 \,|\, A_j)$.)
    3. Use Bayes' theorem to decode that rat's position based on the measurement of simultaneous spikes in both neurons: $P(A_j \,|\, R_1=1, R_2=1)$. (Again, the calculation is exactly the same as for the $R_1=1$ case. Use Bayes' theorem in the same way. Don't be confused by the fact that the event $R_1=1, R_2=1$ looks more complicated that the event $R_1=1$. Just treat $R_1=1,R_2=1$ as a single event when using Bayes' Theorem.)
    4. Sketch a bar graph of the probability distribution $P(A_j \,|\, R_1=1,R_2=1)$.
    5. If you measure a spike from both neuron 1 and neuron 2 in a 10 ms window, in which region is the rat most likely to be? Let $B_3$ be the event that the rat is in that region or one of its neighboring regions on either side. What is $P(B_3 \,|\, R_1=1, R_2=1)$? Compare that probability to $P(E \,|\, R_1=1,R_2=1)$.
    6. From which measurement can you better decode the neuron's location: measurement of a spike in neuron 1, measurement of a spike in neuron 2, or measurement of simultaneous spikes in both neurons? Justify your answer.