# freqanalysis_wltconvol.m

Brian Roach Brian.Roach at YALE.EDU
Tue Oct 17 23:44:29 CEST 2006

```Markus,

Thanks for your reply.  I believe I am getting a better handle on this
function.

Regarding phase-locking factor/ITC, couldn't I try to use the complex data
within the freqanalysis_wltconvol to calculate these data in a similar
method to that in the Tallon-Baudry et. al. '97 gamma paper?  The wltconvol
function is so similar to that paper's analysis already, it seems like I
would only need to divide the complex data by its absolute value.  The
paper refers to taking the "modulus of this complex value," where the
complex value is:
Pi(f,f0) = w(t,f0) X si(t,f0)/ | w(t,f0) X si(t,f0)

I read this as the dividing the imaginary, sine wave, portion of the
wavelet (representing phase angle) at any given time and frequency by its
absolute value.  Does modulus have the same functionality/meaning as the
C++ mod or matlab rem function?  Is there interest in phase-locking values
in the FieldTrip user community?  I am interested in trying to implement
what is described above, but it would be nice to have others see the code
and test it to be sure I have calculated phase-locking values correctly.

Thanks,
Brian
At 05:05 AM 10/9/2006, you wrote:
>Hi Brian,
>
>On Oct 7, 2006, at 12:04 AM, Brian Roach wrote:
>
>>Here is my example:
>>1000Hz sample rate for the acquired data
>>4000ms epochs centered on an event (-2000ms before the event to
>>1999 after the event)
>>
>>cfg =
>>
>>     output: 'pow'
>>     method: 'wltconvol'
>>        foi: [1x60 double]
>>      width: 6
>>     gwidth: 3
>>        toi: [1x1000 double]
>>
>>where foi is 1 to 60Hz (in 1Hz steps), and toi is -.5s to .5s (in
>>1ms steps)
>>
>>I like that 1Hz is not plotted (NaN) values, since you cannot get 6
>>cycles of 1Hz data in my 4s epoch size.  Having run this, I am
>>still uncertain about how gwidth influences the data.  Does a
>>smaller gwidth just widen the bell curve of the gaussian envelope?
>>Is there a trend, such as the higher the gwidth, the better the
>>time resolution (because the wavelet has a sharper rise and fall
>>time)?
>
>cfg.gwidth does not influence the width of the gaussian envelope and
>thus does not have an effect on the temporal or spectral resolution.
>The cfg.gwidth parameter determines the length of the morlet-wavelet
>but not its shape. The gaussian envelope implies that the wavelet
>tails converge towards zero but are not really zero at the edges.
>Thus one has to decide where to crop the wavelet-kernel. The gwidth
>parameter determines the cropped length in standard deviations of the
>gaussian envelope. For cfg.gwidth = 3 the morlet-wavelet is thus
>estimated for the central +/- 3 standard deviations of the gaussian
>envelope. Hence, smaller gwidth parameter lead to edges of the
>wavelets that become more "non-zero" which lead to stronger edge
>effects and more noisy picture of your time-frequency transform. Run
>your analysis with the above parameters but cfg.gwidth = 1. If you
>compare the output to that of cfg.gwidth = 3 this effect should
>become clear.
>
>>In my case, does sf = 2Hz/6Hz or 1/3Hz?  I don't think I have these
>>values right, and since they influence temporal domain and spectral
>>bandwidth, it is important that I know what is right.  It seems
>>like if my interpretation of your e-mail is correct, then each
>>frequency bin consists of that frequency +/-.167 or (1/6) Hz.  In
>>my example above, my 2Hz value would then consist of data from
>>1.8333 to 2.1667Hz.  This would mean that there are gaps in the
>>spectral data and a smaller number of cycles or smaller width would
>>lead to larger bandwidth (i.e. decreasing frequency resolution).
>>What do you think?
>
>The spectral bandwidth of your time-frequency tranform is not
>constant but a function of frequency. For your example, the spectral
>bandwidth (in standard deviations, Hz) is computed as:
>
>bandwidth = cfg.foi ./ cfg.width;
>
>For a constant cfg.width, the spectral bandwidth increases linearly
>with the frequency of interest. While at 18 Hz you have a spectral
>bandwidth of 3 Hz, the bandwidth at 60 Hz is 10 Hz.
>
>>Also, does fieldtrip have a function that gives "phase locking
>>factor" or inter-trial coherence (ITC)?
>
>Not that I know. However, you could compute ITC yourself based on the
>complex output from freqanalysis_mtmconvol run with cfg.output =
>'fourier'.
>
>Best,
>Markus
>

```