User Tools

Site Tools


analysis:course-w16:week13

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-w16:week13 [2016/03/07 17:15]
mvdm [Diversion: the MATLAB profiler]
analysis:course-w16:week13 [2018/07/07 10:19] (current)
Line 1: Line 1:
 ~~DISCUSSION~~ ~~DISCUSSION~~
- 
-:!: **UNDER CONSTRUCTION,​ DO NOT USE YET** :!: 
  
 ===== Spike-field relationships:​ phase locking, phase precession, etc. ===== ===== Spike-field relationships:​ phase locking, phase precession, etc. =====
Line 22: Line 20:
 Local field potentials and related quantities such as the EEG ultimately result from the spatiotemporal summation of electrical currents across the cell membrane of neurons. Thus, in general, it is expected that spiking activity should be related to LFPs somehow. However, the exact nature of this relationship has proven to be far from trivial, and depends on many factors such as the three-dimensional arrangement of neurons, ion channel distributions,​ and more rapid dynamics arising from the interaction of multiple inputs. Accordingly,​ measures that characterize the relationship between spikes and LFPs have painted a surprisingly rich picture of how individual neurons participate in population- and systems-level activity (see e.g. Womelsdorf et al. 2005, Benchenane et al. 2010 and many others for striking examples). ​ Local field potentials and related quantities such as the EEG ultimately result from the spatiotemporal summation of electrical currents across the cell membrane of neurons. Thus, in general, it is expected that spiking activity should be related to LFPs somehow. However, the exact nature of this relationship has proven to be far from trivial, and depends on many factors such as the three-dimensional arrangement of neurons, ion channel distributions,​ and more rapid dynamics arising from the interaction of multiple inputs. Accordingly,​ measures that characterize the relationship between spikes and LFPs have painted a surprisingly rich picture of how individual neurons participate in population- and systems-level activity (see e.g. Womelsdorf et al. 2005, Benchenane et al. 2010 and many others for striking examples). ​
  
-A different, practical issue is that LFPs are susceptible to //volume conduction//,​ that is, they can be recorded some distance away from their source. The exact amount distance depends on numerous factors, but even intracranially in the rat the hippocampally-generated theta rhythm can be recorded several millimeters away in the cortex (Sirota et al. 2008). Thus, is is not a priori clear that a LFP recorded from a particular brain structure is generated there (is locally relevant) raising the possibility of attributing properties of the recording to the wrong site! One of the major ways to determine if a LFP is locally relevant is to establish if it is related to spiking activity, which as a fast and relatively local signal does not volume-conduct nearly as far.+A different, practical issue is that LFPs are susceptible to //volume conduction//,​ that is, they can be recorded some distance away from their source. The exact amount distance depends on numerous factors, but even intracranially in the rat the hippocampally-generated theta rhythm can be recorded several millimeters away in the cortex (Sirota et al. 2008), and gamma oscillations in the ventral striatal LFP [[ http://​biorxiv.org/​content/​early/​2017/​04/​13/​127126|originate in the nearby piriform cortex]]. Thus, is is not a priori clear that a LFP recorded from a particular brain structure is generated there (is locally relevant) raising the possibility of attributing properties of the recording to the wrong site! One of the major ways to determine if a LFP is locally relevant is to establish if it is related to spiking activity, which as a fast and relatively local signal does not volume-conduct nearly as far.
  
 In this module, we will examine basic measures of spike-field relationships useful for both approaches. In this module, we will examine basic measures of spike-field relationships useful for both approaches.
Line 146: Line 144:
 For a more sophisticated analysis of STAs, we move to FieldTrip. Since we now need to load not just LFPs, but also spikes, there are a few preliminaries to take care of first. For a more sophisticated analysis of STAs, we move to FieldTrip. Since we now need to load not just LFPs, but also spikes, there are a few preliminaries to take care of first.
  
-:!: For this section to work, you need to use the version of ''​read_mclust_t.m''​ that is in the ''​nsb2015''​ codebase, **NOT** the one in fieldtrip+:!: For this section to work, you need to use the version of ''​read_mclust_t.m''​ that is in the ''​neuraldata-w16''​ codebase, **NOT** the one in %%FieldTrip%%To do this, you can delete this file from the ''​fieldtrip\fileio\private''​ folder. ​
  
 Now we can load some LFPs and the spikes from this neuron. Ignore the usual warnings about timestamp mismatches arising from gaps in the LFP data. Now we can load some LFPs and the spikes from this neuron. Ignore the usual warnings about timestamp mismatches arising from gaps in the LFP data.
Line 167: Line 165:
 ''​data_all.labels''​ keeps track of what is what, with the indices matching those of ''​data_all.trial{1}''​. Recall that currently there is only one cell because by default, FieldTrip treats the entire recording as one "​trial"​. ​ ''​data_all.labels''​ keeps track of what is what, with the indices matching those of ''​data_all.trial{1}''​. Recall that currently there is only one cell because by default, FieldTrip treats the entire recording as one "​trial"​. ​
  
