8 purpura short course syllabus

Upload: kuldeep00ei32

Post on 06-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 8 Purpura Short Course Syllabus

    1/13

    2008 Purpura

    Neural Signal Processing: Tutorial 1

    Kih P. Purpura, PhD1 and Hman Bkil, PhD21Department o Neurology and Neuroscience, Weill Cornell Medical College

    New York, New York2Cold Spring Harbor LaboratoryCold Spring Harbor, New York

  • 8/2/2019 8 Purpura Short Course Syllabus

    2/13

  • 8/2/2019 8 Purpura Short Course Syllabus

    3/13

    67

    NoteS

    2008 Purpura

    Nural Signal Prcssing: turial 1

    IntroductionIn this chapter, we will work through a number oexamples o analysis that are inspired in part by a ew

    o the problems introduced in Spectral Analysis orNeural Signals. Our purpose here is to introduce anddemonstrate ways to apply the Chronux toolbox to

    these problems. The methods presented here exem-pliy both univariate analysis (techniques restricted

    to signals elaborated over a single time course) andbivariate analysis, in which the goal is to investigate

    relationships between two time series. Problems in-volving more than two time series, or a time seriescombined with unctions o spatial coordinates, are

    problems or multivariate analysis. The chaptersMultivariate Neural Data Sets: Image Time Series,

    Allen Brain Atlas and Optical Imaging Analysis orNeural Signal Processing: A Tutorial deal explicitly

    with these techniques and the use o the Chronux

    toolbox to solve these problems.

    Spectral Analysis or Neural Signals introduces thespectral analysis o single-unit recordings (spikes)

    and continuous processes, or example, local eldpotentials (LFPs). As shown in that chapter, the

    multitaper approach allows the researcher to com-pute and render graphically several descriptions o

    the dynamics present in most electrophysiologicaldata. Neural activity rom the lateral intraparietalarea (LIP) o the alert monkey was used to calculate

    LFP spectrograms and spike-LFP coherograms and,most importantly, measures o the reliability o these

    estimates. Although the computations required toproduce these descriptions are easily attainable us-

    ing todays technology, the steps required to achievemeaningul and reliable estimates o neural dynam-ics need to be careully orchestrated. Chronux pro-

    vides a comprehensive set o tools that organize thesesteps with a set o succinct and transparent MAT-

    LAB scripts. Chronux analysis sotware also clears upmuch o the conusion surrounding which o the pa-

    rameters that control these calculations are crucial,and what values these parameters should take, giventhe nature o the data and the goals o the analysis.

    Chronux is downloadable rom www.chronux.org.

    This sotware package can process both univariateand multivariate time series data, and these signals

    can be either continuous (e.g., LFP) or point processdata (e.g., spikes). Chronux can handle a number osignal modalities, including electrophysiological and

    optical recording data. The Chronux release includesa spike-sorting toolbox and extensive online and

    within-MATLAB help documentation. Chronuxalso includes scripts that can translate les gener-

    ated by NeuroExplorer (Nex Technologies, Little-ton, MA) (.NEX), and the time-stamped (.PLX) and

    streamed (.DDT) data records collected with Plexon(Dallas, TX) equipment.

    We will proceed through components o a standard

    electrophysiology analysis protocol in order to illus-trate some o the tools available in Chronux. Figure 1

    charts the basic steps required or handling most elec-trophysiological data. We will assume that an editingprocedure has been used to sort the data into con-

    tinuous signals (LFPs or EEGs) and spikes. We willalso advance to a stage that ollows both the spike

    sorting and data conditioning steps (detrending andremoving artiacts, including 60 Hz line noise). We

    will return to the detrending and 60 Hz line noiseproblems later in the chapter.

    Typically, a rst step to take in exploratory data analy-sis is to construct a summary o neural activity that is

    aligned with the appearance o a stimulus or some be-haviorally relevant event. Recall that in the exampledescribed in Spectral Analysis or Neural Signals,

    the monkey is challenged with a delay period dur-ing which it must remember the location o a visual

    target that was cued at the beginning o a trial. Each

    Figur 1. Electrophysiological data analysis protocol.

  • 8/2/2019 8 Purpura Short Course Syllabus

    4/13

    68

    NoteS

    2008 Purpura

    3 s trial is composed o a 1 s baseline period ollowed

    by a 2 s period containing the delay and responseperiods. The neural signals, contained in the tutorial

    data le DynNeuroLIPmat, include three LFP signalsand two point-process time series (i.e., two channelso spike times). Nine trials associated with one target

    direction are included, as are 72 trials o the baselineperiod combined across eight possible target posi-

    tions. We will rst produce an estimate o the ringrate associated with the delay period and then pro-

    ceed to look or interactions between the two spikesand or any temporal structure in the LFPs.

    A script that will take us through these steps can belaunched by typing

    >> lip_master_script

    at the command prompt. The rst gure generated

    by the script (Fig. 2) details the spike times (as ras-ter plots) o the two single units or all the baseline

    periods (top row) and or the subset o trials (bottomrow) associated with one particular target. Note that

    the number o spikes increases roughly 1 s ater thestart o the trial. This increase indicates that some-thing is indeed happening at the start o the delay

    period and suggests that these neurons may play a rolein establishing a working memory trace o one targets

    location. The tutorial script will also produce resultsas in Figure 3, where we see the three LFP signals

    that were recorded alongside the spikes. These signalslikewise demonstrate a change in activity at the starto the delay period. As we proceed through the tuto-

    rial, we will see how Chronux can be used to urthercharacterize the neural activity in these recordings.

    RegressionFigure 4 illustrates one characterization that is o-

    ten used or depicting spike data. The top subplot othe gure illustrates a standard requency histogram,using a bin size o 104 ms, or a single trial o spike

    response. The rate is calculated by dividing thespike count in each bin by the bin width. The bot-

    tom subplot o the gure shows a smooth estimate o

    the ring rate generated by applying a local regres-sion algorithm, locft. In order to plot the regressiont and produce 95% condence bounds or the rate

    Figur 2. Raster plots or 2 isolated spikes recorded in monkey

    LIP. Each dot represents the time o occurrence o a spike. Each

    row details the spike times rom a dierent trial in the experi-

    ment. Top row: baseline period (frst second o each trial) orall trials. Bottom row: complete trials, including the baseline

    period (0-1 s) and delay and response periods (1-3 s) or a

    subset o trials associated with a single target.

    Figur 3. Local feld potentials (LFPs) recorded concomitantly

    with the spikes shown in Fig. 1. The LFPs are averaged over

    the trials elaborated in the spike raster plots in Fig. 1. Top row:

    baseline period; bottom row: complete trials. Voltage values

    or the LFPs are in units o microvolts.

    Figur 4. Spike rate estimates. Top row: requency histogram

    constructed rom a single trial or one isolated spike. Bin size =

    104 ms. Bottom row: output rom Chronux script locft. The

    solid line depicts an estimate o the spike rate. The dashed

    lines indicate the 95% confdence interval or this estimate.

    The dots along the time access represent the spike times. The

    nearest neighbor variable bandwidth parameter, nn, is set to

    0.7 or locft.

  • 8/2/2019 8 Purpura Short Course Syllabus

    5/13

    69

    NoteS

    2008 Purpura

    Nural Signal Prcssing: turial 1

    estimate, our tutorial script has run locft using theollowing syntax:

    >> t=loct(data,family,rate)

    ollowed by

    >> lfplot(t)

    and

    >> lfband(t)

    (Fig. 4, dashed lines in bottom subplot). In this case,

    we have opted to t our single-trial spike train to arate unction by setting theamily parameter olocft

    to rate. Alternatively, we could have smoothed thespike data by choosing to t it to a density unction

    in which the smoothing is meant to determine the

    probability o ring a spike as a unction o time.We generated density estimates by setting theamily

    parameter in locft to density instead orate.

    Note the dots that appear along the time axis o thebottom subplot: These are the spike times or the

    trial under consideration. Locft will t a linear, qua-dratic, or other user-specied unction to some subseto the spikes, using each spike time in turn as the

    center point or the least-squares t. The numbero spikes in each subset can be stipulated in one o

    two ways: (1) as a xed bandwidth, i.e., time in-terval. For example, i the parameter h=1 (and the

    spike times are given in units o seconds), then eachlocal t to the data will include 1 s o the trial; or(2) with h=0, and nn (nearest neighbor parameter)

    set to some raction such as 0.3, in which case thetime interval surrounding each spike will expand (or

    shrink) until 30% o the total number o spikes in thetime series is included.

    >> t=loct(data,family,rate,h,1)

    will produce a t using a xed bandwidth o 1 s. The

    bottom subplot o Figure 4 was produced with a near-est neighbor variable bandwidth,

    >> t=loct(data,family,rate,nn,0.7)

    where nn was set to 0.7. I we change this value toa smaller raction, say 0.3, then the smoothing will

    be done more locally, thereby revealing more o thetemporal fuctuations in the spike rate (Fig. 5).

    The data input to locft can include multiple tri-

    als (ollowing the data ormat rules outlined in theAppendix to this chapter). As seen in Figure 6 (whichour tutorial script will also generate), the resulting t

    to our two spike trains appears smoother than the tto the single trial, even though the nearest neighbor

    parameter (nn) is still 0.3. Although the regression isalways done on a single time series, in this case, all the

    spike times rom all the trials or each single unit arecollapsed into one vector. Note how a smoother esti-

    mate arises in Figure 6 than in Figure 5 owing to thegreater continuity across the samples (spike times)o the underlying rate unction. Jackknie condence

    limits can be computed or the multiple trials caseby holding out each trial in turn rom the regression

    t and then calculating the mean and standard errorrom the ensemble o drop-one ts.

    SpectraWe now begin our requencydomain exploration othe dynamics o the LFPs and spikes in our data set.

    Our tutorial script will now generate Figure 7, whichillustrates a multitaper spectrum calculated rom

    the continuous voltage record in one LFP channel(sampling rate = 1 KHz) or a single trial. Only the

    delay period o the trial is included in the data array.The tutorial script lip_master_scriptm includes the

    Figur 5. Spike rate estimate using locftin Chronux. Herethe nearest neighbor variable bandwidth parameter, nn, is set

    to 0.3.

    Figur 6. Spike rate estimates using locft. Estimates are con-

    structed using all spike times rom all trials shown in the bot-tom row o Figure 2. The nn parameter o locftis set to 0.3.

  • 8/2/2019 8 Purpura Short Course Syllabus

    6/13

    70

    NoteS

    2008 Purpura

    ollowing three lines, which can also be run rom thecommand prompt:

    >>params.Fs=1000;

    >>[S,f]=mtspectrumc(data,params);

    >> plot_vector(S,f);

    The rst line sets the sampling rate and, thereore,the requency resolution and range o the spectrum.Many Chronux unctions use a structure,params, that

    contains a number o elds or assigning values to theparameters governing the Fourier analysis routines

    (see Appendix or more about the elds orparams).The spectrum S and requency range used in the cal-

    culation are the outputs omtspectrumc. A Chronuxscript (the third line in this code segment) can beused to perorm special plotting. The deault setting

    orplot_vector produces a plot with a log transorm oS as a unction o a linear requency range. To plot

    the spectrum on a linear-linear set o axes, use

    >> plot_vector(S,f,n) .

    In Figure 7, the spectrum is plotted over a deault

    range: rom 0 Hz to the Nyquist limit or the sam-pling rate, 500 Hz. The output range o S and is

    restricted by setting another eld in theparams struc-ture,paramspass. Figure 8 presents the LFP spectrum

    rom the single trial but now with

    >>params.fpass=[0 100] ,

    and then, as beore

    >>params.Fs=1000;

    >>[S,f]=mtspectrumc(data,params);

    >> plot_vector(S,f); .

    The tutorial script will generate other examples oband-limited spectra ater you choose lower limits

    and upper limits or the requency range.

    The spacing in the requency grids used by the astFourier transorms (FFTs) called by Chronux can be

    adjusted through another eld in the structureparams.Iparamspad = 1, then no zeros will be appended tothe time series, and the requency grid will be set by the

    deaults imposed by MATLAB. Withparamspad = 0 ,the time series will be padded with zeros so that its

    total length is 512 sample points. For paramspad =

    1,2, the zero padding produces time series that are1024, 2048,, samples in length, respectively. Asone can see by executing the next code segment,

    >> params.pad=1;

    >>[S,f]=mtspectrumc(data,params);

    >> plot_vector(S,f,y)

    >> params.pad=3;

    >>[S,f]=mtspectrumc(data,params);

    >> plot_vector(S,f,m) ,

    the spectrum generated with a padding actor o 3

    (Fig. 9, red) is computed on a much denser grid thanthe spectrum computed with a padding actor o 1

    (Fig. 9, blue plot).

    One advantage o taking the multitaper approach to

    spectral analysis is the ability to control the degreeo smoothing in the spectrum. This is accomplished

    by adjusting the time-bandwidth product o thedata windowing, which in turn is established by the

    choice o the number o Slepian tapers to use. Thetutorial script lip_master_scriptm again calculatesthe spectrum o the single trial LFP signal, but now

    with two dierent degrees o smoothing. As beore,the number o tapers to use is set by a eld in the

    Figur 7. Multitaper spectrum or a single trial LFP; data

    selected rom the delay period. The y-axis o the spectrumis in units o dB=10*log10(S). params.Fs=1000, params.tapers=[3 5], params.fpass=[0 params.Fs/2], params.pad=0.

    Figur 8. Multitaper spectrum or a single trial LFP. Data se-

    lected rom the delay period. params.Fs=1000, params.

    tapers=[3 5],params.pass=[0 100],params.pad=0.

  • 8/2/2019 8 Purpura Short Course Syllabus

    7/13

    71

    NoteS

    2008 Purpura

    Nural Signal Prcssing: turial 1

    structureparams: paramstapers=[TW K], where TWis the time-bandwidth product and Kis the numbero tapers. For example, i

    >> params.tapers=[3 5] ,

    then the time-bandwidth product is TW= 3 and the

    number o tapers used is 5. The rule K = 2*TW 1 setsthe highest number o tapers that can be used whilepreserving the good time-requency concentration o

    the data windowing available rom the Slepian tapersequences. Fewer tapers than the limit o ve can be

    employed, and Chronux will produce a fag when thenumber o tapers requested is inconsistent with theTW. T is the length (typically in seconds) o our datasegment. One can also think o this value as being es-

    tablished by the [number o samples in data segment] 1/Fs (inverse o the sampling rate). Wis the hal-bandwidth o the multitaper lter, and i we do not

    change T, we can demonstrate changes in smooth-ing as a unction o changes in the hal-bandwidth,

    as shown in Figure 10. The tutorial script will promptthe user to try other degrees o spectral smoothing by

    entering new values or the time-bandwidth product.

    To compute the spectrum over a number o trials andreturn an average thereo, we set the trialave eldin the structureparams to 1. The tutorial script will

    carry out the ollowing steps:

    >> params.trialave=1;

    >>[S,f]=mtspectrumc(data,params);

    >> plot_vector(S,f) .

    Itrialave = 0, and the structured array data have anynumber o trials, the output S will be a matrix where

    each column is the spectrum computed rom onetrials neural signal.

    Chronux will also calculate and plot error bars ormultitaper spectra. Two dierent types o condence

    interval estimates are available. I we set the eld errinparams to

    >> params.err=[1 p], with p=0.05, and then

    execute>>[S,f,Serr]=mtspectrumc(data,params);

    >>plot_vector(S,f,[],Serr); ,

    Chronux will plot the spectrum bracketed by thetheoretical 95% condence limits or that estimate.The array Serr contains the (1 p)% limits, with the

    lower limit in the rst row and the upper limit inthe second row o the array. In this case, the con-

    dence bounds are based on the parametric distribu-tion or the variance o a random variable, i.e., the

    chi-square, with two degrees o reedom. I instead,we set the eld err inparams to

    >> params.err=[2 p], with p=0.05 ,

    the 95% condence bounds will be derived rom ajackknie estimate o the standard error or the sam-

    ple spectra. Thus, i we run the lines o code givenabove or the theoretical condence interval, andcontinue with

    >> hold

    >>p=0.05;

    >>params.err=[2 p];

    >>[S,f,Serr]=mtspectrumc(data,params);

    >>plot(f,10*log10(Serr(1,:)),r);>>plot(f,10*log10(Serr(2,:)),r); ,

    a gure similar to that seen in Figure 11 should berendered by the tutorial script.

    Figur 10. Multitaper spectrum or a single trial LFP; data

    selected rom the delay period (1 s duration, so T = 1).params.Fs=1000, params.tapers=[3 5] (blue), params.tapers=[10

    19] (red),params.pass=[0 100], params.pad=2

    Figur 9. Multitaper spectrum or a single trial LFP; data

    selected rom the delay period. params.Fs=1000, params.

    tapers=[3 5],params.pass=[0 100],params.pad=1 (blue),

    params.pad=3 (red).

  • 8/2/2019 8 Purpura Short Course Syllabus

    8/13

    72

    NoteS

    2008 Purpura

    Note that or these data, the jackknie condence

    interval (in red) is in good agreement with the so-called theoretical interval (in blue).

    As discussed in detail in other chapters, multitaper

    spectra can be calculated or point process data. Asdescribed in the Appendix herein, Chronux contains

    a whole set o analogous scripts or point processesthat match those or continuous data. However, thesuxes o the script names carry apt orpb, or point

    times and point binned, respectively, instead o a c, orcontinuous. For example, the script mtspectrumptm

    will compute the multitaper spectrum or data repre-sented as a series o spike times. The ollowing sec-tion o MATLAB code will extract a data segment

    o interest rom the trials, set the appropriate paramselds, compute the spectrum or the spike data, and

    plot the results:

    data=dsp1t; % data rom 1st cell

    delay_times=[1 2]; % start and end timeo delay period

    data=extractdatapt(data,delay_times,1); % extracts spikes within

    delay periodparamsFs=1000; % inverse o the spacing

    between points on the

    grid used or computingSlepian unctions

    paramspass=[0 100]; % range o requencieso interest

    paramstapers=[10 19]; % tapers

    paramstrialave=1; % average over trialsp=005; % p value or errorsparamserr=[1 p]; % chi2 errors

    [S,,R,Serr]=mtspectrumpt(data,params);

    The output should be similar to that presented in

    Figure 12. The tutorial script should be able to pro-duce this gure. One thing to note here is the high

    number o tapers, 19, used or computing the spec-trum. Owing to the inherent complexity o even a

    single spikes power spectrum, extensive smoothingoten helps represent spike spectra. The output vari-able R is something unique to spike spectra: It is the

    high-requency estimate o the spike rate derivedrom the spectrum. This estimate is either made on

    a trial-by-trial basis or based on the average, depend-ing on the setting o the parameterparamstrialave. In

    Figure 12, the mean rate estimates appear as dottedhorizontal lines.

    SpectrogramsThis section will illustrate how Chronux controls

    the calculation o time-requency representationso neural data. Chronux can generate spectrogramsor continuous data (like EEGs and LFPs) as well as

    point process activity (spike times and binned spikecounts). An important component o the Chronux

    spectrogram is the sliding window, which sets thewidth o the data window (usually specied in

    seconds) and how much the window should slidealong the time axis between samples. Within each

    Figur 11. Multitaper spectrum or LFP using all trials asso-

    ciated with one target; data selected rom the delay period.params.Fs=1000,params.tapers=[10 19],params.pass=[0

    100],params.pad=2,params.trialave=1 (average spectrumshown in black), params.err=[1 .05] (blue), params.err=[2

    .05] (red).

    Figur 12. Multitaper spectrum or two spikes recorded

    in area LIP; delay period activity only. Top: Cell 1, params.

    Fs=1000, params.tapers=[10 19], params.pass=[0 100],

    params.pad=0, params.trialave=1 (average, heavy line),

    params.err=[1 .05] (dashed lines), mean rate estimate (dotted

    horizontal line). Bottom: Cell 2, params.Fs=1000, params.

    tapers=[10 19], params.pass=[0 500], params.pad=0,

    params.trialave=1 (average, heavy line),params.err=[1 .05]

    (dashed lines), mean rate estimate (dotted horizontal line).

  • 8/2/2019 8 Purpura Short Course Syllabus

    9/13

    73

    NoteS

    2008 Purpura

    Nural Signal Prcssing: turial 1

    window, multitaper spectral analysis o the dataproceeds as it does when calculating standard spec-tra. However, one must remember that the spectral

    analysis is restricted to the temporal window or the

    data. Thus, the number o tapers used or the spec-trogram should refect the time-bandwidth producto the window, not the dimensions o the entire data

    segment o interest. Extensive temporal overlappingbetween successive windows will tend to producesmoother spectrograms. The ollowing code ragment

    rom the tutorial script (lip_master_scriptm) will helpgenerate spectrograms or two o the LFP channels in

    our data set (Fig. 13):

    movingwin=[05 005]; % set the moving

    window dimensionsparamsFs=1000; % sampling requency

    paramspass=[0 100]; % requencies ointerest

    paramstapers=[5 9]; % tapersparamstrialave=1; % average over trialsparamserr=0; % no error

    computation

    data=dlp1t; % data rom channel 1[S1,t,]=mtspecgramc

    (data,movingwin,params); % computespectrogram

    subplot(121)

    plot_matrix(S1,t,);xlabel([]); % plot spectrogram

    caxis([8 28]); colorbar;

    data=dlp2t; % data rom channel 2[S2,t,]=mtspecgramc(data,movingwin,params); % compute

    spectrogramsubplot(122);

    plot_matrix(S2,t,);xlabel([]); % plot spectrogram

    caxis([8 28]); colorbar;

    Note the use o the special Chronux plotting rou-tine plot_matrix. Here the window is set to 500 ms

    in duration with a slide o 50 ms along the time axisbetween successive windows.

    The same sets o parameters used or continuous LFP

    signals can be employed or calculating the spikespectrograms (Fig. 14). However, one useul modi-cation to make when plotting spike spectrograms is

    to normalize the spike power S by the mean ringrate R. For example,

    data=dsp1t; % data rom 1st cell[S,t,,R]=mtspecgrampt

    (data,movingwin,params); % computespectrogram

    fgure;subplot(211);

    % plot spectrogramnormalized by rateplot_matrix(S/repmat(R,

    [1 size(S,2)]),t,);xlabel([]);caxis([-5 6]);colorbar;

    data=dsp2t; % data rom 2nd cell

    [S,t,,R]=mtspecgrampt(data,movingwin,params); % compute

    spectrogram

    subplot(212); % plot spectrogram

    normalized by rate

    plot_matrix(S/repmat(R,[1 size(S,2)]),t,);caxis([-5 6]);colorbar;

    The normalized spectrograms demonstrate how the

    spike power fuctuates across the trials with respectto the mean rate. Here one can readily observe that,while there is an increase in gamma-band power in

    the spike discharge with respect to the mean rateduring the delay period (Fig. 14, yellow-orange col-

    ors, top subplot), the power in the lower-requencyfuctuations in the spike discharge is suppressed with

    respect to the mean rate (blue colors).

    CoherenceAs an example o the use o Chronux sotware or

    evaluating the strength o correlations between dier-ent neural signals, we will calculate the spike-eld co-

    herence or pairs drawn rom the three LFP channelsand two spike channels in our monkey parietal lobe

    data set. As discussed in Spectral Analysis or NeuralSignals, spike-eld coherence is a requency-domainrepresentation o the similarity o dynamics between

    a spike train and the voltage fuctuations produced byactivity in the spiking neurons local neural environ-

    Figur 13. Time-requency spectrograms or two LFP chan-

    nels. Activity rom all trials, over the entire trial (3 s) used

    or the analysis. Movingwin=[.5 .05], params.Fs=1000,

    params.tapers=[5 9], params.pass=[0 100], params.

    pad=0,params.trialave=1,params.err=0.

  • 8/2/2019 8 Purpura Short Course Syllabus

    10/13

    74

    NoteS

    2008 Purpura

    ment. As beore, we start by setting the values o the

    parameters carried by the structure params:

    paramsFs=1000; % sampling requency,

    same or LFP and spikeparamspass=[0 100]; % requency range

    o interestparamstapers=[10 19]; % emphasize smoothing

    or the spikes

    paramstrialave=1; % average over trialsparamserr=[1 005]; % population error bars

    delay_times=[1 2]; % defne the delay period

    (between 1 and 2seconds)

    datasp=extractdatapt(dsp1t,delay_times,1); % extract the spike data

    rom the delay period

    datalp=extractdatac(dlp1t,paramsFs,

    delay_times); % extract the LFP datarom the delay period

    [C,phi,S12,S1,S2,,zerosp,conC,phistd]=

    coherencycpt(datalp,datasp,params); % compute the coherence

    Note that the script or computing the coherency is

    coherencycpt, a unction that handles the hybrid casemixing continuous and point process data. For the

    outputs, we have the ollowing:

    C, the magnitude o the coherency, a complexquantity (ranges rom 0 to 1);

    phi, the phase o the coherency; S1 and S2, the spectra or the spikes and LFP

    signals, respectively; f, the requency grid used or the calculations;

    zerosp, 1 or trials or which there was at least one

    spike, 0 or trials with no spikes; confC, condence level or C at (1 p)% i

    paramserr=[1p] orparamserr=[2p]; and phistd, theoretical or jackknie standard devia-

    tion, depending on theparamserr selection

    These are used to calculate the condence intervalsor the phase o the coherency.

    This code segment, which is called by the tutorialscript, should generate a graphic similar to Figure 15.

    The top row o the gure shows the spike-eld coher-ence or spike 1 against the three LFP channels. The

    bottom row has the spike-eld coherence estimatesor spike 2 against the three LFP channels. The g-ure depicts the condence level or the coherence

    estimates as a horizontal dotted line running throughall the plots; coherence values above this level are

    signicant. We see rom this gure that the spikesand LFPs in the monkey parietal cortex showed an

    enhanced coherence during the delay period or therequency range rom ~25 Hz to more than 100 Hzor all the matchups, except LFP3, with both spikes.

    For the coherence measures involving LFP3, the co-herence is not signicant or very ast fuctuations

    (>90 Hz).

    Figur 15. Spike-feld coherence. Top row: coherence es-

    timates between cell (spike) 1 with LFP channel 1 (let), LFP

    channel 2 (middle), and LFP channel 3 (right). Bottom row:

    coherence estimates between cell (spike) 2 with LFP channel 1

    (let), LFP channel 2 (middle), and LFP channel 3 (right). Signif-

    cance level or the coherence estimates: horizontal dotted line

    running through all plots.

    Figur 14. Time-requency spike spectrograms or two spikes

    recorded in LIP. Activity rom all trials, over the entire trial

    (3 s) used or the analysis. Spectrograms are normalized by

    the mean rates o the two single units. Movingwin=[.5 .05],params.Fs=1000, params.tapers=[5 9], params.pass=

    [0 100], params.pad=0, params.trialave=1, params.err=0.

  • 8/2/2019 8 Purpura Short Course Syllabus

    11/13

    75

    NoteS

    2008 Purpura

    Nural Signal Prcssing: turial 1

    Using Chronux, we can also estimate the coherencebetween two spike trains. The setup o the parame-

    ters or the calculation is very similar to that requiredor the hybrid script:

    >> params.err=[2 p];

    >> [C,phi,S12,S1,S2,f,zerosp,confC,phistd,Cerr]=coherencypt(datasp1,datasp2,params);

    Here,phistd is the jackknied standard deviation othe phase, and Cerr is the (1 p)% condence in-

    terval or the coherence. Figure 16 shows a plot othe spike-spike coherence, comparing the delayperiod activity (in blue) with the coherence during

    the baseline (in red).

    DenoisingIn Figure 17, we expand the Data Conditioningsubgraph o the electrophysiology analysis proto-

    col rst introduced in Figure 1. The branch or theLFP data carries us through two stages o processing:

    local detrending and the testing and removal o 60

    Hz line noise. Electrophysiological recordings, bothin the research laboratory and in clinical settings,are prone to contamination. 60 Hz line noise (50 Hz

    in Europe), slow drits in baseline voltage, electricaltransients, ECG, and breathing movements all con-

    tribute dierent types o distortion to the recordedsignal. Methods or removing particular waveorms,

    such as ECG and large electrical transients, havegood solutions that are treated elsewhere (Perasan B,

    Spectral Analysis or Neural Signals; Mitra andPesaran, 1999; Sornborger et al., 2005; Mitra and

    Bokil, 2008). We will ocus here on slow fuctuationsin electrophysiological signals and line noise.

    I we add a sinusoidal voltage fuctuation to one o

    our LIP LFP recordings, the result will look some-

    thing like Figure 18 (top let). Such a slow fuctua-tion could be entirely the result o changes in the

    electrostatic charges built up around the recordingenvironment. Thereore, it is noise and we should

    try to remove it. With Chronux, we use a local lin-

    ear regression to detrend neural signals. The scriptlocdetrend utilizes a moving window controlled by

    params to select time samples rom the signal. Thebest tting line, in a least-squares sense, or each

    sample is weighted and combined to estimate theslow fuctuation, which is then removed rom the

    data signal.

    For Figure 18 (top middle),

    >> dLFP=locdetrend(LFP,[.1 .05]).

    The dimensions o the sampling window are 100 ms

    Figur 16. Coherence between spikes o cell 1 and cell 2. Blue

    traces: data restricted to the delay period o each trial (solid

    line, average coherence; dashed lines, 95% jackknie conf-

    dence interval or this estimate o the coherence). Red trace:

    data restricted to the baseline period o each trial. Horizontal

    line: signifcance level or the coherence estimates. params.Fs=1000, params.tapers=[10 19], params.pass=[0 100],

    params.pad=0,params.trialave=1,params.err=[2 .05].

    Figur 17. Data conditioning component o electrophysiologi-

    cal analysis protocol.

  • 8/2/2019 8 Purpura Short Course Syllabus

    12/13

    76

    NoteS

    2008 Purpura

    in duration, with a window shit o 50 ms betweensamples. Note that the detrended signal has much lesslow-requency fuctuation than the original signal (Fig.

    18, top let). In Figure 18 (top right), we see that theestimate o the slow fuctuation (blue) does a pretty

    good job o capturing the actual signal (red) that wasadded to the LFP data. However, i the sampling win-

    dow parameters are not well matched to changes inthe signal, the detrending will not be successul.

    For Figure 18 (bottom, center),

    >> dLFP=locdetrend(LFP,[.5 .1]).

    Window duration = 500 ms, hal the sample lengthwith a window shit o 100 ms. Here the estimate o

    the slow fuctuation (blue) does a poor job o captur-ing the sinusoid (Fig. 18, red, bottom right).

    Chronux accomplishes the removal o 60 Hz linenoise by applying Thomsons regression method or

    detecting sinusoids in signals (Thomson, 1982). Thismethod does not require that the data signal have

    a uniorm (white) power spectrum. The Chronuxscript rmlinesc can either remove a sinusoid o chosen

    requency or automatically remove any harmonics

    whose power exceeds a criterion in the F-distribution(the F-test). Figure 19 demonstrates the applicationo the F-test option ormlinesc.

    >>no60LFP=rmlinesc(LFP,params).

    Here the LFP (Fig. 19, top let) has been contaminat-ed with the addition o a 60 Hz sinusoid. The mul-

    titaper spectrum o this signal is shown in Figure 19(top right panel). Note the prominent 60 Hz element

    in this spectrum (broadened but well dened by theapplication o the multitaper technique). The spec-

    trum ono60LFP is shown in the gures bottom letpanel; the time series with the 60 Hz noise removed,

    the vector returned by rmlinesc, is shown in the bot-tom right panel.

    Appendix: Chronux ScriptsWhile not an exhaustive list o what is available inChronux, the scripts enumerated here (discussed inthis chapter) are oten some o the most useul ortrying rst during the early phase o exploratory data

    analysis. This section describes the means or settingsome o the more important parameters or control-

    ling multitaper spectral calculations, as well as thebasic rules or ormatting input data.

    Denoising(1) Slow variations (e.g., movements o a patient or

    EEG data)

    locdetrend.m: Loess method(2) 50/60 Hz line noise

    rmlinesc.mrmlinesmovingwinc.m

    Spectra and coherences (continuous processes)(1) Fourier transorms using multiple tapers

    mttc.m(2) Spectrum

    mtspectrumc.m(3) Spectrogram

    mtspecgramc.m(4) Coherency

    mtcoherencyc.m

    (5) Coherogrammtcohgramc.m

    Analogous scripts are available or analyzing time

    Figur 19. Application o rmlinesc.

    Figur 18. Application o locdetrend.

  • 8/2/2019 8 Purpura Short Course Syllabus

    13/13

    77

    NoteS

    Nural Signal Prcssing: turial 1

    series data organized in alternative ormats. Point-process time series data can be analyzed using

    mttptm, mtspectrumptm, etc. Binned spike countdata can be analyzed with mttbm, mtspectrumbm,

    etc. An additional set o scripts is available or cal-culating the coherence between a continuous series

    and a point-process time series (coherencycptm,coherogramcptm, etc.), and or the coherencebetween a continuous and binned spike counts

    (coherencycpbm, coherogramcpbm, etc).

    In a typical unction call, such as

    [S,,Serr]=mtspectrumc(data,params) , a structureparams is passed to the script. This structure sets val-ues or a number o important parameters used by

    this and many other algorithms in Chronux.

    paramsFs Sampling requency (e.g., i dataare sampled at 1 kHz, use 1000).paramstapers Number o tapers to use in spectral

    analysis specied by either passinga matrix o precalculated Slepian

    tapers (using the dpss unction inMATLAB) or calculating the time-

    requency bandwidth and the num-ber o tapers as [NW K], where Kis

    the number o tapers. Deault val-ues are params.tapers=[3 5].

    paramspad Amount o zero-padding or the

    FFT routines utilized in the multi-taper spectral analysis algorithms. Ipad = 1, no padding; i pad = 0,

    the FFT is padded to 512 points; ipad = 1, the FFT is padded to 1024

    points, pad = 2, padding is 2048points, etc. For a spectrum with adense requency grid, use more pad-

    ding.paramspass Frequency range o interest. As a

    deault, [0 Fs/2] will allow rom DCup to the Nyquist limit o the sam-

    pling rate.

    paramserr Controls error computation. Forerr=[1 p], so-called theoretical er-

    ror bars at signicance level p aregenerated and placed in the output

    Serr; err=[2 p] or jackknie errorbars; err=[0p] or err=0 or no error

    bars (make sure that Serr is not re-quested in the output in this case).

    paramstrialavg I 1, average over trials/channels; i

    set to 0 (deault), no averaging.Local regression and likelihood

    (1) Regression and likelihoodlocft.m

    (2) Plotting the tlplot.m

    (3) Plotting local condence bandslband.m

    (4) Plotting global condence bandsscb.m

    Data ormat(1) Continuous/binned spike count data

    Matrices with dimensions: time (rows) trials/channels (columns)

    Example: 1000 10 matrix is interpreted as1000 time-point samples or 10 trials rom 1channel or 1 trial rom 10 channels. I mul-

    tiple trials and channels are used, then addmore columns to the matrix or each addi-

    tional trial and channel.(2) Spike times

    Structured array with dimension equal to thenumber o trials/channels.

    Example: data(1).times=[0.3 0.35 0.42 0.6]

    data(2).times=[0.2 0.22 0.35]Chronux interprets data as two trials/chan-

    nels: our spikes collected at the times (inseconds) listed in the bracket or the rst

    trial/channel, and three spikes collected inthe second trial/channel.

    Supported third-party data ormats

    NeuroExplorer (.NEX)Plexon (both .PLX and .DDT le ormats)

    ReferencesMitra PP, Bokil H (2008) Observed Brain Dynamics.

    New York: Oxord UP.

    Mitra PP, Pesaran B (1999) Analysis o dynamicbrain imaging data. Biophys J 76:691-708.

    Sornborger A, Yokoo T, Delorme A, Sailstad C,Sirovich L (2005) Extraction o the average

    and dierential dynamical response in stimulus-locked experimental data. J Neurosci Methods

    141:223-229.

    Thomson DJ (1982) Spectrum estimation and har-monic analysis. Proc IEEE 70:1055-1096.