


This library performs time-frequency analysis (mostly using the
multi-taper spectral estimation method) of univariate and multivariate
data, both for continuous processes such as LFP/EEG and for point
processes such as spike times. Point process can either be stored as
times or as a binned process of counts. The routines in this library
are named differently for the three cases. For calculations
that can be performed for each of the three data types, we use suffixes
c, pb, or pt to refer to continuous, point process binned counts, or
point process times. For example, the spectrum calculation is performed
mtspectrumc for continuous processes, mtspectrumpb for a binned point
process, and mtspectrumpt for a point process consisting of times. There
are also routines for calculating hybrid quantities involving one continuous
and one point process. These are suffixed in a similar manner. For
example, coherencycpb calculates the coherency between a binned point process
and a continuous process.
Certain variables are used repeatedly in this library.
DATA
data in most cases can be univariate or multivariate, and either point process,
or continuous.
Continuous data: Continuous data is assumed to be a matrix with
dimensions samples x channels/trials.
Point Process: A single time series of spike times can be in the form of
a column vector.
Multichannel/trial spike time data is not amenable to this
storage format, since there are generally different
number of spikes in each channel/trial. Instead,
multichannel/trial spike data is stored in a structure
array. A structure is a matlab data object with various
fields. These fields contain the elements
e.g. The command data=struct('times',[]); creates an empty
structure with field 'times'. Similarly, the command
data=struct('times',[1 2 3]); creates the structure with
the field 'times' containing integers 1, 2, and 3.
We can also have a structure array (or an array of structures)
defined for example, by
data(1)=struct('times',rand(1,100)); and
data(2)=struct('times',rand(1,200));
This is a 2 dimensional structure array where the
first field is a 100 dimensional random vector, and
the second field is a 200 dimensional random vector.
This format allows storage of multichannel point
process times in a single variable data.
The above holds for point processes stored as times.
If instead, the point processes are binned, then one
can use a matrix to represent them
Summary: data - array of continuous data with dimensions time x channels
structural array of spike times with dimensions
equal to the number of channels
1d array of spike times as a column vector
array of binned spike counts with dimensions time x channels
PARAMETERS:
These are various parameters used in the spectral calculations. Since
these parameters are used by most routines in Chronux, they are stored in
a single structure params. The fields of params are
tapers: tapers denotes either the parameters used in the dpss calculation
or the calculated slepian sequences themselves. In the first case,
tapers=[TW K] where TW denotes the time bandwidth product, and K denotes
the number of sequences to be calculated. optional (default [3
5])
pad: pad factor used to compute fft. This should be chosen to be a small
integer 2,3. Then the fft will be calculated using 2 raised to (the
next power of 2 greater than the length of the data+pad). e.g. if
the length of the data is 512 and pad=2, fft will be calculated
using windows of length 2048. If pad=3, it will be calculated using
4096 points. optional (default 2)
Fs:sampling frequency.optional (default 1)
fpass: frequencies in an fft calculation can range from 0 to Fs/2 where
Fs is the sampling frequency. Sometimes it may be useful to
compute fourier transforms (and resulting quantities like the
spectrum over a smaller range of frequencies). This is specified
by fpass, which can be in the form [fmin fmax] where fmin >=0 and
fmax<=Fs/2. optional (default [0 Fs/2])
err=[errtype p] calculates theoretical error bars (confidence levels)
when errtype=1 and jackknife error bars when errchk=2. In each case, the
error is calculated at a p value specified by p. -
optional (default 0)
trialave: trialave controls whether or not to average over channels/trials for
multichannel/trial analyses. trialave=0 (default) implies no trial
averaging, trialave=1 implies that the quantity of interest is averaged
over channels/trials. optional (default 0)
Other parameters are discussed in individual routines as and when they
are used.