-Clearly, some precision about spike times is lost when converting spike times to this binarized format: as a result, spike times are now only known with a precision of 1/2000 s, rather than Neuralynx'​s native 0.1 us. However, when examining spike-field relationships for oscillations below 100Hz or so, 1/2000 is generally sufficient. FieldTrip has ways of maintaining full-precision spike representations explained in the spikefield tutorial, but for now we will use this fast and convenient method.+Clearly, some precision about spike times is lost when converting spike times to this binarized format: as a result, spike times are now only known with a precision of 1/2000 s, rather than Neuralynx'​s native 0.1 us. However, when examining spike-field relationships for oscillations below 100Hz or so, 1/2000 is generally sufficient. ​%%FieldTrip%% has ways of maintaining full-precision spike representations explained in the spikefield tutorial, but for now we will use this fast and convenient method.
  
 Let's compute and plot the STA for this neuron: Let's compute and plot the STA for this neuron:
Line 195: Line 193:
  
 <code matlab> <code matlab>
 +data.hdr.Fs = data.fsample;​
 +
 cfg = []; cfg = [];
 cfg.trialfun = '​ft_trialfun_lineartracktone2';​ cfg.trialfun = '​ft_trialfun_lineartracktone2';​
Line 212: Line 212:
 </​code>​ </​code>​
  
