User Tools

Site Tools


analysis:course:week10

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
analysis:course:week10 [2013/11/18 09:20]
mvdm [Estimating tuning curves]
analysis:course:week10 [2018/07/07 10:19] (current)
Line 1: Line 1:
-:!: This module is currently in progress, please do not use yet! Should be available on November 20 at the latest.+~~DISCUSSION~~
  
 ===== Spike train analysis II: tuning curves, encoding, decoding ===== ===== Spike train analysis II: tuning curves, encoding, decoding =====
Line 95: Line 95:
 </​code>​ </​code>​
  
-Next, we plot the spikes of a single cell (cell 5, which we met in the previous module) where the rat was when each spike was emitted:+Next, we plot the spikes of a single cell (cell 7, which we met in the previous module) where the rat was when each spike was emitted:
  
 <code matlab> <code matlab>
 % get x and y coordinate for times of spike % get x and y coordinate for times of spike
-iC = 5;+iC = 7;
 spk_x = interp1(Range(sd.x),​Data(sd.x),​Data(sd.S{iC}),'​linear'​);​ spk_x = interp1(Range(sd.x),​Data(sd.x),​Data(sd.S{iC}),'​linear'​);​
 spk_y = interp1(Range(sd.y),​Data(sd.y),​Data(sd.S{iC}),'​linear'​);​ spk_y = interp1(Range(sd.y),​Data(sd.y),​Data(sd.S{iC}),'​linear'​);​
Line 124: Line 124:
 spk_binned = ndhist(cat(1,​spk_x',​spk_y'​),​[SET_nxBins;​ SET_nyBins],​[SET_xmin;​ SET_ymin],​[SET_xmax;​ SET_ymax]); spk_binned = ndhist(cat(1,​spk_x',​spk_y'​),​[SET_nxBins;​ SET_nyBins],​[SET_xmin;​ SET_ymin],​[SET_xmax;​ SET_ymax]);
  
-imagesc(spk_binned'​) +imagesc(spk_binned'​); 
-axis xy; colorbar+axis xy; colorbar;
 </​code>​ </​code>​
  
Line 143: Line 143:
 tc = spk_binned./​(occ_binned .* (1./​VT_Fs));​ % firing rate is spike count divided by time tc = spk_binned./​(occ_binned .* (1./​VT_Fs));​ % firing rate is spike count divided by time
  
-pcolor(tc'​);​ shading flat +pcolor(tc'​);​ shading flat; 
-axis xy; colorbar; axis off+axis xy; colorbar; axis off;
 </​code>​ </​code>​
  
Line 176: Line 176:
 figure; figure;
 pcolor(tc'​);​ shading flat; axis off pcolor(tc'​);​ shading flat; axis off
-axis xy; colorbar+axis xy; colorbar;
 </​code>​ </​code>​
  
Line 205: Line 205:
 The key quantity to estimate is $P(\mathbf{n}|\mathbf{x})$,​ the probability of observing $n$ spikes in a given time window when the rat is at location $x$. At the basis of estimating this probability (the "​likelihood"​ or evidence) lies the tuning curve: this tells us the //average// firing rate at each location. We need a way to convert a given number of spikes -- whatever we observe in the current time window for which we are trying to decode activity, 3 spikes for cell 1 in the figure above -- to a probability. In other words, what is the probability of observing 3 spikes in a 250ms time window, given that for this location the cell fires, say at 5Hz on average? The key quantity to estimate is $P(\mathbf{n}|\mathbf{x})$,​ the probability of observing $n$ spikes in a given time window when the rat is at location $x$. At the basis of estimating this probability (the "​likelihood"​ or evidence) lies the tuning curve: this tells us the //average// firing rate at each location. We need a way to convert a given number of spikes -- whatever we observe in the current time window for which we are trying to decode activity, 3 spikes for cell 1 in the figure above -- to a probability. In other words, what is the probability of observing 3 spikes in a 250ms time window, given that for this location the cell fires, say at 5Hz on average?
  
