Title: Chronux Tutorial: Part I
1Chronux Tutorial Part I
- Hemant Bokil
- Cold Spring Harbor Laboratory
2 People
Hemant Bokil
Catherine Loader
Partha Mitra
Peter Andrews
Contributors Dan Hill Chris
Fall Samar Mehta Hirak Parikh Andrew
Sornborger
3Outline
- Introduction to Chronux
- ? Aim
- ? Website
- ? Download
- ? Documentation
- ? Key functions
- Analysis of LIP data - Example 2 of the previous
talk rates, spike and LFP spectra and
coherences, coherences between cells - Analysis protocol
- F-test for line noise
4Chronux Aim
To provide a comprehensive set of tools for the
analysis of neurobiological time series data
5Current version
Spectral analysis
Locfit local regression and likelihood based
analyses
MATLAB Toolboxes
Spike sorting
- Univariate and multivariate time series data.
- Continuous data (e.g. LFPs) and point process
data (e.g. spikes). - Multiple modalities Image data (examples in
Chris Falls talk) - Extensive online and within-Matlab help
- GUI under active development, release in a few
months
6Website (www.chronux.org)
7Documentation
8Key routines for continuous processesDenoising
Slow variations (e.g. movements of a patient for
EEG data)
50/60 Hz line noise
locdetrend.m Loess method
rmlinesc.m rmlinesmovingwinc.m
9Spectra, Coherences etc
Fourier transforms using multiple tapers mtfftc.m
Spectrum mtspectrumc.m
Coherencymtcoherencyc.m
Spectrogram mtspecgramc.m
Coherogrammtcohgramc.m
Local regression and likelihood
Regression and likelihood locfit.m
Plotting the fit lfplot.m
Plotting local confidence bands lfband.m
Plotting global confidence bands scb.m
10Chronux data format
- Continuous/binned point process data
- matrices with dimension time x
channels/trials - e.g. 1000 x 10 dimensional
matrix - interpreted as 1000
samples - 10 channels/trials
- Spikes times
- struct array with dimension number of
channels/trials - e.g. data(1).times0.3 0.35
0.42 0.6 - data(2).times0.2 0.22
0.35 - 2 spike trains with 4 and 3
spikes
11Important parameter in mulitple Chronux functions
- params structure with multiple fields
- Fs sampling frequency (slightly different
interpretation for spike times - tapers controls the number of tapers
- pad controls the padding
- fpass frequency range of interest
- err controls error computation
- trialave controls whether or not to average
over trials -
12Example II Spike rates, spectra and coherence
(from the previous lecture)
- Simultaneous two-cell recording from Macaque area
LIP dataset DynNeuroLIP.mat
Reach and Saccade
Delay
Cue
Delay
Cue
Reach and Saccade Task
Pesaran et al (Unpublished)
13Example II
- 3 local field potentials (LFP) and 2 single
units, LFP sampled at 1 kHz - Trial 3 seconds of data for 9 trials to one of
the - directions
- 1 s (Baseline), 2 s (Delay post movement)
- Baseline 1 second of data for 74 trials (pooled
- across all directions)
14Tasks
- Compute the following for the Memory trials
- Spike rates
- LFP and spike spectra
- Spike-field coherence
- Spike-Spike coherence
Compare spike-spike coherence during the memory
period and the baseline period.
15The main script for this tutorial lip_master_scri
pt.m Calls other scripts to run through the
various analyses
16The main script for this tutorial lip_master_scri
pt.m Calls other scripts to run through the
various analyses
17Spike rate 1 trial Basic locfit usage (rate
estimate)
gtgt fitlocfit(data,'family','rate') gtgt
lfplot(fit) gtgt lfband(fit)
Density estimate replace 'rate by dens
Regression gtgt fitlocfit(x,y)
18Setting the bandwidth fixed (h), nearest
neighbor (nn)
h fixed/absolute bandwidth e.g. h1 is
interpreted as 1 s if data is in seconds
nn fixed fraction of the total number of points
e.g. nn0.3 takes the 30 closest points to a
given point Default nn0.7, h0
gtgt fitlocfit(data,'family','rate,nn,0.3) gtgt
lfplot(fit) gtgt lfband(fit)
19 Multiple trials pool the spikes and
compute fit rescale fits and confidence intervals
20LFP spectrum mtspectrumc.m
gtgtS,fmtspectrumc(data) gtgt plot(f,10log10(S))
S spectrum f frequency
21Sampling frequency
Set params.Fs Default 1
gtgtparams.Fs1000 gtgtS,fmtspectrumc(data,params)
gtgt plot_vector(S,f)
plot_vector Allows plotting errors and choice
of color and scale (default log scale for
S) gtgt plot_vector(S,f,n) Uses linear
scale for S
22Restricting frequencies of interest
Set params.fpass Default 0 params.Fs/2
gtgtparams.Fs1000 gtgtparams.fpass0
100 gtgtS,fmtspectrumc(data,params) gtgt
plot_vector(S,f)
23Changing the padding
Set params.pad Default0
Allowed values -1 0 1 2
... For N500, NFFT 500 512 1024 2048
Default 0
gtgt params.pad2 gtgtS,fmtspectrumc(data,params)
gtgt plot_vector(S,f)
24Smoothing (changing the bandwidth)
- Set params.tapers of the form TW K
- Default 3 5
- TW time-bandwidth product
- Klt2TW well concentrated
- Slepian sequences
gtgtparams.tapers5 9 gtgtS,fmtspectrumc(data,pa
rams) gtgt plot_vector(S,f,,,r)
25Averaging over trials
Set params.trialave1
gtgt params.trialave1 gtgtS,fmtspectrumc(data,par
ams) gtgt plot_vector(S,f)
Note computing the spectrum separately for each
trial and averaging will work for the spectrum,
but not for the Jackknife error bars
26Errors
params.err 1 p
params.err2 p Jackknife
Set params.err
Serr (1-p) confidence interval of S
gtgtp0.05 gtgtparams.err1 p gtgtS,f,Serrmtspect
rumc(data,params) gtgtplot_vector(S,f,,Serr) gtgt
hold on
gtgtp0.05 gtgtparams.err2 p gtgtS,f,Serrmtspect
rumc(data,params) gtgtplot(f,10log10(Serr(1,)),r
) gtgtplot(f,10log10(Serr(2,)),r)
27Spike spectrum
mtspectrumpt.m
gtgtparams.err1 p gtgtS,f,R,Serrmtspectrumpt(da
ta,params)
28Spectrogram mtspecgramc
Set duration and step size of moving
windowmovingwin
gtgt movingwin0.5 0.05 gtgt S,t,fmtspecgramc(da
ta,movingwin,params)
29Spike spectrogram mtspecgrampt.m
gtgtS,t,f,Rmtspecgrampt(data,movingwin,params)
30Coherence between LFP and spikes
coherencycpt.m
gtgtparams.err1 p gtgtC,phi,S12,S1,S2,f,zerosp,co
nfC,phistdcoherencycpt(datalfp, datasp,params)
C coherence Phi phase confC
Probability(CgtconfC)p phistd
asymptotic standard deviation of phase
31Coherence between cells
coherencypt.m
gtgt params.err2 p gtgt C,phi,S12,S1,S2,f,zerosp
,confC,phistd,Cerrcoherencypt(datasp1,
datasp2,params)
Phistd Jackknifed standard deviation of the
phase Cerr (1-p) confidence intervals for C
32Comparison of coherences and spectra
- Two experimental conditions with unequal number
of trials - Coherence and spectral estimates are biased and
the bias depends on sample size - Would like a simple hypothesis test with a
corresponding p value
Bokil et al., J Neurosci Methods. 2006 Aug 28
33Comparison of coherences and spectra
- If ztanh-1 (C)
- E(z)tanh-1(Cpop)1/(2m-2)
- V(z)?(m)
Null hypothesis C1,popC2,pop ? zN(0,1)
Bokil et al., J Neurosci Methods. 2006 Aug 28
34Chronux code for comparing coherences
dz,vdz,Adztwo_group_test_coherence(J1c1,J2c1,J1
c2,J2c2,p,'y',f)
Fourier transforms
Bokil et al, 2006
35Electrophysiology Analysis Protocol
36Electrophysiolgy Data Conditioning
37Removing 50/60 Hz
N samples X1, X2, , XN
Model X(t)a cos(2?f0t?)?(t)
Potential Method Least squares
- ?(t) is non-white in general
- non-linear in f0 and ?
38Thomsons F testIdea Equation can be
transformed to a linear regression in frequency
Notice
39Thomsons F test
- Multiply both sides by kth Slepian sequence ukn
and Fourier transform
40Thomsons F-test
Used in touch-tone phones to detect the key