-Notice that the contents of ''​data_trl''​ now have multiple cells (88) corresponding to trials, rather than just one for the entire session as before.+Notice that the contents of ''​data_trl''​ now have multiple cells (88) corresponding to trials, rather than just one for the entire session as before. ​(Also, a more transparent trialification method can be seen in [[http://​ctnsrv.uwaterloo.ca/​vandermeerlab/​doku.php?​id=analysis:​course-w16:​week7|this module]].)
  
 Now, we can compute the STA for specific task segments, defined relative to task event time zero, the nosepokes into the reward receptacle: Now, we can compute the STA for specific task segments, defined relative to task event time zero, the nosepokes into the reward receptacle:
Line 236: Line 236:
 ☛ How does this pre-nosepoke STA compare to the non-restricted STA? Confirm your impressions by also computing and plotting a "​post-nosepoke"​ STA of equivalent window length. ☛ How does this pre-nosepoke STA compare to the non-restricted STA? Confirm your impressions by also computing and plotting a "​post-nosepoke"​ STA of equivalent window length.
  
-The spike artifact at time zero is going to cause us trouble later on. FieldTrip provides functionality for removing it:+The spike artifact at time zero is going to cause us trouble later on. %%FieldTrip%% provides functionality for removing it:
  
 <code matlab> <code matlab>
Line 347: Line 347:
 This results in: This results in:
  
-{{ :​analysis:​course:​week11_fig5.png?600 |}}+{{ :​analysis:​course-w16:sta_time.png?nolink&600 |}}
  
 This plot indicates that there is some phase-locking in the high theta range, which disappears from -0.5 seconds to about 0.5 seconds after the nosepoke, after which a complex pattern appears. Some of this may be due to chewing artifacts. This plot indicates that there is some phase-locking in the high theta range, which disappears from -0.5 seconds to about 0.5 seconds after the nosepoke, after which a complex pattern appears. Some of this may be due to chewing artifacts.
Line 371: Line 371:
  
 cfg            = []; cfg            = [];
-cfg.method ​    = '​ppc';​ % compute ​coherence; other measures of connectivity are also available+cfg.method ​    = '​ppc';​ % compute ​ppc; other measures of connectivity are also available
 fd             = ft_connectivityanalysis(cfg,​TFR_pre);​ fd             = ft_connectivityanalysis(cfg,​TFR_pre);​
  
Line 382: Line 382:
 This gives: This gives:
  
-{{ :​analysis:​course:​week11_fig6.png?600 |}}+{{ :​analysis:​course-w16:sta_time2.png?nolink&600 |}}
  
 As noted previously, the Fourier transform of the autocorrelation function of a LFP is related to the Fourier transform of the signal itself, and the Fourier transform of the cross-correlation function gives the cross-spectral density, the basis for the coherence measure that characterizes the degree to which two signals maintain a consistent phase relationship. Since we can compute the acf and ccf of spike trains, this means we can similarly compute a cross-spectral density between a spike train and a LFP. However, the spike spectrum does not maintain information about how many spikes were used to estimate it, and as a result the spike-field coherence is also subject to biases. The PPC method based on a separate FFT for each spike is the preferred current method. As noted previously, the Fourier transform of the autocorrelation function of a LFP is related to the Fourier transform of the signal itself, and the Fourier transform of the cross-correlation function gives the cross-spectral density, the basis for the coherence measure that characterizes the degree to which two signals maintain a consistent phase relationship. Since we can compute the acf and ccf of spike trains, this means we can similarly compute a cross-spectral density between a spike train and a LFP. However, the spike spectrum does not maintain information about how many spikes were used to estimate it, and as a result the spike-field coherence is also subject to biases. The PPC method based on a separate FFT for each spike is the preferred current method.
Line 391: Line 391:
  
 <code matlab> <code matlab>
-csc = myLoadCSC('​R016-2012-10-03-CSC02d.ncs'​)+LoadExpKeys
-cscR = Range(csc); cscD = Data(csc);​ +cfg = []; 
- +cfg.fc ​ExpKeys.goodTheta
-% filter in theta range +csc LoadCSC(cfg);
-Fs = 2000; +
-Wp = [ 6 10* 2 / Fs+
-Ws [ 4 12] * 2 / Fs+
-[N,​Wn] ​cheb1ordWp, Ws, 3, 20); % determine filter parameters +
-[b_c1,a_c1] = cheby1(N,​0.5,​Wn); % builds filter+
    
-csc_filtered ​filtfilt(b_c1,a_c1,cscD); +% filter in theta range 
-phi = angle(hilbert(csc_filtered));+cfg_f []; 
 +cfg_f.f = [6 10]; cfg_f.type = '​fdesign';​ 
 +cscF = FilterLFP(cfg,csc); 
 + 
 +phi = angle(hilbert(cscF.data));
 </​code>​ </​code>​
  
Line 408: Line 407:
  
 <code matlab> <code matlab>
-S = LoadSpikes({'​R016-2012-10-03-TT02_1.t'​});​ +S = LoadSpikes([]); 
-spk_t = Data(S{1}); +spk_phi = interp1(cscF.tvec,phi,S.t{1},'​nearest'​);​ 
-spk_phi = interp1(cscR,phi,spk_t,'​nearest'​);​ + 
 hist(spk_phi,​-pi:​pi/​18:​pi) hist(spk_phi,​-pi:​pi/​18:​pi)
 </​code>​ </​code>​
  
-As before, the phase histogram is non-uniform,​ indicating a spike-LFP relationship. Now we can plot phase as a function of position:+As before, the phase histogram is non-uniform,​ indicating a spike-LFP relationship. Now we can plot phase as a function of position, using the nice ''​scatterplotC''​ function:
  
 <code matlab> <code matlab>
-[Timestamps,​ X, Y, Angles, Targets, Points, Header] ​Nlx2MatVT('​VT1.nvt', ​[1 1 1 1 1 1], 1, 1, []); +pos LoadPos([]);
-Timestamps = Timestamps*10^-6;​ +
-toRemove = (X == 0 & Y == 0); +
-X = X(~toRemove);​ Y = Y(~toRemove);​ Timestamps = Timestamps(~toRemove);+
  
-spk_x = interp1(Timestamps,X,spk_t,'​linear'​);​ +spk_x = interp1(pos.tvec,getd(pos,'​x'​),S.t{1},'​linear'​);​ 
-spk_y = interp1(Timestamps,Y,spk_t,'​linear'​);​ +spk_y = interp1(pos.tvec,getd(pos,'​y'​),S.t{1},'​linear'​);​ 
- +  
-plot(X,Y,'​.','​Color',​[0.5 0.5 0.5],'​MarkerSize',​1);​ axis off; hold on;+plot(getd(pos,'​x'​),​getd(pos,'​y'​),'​.','​Color',​[0.5 0.5 0.5],'​MarkerSize',​1);​ axis off; hold on;
 h = scatterplotC(spk_x,​spk_y,​spk_phi,'​Scale',​[-pi pi],'​solid_face',​1,'​plotchar','​.'​);​ h = scatterplotC(spk_x,​spk_y,​spk_phi,'​Scale',​[-pi pi],'​solid_face',​1,'​plotchar','​.'​);​
 </​code>​ </​code>​
Line 435: Line 430:
  
 Each spike is now plotted according to where the rat was when it occurred, and the color indicates the theta phase. Note that there is a systematic phase change visible as the rat runs along the bottom edge of the track: this is the famous //theta phase precession//​ phenomenon characteristic of hippocampal place cells. Each spike is now plotted according to where the rat was when it occurred, and the color indicates the theta phase. Note that there is a systematic phase change visible as the rat runs along the bottom edge of the track: this is the famous //theta phase precession//​ phenomenon characteristic of hippocampal place cells.
 +
 +==== Challenges ====
 +
 +★ Apply one or more of the methods introduced in this module to your own data. Keep in mind that in these examples, we have related spikes (action potentials) to local field potentials; however, the idea of spike-field relationships can be generalized to relationships between any point process and any periodic time series data. For instance, the timing of behavioral responses may be systematically related to the phase of changes in say, pupil diameter. ​
 +
 +★ In this module we encountered a relationship between the spiking of hippocampal neurons and the theta rhythm. However, it is also thought that the spike timing of these neurons is related to low-gamma (~40-60 Hz) and high-gamma (~70-90 Hz) oscillations. Characterize this relationship using one or more of the methods used here. Good sessions with many hippocampal neurons include those from rats R050 and R064; the ''​ExpKeys''​ ''​GoodTheta''​ field also tends to have good gamma.
analysis/course-w16/week13.1457388914.txt.gz · Last modified: 2018/07/07 10:19 (external edit)