0001 function chronux 0002 % This library performs time-frequency analysis (mostly using the 0003 % multi-taper spectral estimation method) of univariate and multivariate 0004 % data, both for continuous processes such as LFP/EEG and for point 0005 % processes such as spike times. Point process can either be stored as 0006 % times or as a binned process of counts. The routines in this library 0007 % are named differently for the three cases. For calculations 0008 % that can be performed for each of the three data types, we use suffixes 0009 % c, pb, or pt to refer to continuous, point process binned counts, or 0010 % point process times. For example, the spectrum calculation is performed 0011 % mtspectrumc for continuous processes, mtspectrumpb for a binned point 0012 % process, and mtspectrumpt for a point process consisting of times. There 0013 % are also routines for calculating hybrid quantities involving one continuous 0014 % and one point process. These are suffixed in a similar manner. For 0015 % example, coherencycpb calculates the coherency between a binned point process 0016 % and a continuous process. 0017 % 0018 % Certain variables are used repeatedly in this library. 0019 % 0020 % DATA 0021 % data in most cases can be univariate or multivariate, and either point process, 0022 % or continuous. 0023 % 0024 % Continuous data: Continuous data is assumed to be a matrix with 0025 % dimensions samples x channels/trials. 0026 % 0027 % Point Process: A single time series of spike times can be in the form of 0028 % a column vector. 0029 % Multichannel/trial spike time data is not amenable to this 0030 % storage format, since there are generally different 0031 % number of spikes in each channel/trial. Instead, 0032 % multichannel/trial spike data is stored in a structure 0033 % array. A structure is a matlab data object with various 0034 % fields. These fields contain the elements 0035 % e.g. The command data=struct('times',[]); creates an empty 0036 % structure with field 'times'. Similarly, the command 0037 % data=struct('times',[1 2 3]); creates the structure with 0038 % the field 'times' containing integers 1, 2, and 3. 0039 % 0040 % We can also have a structure array (or an array of structures) 0041 % defined for example, by 0042 % data(1)=struct('times',rand(1,100)); and 0043 % data(2)=struct('times',rand(1,200)); 0044 % This is a 2 dimensional structure array where the 0045 % first field is a 100 dimensional random vector, and 0046 % the second field is a 200 dimensional random vector. 0047 % This format allows storage of multichannel point 0048 % process times in a single variable data. 0049 % 0050 % The above holds for point processes stored as times. 0051 % If instead, the point processes are binned, then one 0052 % can use a matrix to represent them 0053 % 0054 % 0055 % Summary: data - array of continuous data with dimensions time x channels 0056 % structural array of spike times with dimensions 0057 % equal to the number of channels 0058 % 1d array of spike times as a column vector 0059 % array of binned spike counts with dimensions time x channels 0060 % 0061 % PARAMETERS: 0062 % These are various parameters used in the spectral calculations. Since 0063 % these parameters are used by most routines in Chronux, they are stored in 0064 % a single structure params. The fields of params are 0065 % 0066 % tapers: tapers denotes either the parameters used in the dpss calculation 0067 % or the calculated slepian sequences themselves. In the first case, 0068 % tapers=[TW K] where TW denotes the time bandwidth product, and K denotes 0069 % the number of sequences to be calculated. optional (default [3 0070 % 5]) 0071 % 0072 % pad: pad factor used to compute fft. This should be chosen to be a small 0073 % integer 2,3. Then the fft will be calculated using 2 raised to (the 0074 % next power of 2 greater than the length of the data+pad). e.g. if 0075 % the length of the data is 512 and pad=2, fft will be calculated 0076 % using windows of length 2048. If pad=3, it will be calculated using 0077 % 4096 points. optional (default 2) 0078 % 0079 % Fs:sampling frequency.optional (default 1) 0080 % 0081 % 0082 % fpass: frequencies in an fft calculation can range from 0 to Fs/2 where 0083 % Fs is the sampling frequency. Sometimes it may be useful to 0084 % compute fourier transforms (and resulting quantities like the 0085 % spectrum over a smaller range of frequencies). This is specified 0086 % by fpass, which can be in the form [fmin fmax] where fmin >=0 and 0087 % fmax<=Fs/2. optional (default [0 Fs/2]) 0088 % 0089 % err=[errtype p] calculates theoretical error bars (confidence levels) 0090 % when errtype=1 and jackknife error bars when errchk=2. In each case, the 0091 % error is calculated at a p value specified by p. - 0092 % optional (default 0) 0093 % 0094 % trialave: trialave controls whether or not to average over channels/trials for 0095 % multichannel/trial analyses. trialave=0 (default) implies no trial 0096 % averaging, trialave=1 implies that the quantity of interest is averaged 0097 % over channels/trials. optional (default 0) 0098 % 0099 % Other parameters are discussed in individual routines as and when they 0100 % are used.