[FieldTrip] Phase Lag Index

Lidia Mijas lid.mijas at gmail.com
Tue Jun 24 11:44:32 CEST 2014


Thank you Jan-Mathijs,

So abs(x) will give me absolute value of x. But how can I use it
considering that my data is in spm/fieldtrip format?
This is my code for wpli.
'fd' stores WPLI values so values from -1 to 1 but taking abs(fd) doesn't
work.
Also not sure how to use just matlab to compute pli in the same way as the
code below. Any tips?

listfiles=ls('C:\Users\Lid\Documents\a_project\Controls\sources [40
80]\both_m1s\BceRdfspm8_*.mat');

for j=1:size(listfiles,1)

spmfilename=deblank(listfiles(j,:));

D= spm_eeg_load(spmfilename);
data = D.ftraw(0);
%
% megchan1 = 'lm1';
megchan2 = 'rm1';
emgchan = 'EEG061';

% meg1 = ft_selectdata(data, 'channel', megchan1, 'toilim', [1 3],
'avgoverrpt', 'no');
% meg1.label{1} = 'LM1';
meg2 = ft_selectdata(data, 'channel', megchan2, 'toilim', [1 3],
'avgoverrpt', 'no');
meg2.label{1} = 'RM1';
emg = ft_selectdata(data, 'channel', emgchan, 'toilim', [1 3],
'avgoverrpt', 'no');
emg.label{1} = 'EMG';

%emg.time = meg.time;

inp = ft_appenddata([],emg, meg2);
%
cfg            = [];
cfg.output     = 'powandcsd';
cfg.method     = 'mtmfft';
%cfg.taper      = 'hanning';
cfg.foilim     = [5 100];
cfg.toi = [1 3];
cfg.tapsmofrq  = 7; % was 2.5
cfg.keeptrials = 'yes';
cfg.channel    =  {'EMG', 'RM1'};%'EMG';
cfg.channelcmb = {'RM1','EMG'}; %'EMG' 'RM1'; 'LM1' 'RM1' };
freq           = ft_freqanalysis(cfg, inp);
%
cfg            = [];
cfg.method     = 'wpli';
cfg.channelcmb = {'RM1', 'EMG'};
fd              = ft_connectivityanalysis(cfg, freq);

%
cfg                  = [];
cfg.xparam           = 'freq';
cfg.zparam           = 'wplispctrm';
cfg.xlim             = [5 100];
cfg.ylim             = [-1 1];
cfg.channel          = 'EMG';
cfg.refchannel    = 'RM1';
cfg.showlabels       = 'yes';
figure; ft_singleplotER(cfg,fd);
L = 120;
c95 = 1-0.05^(1/(L-1));
x = get(gca,'xlim');
xlabel('frequency');
ylabel('cortico-muscular PLI');
hold on, line(x,[c95,c95],'linestyle','--','color','k'), hold off
% eval(['print -dpng beta_ppc_emg_rm1_patient_' LW240492 '.png']);
eval(['print -dpng gamma_pli_emg_rm1_control_' num2str(spmfilename(12:19))
'.png']);
close(gcf);

%
% mean(fd.ppcspctrm(fd.freq>=15 & fd.freq<=30))
%
% ffreq = fd.freq(fd.freq>=15 & fd.freq<=30);
% [m, ind] = max(fd.ppcspctrm(ismember(fd.freq, ffreq)));
% disp(['Max ' num2str(m) ' at ' num2str(ffreq(ind)) ' Hz']);

end
%%

Many thanks!!


2014-06-24 8:05 GMT+01:00 jan-mathijs schoffelen <
jan.schoffelen at donders.ru.nl>:

> Hi Lidia,
>
> Transforming a number that is bounded between -1 and 1 into a number that
> has absolute value and is bounded between 0 and 1 can be achieved by taking
> the abs().
> Alternatively, you could compute the classic PLI from a time series of
> complex-valued cross-spectral density estimates by
> abs(mean(sign(angle(x))));
>
> Best,
> Jan-Mathijs
>
>
> On Jun 24, 2014, at 12:46 AM, Lidia Mijas <lid.mijas at gmail.com> wrote:
>
> Hi everyone,
>
> I would like to compute a classic phase lag index between pairs of MEG
> time series.
>
> So far I only found a wieghted phase lag index method implemented in ft
> and as far as I understand it is a directed measure so it gives the values
> from -1 to 1. Has anyone have an idea how to transform it so it computes
> absolute values from 0 to 1???
>
> Many thanks in advance.
>
> Regards,
> Lidia
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
> Jan-Mathijs Schoffelen, MD PhD
>
> Donders Institute for Brain, Cognition and Behaviour,
> Centre for Cognitive Neuroimaging,
> Radboud University Nijmegen, The Netherlands
>
> Max Planck Institute for Psycholinguistics,
> Nijmegen, The Netherlands
>
> J.Schoffelen at donders.ru.nl
> Telephone: +31-24-3614793
>
> http://www.hettaligebrein.nl
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140624/d1c09977/attachment.html>


More information about the fieldtrip mailing list