# [FieldTrip] instantaneous phase and phase locking value

Eelke Spaak eelke.spaak at donders.ru.nl
Thu Jun 14 14:34:52 CEST 2012

```Hi Qi,

There are several options in FT for estimating instantaneous phase.
You could use a sliding time window FFT in ft_freqanalysis, where you
choose to get complex Fourier spectra as output, and specify to get an
estimate at each sample, as in:

cfg = [];
cfg.method = 'mtmconvol';
cfg.keeptrials = 'yes';
cfg.taper = 'hanning'; % in general, dpss here does not make sense if
you're interested in instantaneous phase
cfg.toi = data.time{1}; % assuming your trials are of equal length
cfg.foi = 10; % or whatever frequency you want estimated (can of
course be a vector)
cfg.t_ftimwin = 5./cfg.foi; % use e.g. 5 cycles to estimate the phase
cfg.output = 'fourier';
freq = ft_freqanalysis(cfg, data);

The output freq.fourierspctrm will be a nTrials X nChannels X nFreqs X
nSamples complex-valued matrix, from which you can get instantaneous
phase by using angle().

An alternative approach would be to first filter your data, and then
apply a Hilbert transform. This can be done in ft_preprocessing:

cfg = [];
cfg.bpfilter = 'yes';
cfg.bpfreq = [7 14];
cfg.bpfilttype = 'fir'; % or 'firls' (slower), but avoid the default
'but' (= not well-suited for hilbert phase estimate)
cfg.hilbert = 'angle'; % this gives you just the phase, you can
specify 'complex' to get both phase and amplitude
datPhase = ft_preprocessing(cfg, data);

where datPhase will be just a FT raw data structure containing phase
information (or complex phase/amplitude information, depending on your
choice).

Concerning the phase-locking value, you might want to take a look at
ft_connectivityanalysis with cfg.method='plv', but I have no
experience on this.

Best,
Eelke

On 13 June 2012 23:35, qi li <lihqih at gmail.com> wrote:
> Hi there,
>
> I am wondering whether fieldtrip has a function to compute the
> instantaneous phase and phase locking value. Thanks!
>
> Qi
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

```