-A convenient answer is to assume that the spike counts follow a Poisson distribution. Assuming this enables us to assign a probability to each possible spike count for a mean given by the tuning curve. Specifically,​ from the definition of the Poisson distribution,​ it follows that+A convenient answer is to assume that the spike counts follow a Poisson distribution. Assuming this enables us to assign a probability to each possible spike count for a mean given by the tuning curve. Specifically,​ from the [[http://​en.wikipedia.org/​wiki/​Poisson_distribution | definition of the Poisson distribution]], it follows that
  
 \[P(n_i|\mathbf{x}) = \frac{(\tau f_i(\mathbf{x}))^{n_i}}{n_i!} e^{-\tau f_i (x)}\] \[P(n_i|\mathbf{x}) = \frac{(\tau f_i(\mathbf{x}))^{n_i}}{n_i!} e^{-\tau f_i (x)}\]
  
-$f_i(\mathbf{x})$ is the average firing rate of neuron $i$ over $x$ (i.e. the tuning curve for position), $n_i$ is the number of spikes emitted by neuron $i$ in the current time window, and $\tau$ is the size of the time window used.+$f_i(\mathbf{x})$ is the average firing rate of neuron $i$ over $x$ (i.e. the tuning curve for position), $n_i$ is the number of spikes emitted by neuron $i$ in the current time window, and $\tau$ is the size of the time window used. Thus, $\tau f_i(\mathbf{x})$ is the mean number of spikes we expect from neuron $i$ in a window of size $\tau$; the Poisson distribution describes how likely it is that we observe the actual number of spikes $n_i$ given this expectation.
  
-In reality, place cell spike counts are typically not Poisson-distributed (Fenton et al. 1998) so this is clearly a simplifying assumption. There are many other, more sophisticated approaches for the estimation of $P(n_i|\mathbf{x})$ (see for instance ​Pillow ​et al. 2009) but this basic method works well for many applications.+In reality, place cell spike counts are typically not Poisson-distributed ([[http://​www.ncbi.nlm.nih.gov/​pubmed/​9501237 | Fenton et al. 1998]]) so this is clearly a simplifying assumption. There are many other, more sophisticated approaches for the estimation of $P(n_i|\mathbf{x})$ (see for instance ​[[http://​www.ncbi.nlm.nih.gov/​pubmed/​17925266 | Paninski ​et al. 2007]]) but this basic method works well for many applications.
  
 The above equation gives the probability of observing $n$ spikes for a given average firing rate for a single neuron. How can we combine information across neurons? Again we take the simplest possible approach and assume that the spike count probabilities for different neurons are independent. This allows us to simply multiply the probabilities together to give: The above equation gives the probability of observing $n$ spikes for a given average firing rate for a single neuron. How can we combine information across neurons? Again we take the simplest possible approach and assume that the spike count probabilities for different neurons are independent. This allows us to simply multiply the probabilities together to give:
Line 218: Line 218:
 e^{-\tau f_i (x)}\] e^{-\tau f_i (x)}\]
  
-An analogy here is simply to ask: if the probability of a coin coming up heads is 0.5, what is the probability of two coints, flipped simultaneously,​ coming up heads? If the coins are independent then this is simply 0.5*0.5.+An analogy here is simply to ask: if the probability of a coin coming up heads is $0.5$, what is the probability of two coints, flipped simultaneously,​ coming up heads? If the coins are independent then this is simply ​$0.5*0.5$.
  
 Combining the above with Bayes' rule, and rearranging a bit, gives Combining the above with Bayes' rule, and rearranging a bit, gives
Line 225: Line 225:
  
 This is more easily evaluated in vectorized MATLAB code. $C(\tau,​\mathbf{n})$ is a normalization factor which we simply set to guarantee $\sum_x This is more easily evaluated in vectorized MATLAB code. $C(\tau,​\mathbf{n})$ is a normalization factor which we simply set to guarantee $\sum_x
-P(\mathbf{x}|\mathbf{n}) = 1$ (Zhang et al. 1998). ​We assume that P(\mathbf{x}) (the "​prior"​) is uniform. +P(\mathbf{x}|\mathbf{n}) = 1$ (Zhang et al. 1998). ​For now, we assume that $P(\mathbf{x})(the "​prior"​) is uniform, that is, we have no prior information about the location of the rat and let our estimate be completely determined by the likelihood.
 === Preparing tuning curves for decoding === === Preparing tuning curves for decoding ===
  
Line 254: Line 253:
 tc(isinf(tc)) = NaN; tc(isinf(tc)) = NaN;
  
-pcolor(tc'​);​ shading flat +pcolor(tc'​);​ shading flat; 
-axis xy; colorbar; axis off+axis xy; colorbar; axis off;
 </​code>​ </​code>​
  
Line 415: Line 414:
 Initially, when the rat is moving around at the base of the maze (its actual position is indicated by the white ''​o''​),​ no decoding results will be shown because there are no cells active. However, after a few seconds the rat starts running up the stem of the maze, and some pixels in the plot will change color, indicating $P(\mathbf{x}|\mathbf{n})$,​ the "​posterior probability"​ that is the output of the decoding procedure. As you can see, the decoding seems to track the rat's actual location as it moves. Initially, when the rat is moving around at the base of the maze (its actual position is indicated by the white ''​o''​),​ no decoding results will be shown because there are no cells active. However, after a few seconds the rat starts running up the stem of the maze, and some pixels in the plot will change color, indicating $P(\mathbf{x}|\mathbf{n})$,​ the "​posterior probability"​ that is the output of the decoding procedure. As you can see, the decoding seems to track the rat's actual location as it moves.
  
-☛ No decoding is available for those bins where no neurons are active, because we manually set the posterior to zero. However, there also seem to be some frames in the animation where some neurons are active (as indicated in the title). What is the explanation for this?+☛ No decoding is available for those bins where no neurons are active, because we manually set the posterior to zero. However, there also seem to be some frames in the animation where some neurons are active (as indicated in the title), yet no decoded estimate is visible. What is the explanation for this?
  
 === Exporting the results to a movie file === === Exporting the results to a movie file ===
analysis/course/week10.1384784405.txt.gz · Last modified: 2018/07/07 10:19 (external edit)