[FieldTrip] PLV analysis clarification

Matt Mollison matt.mollison at gmail.com
Wed Mar 16 02:01:46 CET 2011


Hi FieldTrippers,

I know there have been quite a few PLV/coherence emails on this list. I've
searched the archives extensively and have attempted this on my own for a
while now, but even using all the info I gathered from the archives I
haven't succeeded in running any PLV (or coherence) analyses.

Here's what I'm hoping to accomplish by posting here: I'd appreciate any
advice about how to correctly run analyses for a within-subjects (32 subj)
experiment comparing PLV between 2 conditions that every subject ran in,
looking at specific times and frequencies (and/or using cluster stats—though
I have no idea how to deal with so many pairwise cohrefchannel+channel
combinations, but I'm re-reading Maris et al., 2007 tonight).

Here's my issue: I've had a difficult time implementing PLV analyses,
particularly stats, and I don't know if/where I should z-transform PLV. I
can calculate PLV by running ft_freqanalysis and then
ft_connectivityanalysis, but I can't do anything with the output. Well, I
shouldn't say I can't do *anything* with the output: if I
run ft_freqanalysis with cfg.method='mtmconvol' I can plot the data for one
channel and a cohrefchannel using ft_singleplotTFR, but I can't run the PLV
data through ft_freqstatistics. Also, I've found that cfg.method='wavelet'
does not produce any cases where I can plot PLV (using both powandcsd and
fourier; I feel like I know the technical difference between the powandcsd
and fourier options, but I don't know how they functionally differ for
running analyses in FT).

To be more specific about these cases where I've been able to plot PLV, I've
used these options for ft_freqanalysis (plus specifics for each method like
toi, foi, etc.), and then ran it through ft_connectivityanalysis with
cfg.method='plv':
cfg_freq = [];
cfg_freq.method='mtmconvol';
cfg_freq.output = 'fourier';
cfg_freq.keeptrials = 'yes';
cfg_freq.keeptapers = 'yes';
cfg_freq.channelcmb = {'E3','E60';'E3','E62';'E11','E60';'E11','E62'}; %
when debugging, only calculate for a few channels
and
cfg_freq = [];
cfg_freq.method='mtmconvol';
cfg_freq.output = 'powandcsd';
cfg_freq.keeptrials = 'no';
cfg_freq.keeptapers = 'no';
cfg_freq.channelcmb = {'E3','E60';'E3','E62';'E11','E60';'E11','E62'}; %
when debugging, only calculate for a few channels

I can't tell if I'm doing something wrong or if there are bugs in the FT
scripts when processing the label, labelcmb, and dimord fields. I posted
about errors/crashes regarding these fields on bugzilla a few weeks ago <
http://bugzilla.fcdonders.nl/show_bug.cgi?id=480> when I was a little less
educated about these analyses, but I haven't progressed in coding up my own
analyses; I've only made a lot of fruitless attempts. People on this list
seem to be successfully running PLV/coherence analyses, so I can only guess
that the problem is on my end. Once I get it figured out I'd be happy to
write a baseic tutorial for the FT wiki.

TL;DR: any advice on a viable PLV/coherence within-subjects workflow would
be much appreciated.

Thanks,
Matt

P.S. I'm attaching a text file noting success and failures of FT functions
for iterations of wavelet/mtmconvol and powandcsd/fourier and
keeptrials/keeptapers=yes/no. It's a lot of details, and you probably
shouldn't feel the need to read though it unless you're debugging. I've
tried to visually separate the iterations with equals signs, and the
functions within an iteration with hyphens.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20110315/a9b4dcc4/attachment-0001.html>
-------------- next part --------------
=================================================================
cfg_freq.method = 'wavelet';
cfg_freq.output = 'powandcsd';
cfg_freq.channelcmb = {'all','all'}; % 129 channels

--------------------------------------
ft_freqanalysis
data_freq =
        label: {129x1 cell}
       dimord: 'chan_freq_time'
         freq: [2.9630 3.7037 4.4444 5.1852 5.9259 6.6667 7.4074 8.1481 8.8889]
         time: [1x33 double]
    powspctrm: [129x9x33 double]
     labelcmb: {8256x2 cell}
    crsspctrm: [8256x9x33 double]
          cfg: [1x1 struct]

ft_connectivityanalysis with 'plv'
data_conn =
      labelcmb: {8256x2 cell}
       dimord: 'chan_freq_time'
    plvspctrm: [8256x9x33 double]
         freq: [2.9630 3.7037 4.4444 5.1852 5.9259 6.6667 7.4074 8.1481 8.8889]
         time: [1x33 double]
          cfg: [1x1 struct]

--------------------------------------
FAILURE: can't run ft_freqgrandaverage on data_conn because there is no label field

--------------------------------------
FAILURE: can't run ft_singleplotTFR on data_conn

cfg_ft.cohrefchannel = 'E3';
cfg_ft.channel = 'E60';
selected 1408 channels for plvspctrm
??? Error using ==> ft_channelselection at 72
data with non-unique channel names is not supported

Error in ==> ft_singleplotTFR at 290
selchannel = ft_channelselection(cfg.channel, data.label);

--------------------------------------
FAILURE: can't run ft_topoplotTFR on data_conn

creating layout from data.elec
creating layout for egi128 system
selected 1408 channels for plvspctrm
Warning: Duplicate x-y data points detected: using average of the z values. 
> In griddata at 108
  In ft_plot_topo at 146
  In ft_topoplotER at 747
  In ft_topoplotTFR at 116
??? Error using ==> griddata at 122
Not enough unique sample points specified.

Error in ==> ft_plot_topo at 146
[Xi,Yi,Zi] = griddata(chanX', chanY, dat, xi', yi, interpmethod); % interpolate the topographic data

Error in ==> ft_topoplotER at 747
    ft_plot_topo(chanX,chanY,datavector,'interpmethod',cfg.interpolation,...

Error in ==> ft_topoplotTFR at 116
cfg=ft_topoplotER(cfg, varargin{:});
=================================================================
=================================================================
=================================================================
cfg_freq.method = 'wavelet';
cfg_freq.output = 'fourier'
cfg_freq.channelcmb = {'E3','E60';'E3','E62';'E11','E60';'E11','E62'};
cfg_freq.channel = unique(cfg_freq.channelcmb);

have to set keeptapers to 'no' even though (as far as I know) there are no tapers used in wavelets (see ft_freqanalysis line 313)
cfg_freq.keeptrials = 'no';
cfg_freq.keeptapers = 'no';

--------------------------------------
ft_freqanalysis
data_freq =
            label: {4x1 cell}
           dimord: 'chan_freq_time'
             freq: [2.9630 3.7037 4.4444 5.1852 5.9259 6.6667 7.4074 8.1481 8.8889]
             time: [1x33 double]
    fourierspctrm: [4x9x33 double]
              cfg: [1x1 struct]

--------------------------------------
FAILURE: can't run ft_connectivityanalysis on data_freq because there is no cumtapcnt field

??? Reference to non-existent field 'cumtapcnt'.

Error in ==> ft_checkdata>fixcsd at 844
  sumtapcnt = [0;cumsum(data.cumtapcnt(:))];

Error in ==> ft_checkdata at 594
    data = fixcsd(data, cmbrepresentation, channelcmb);

Error in ==> univariate2bivariate at 29
        data    = ft_checkdata(data, 'cmbrepresentation', 'full');

Error in ==> ft_connectivityanalysis at 234
          [data, powindx, hasrpt] = univariate2bivariate(data, 'fourierspctrm', 'crsspctrm', dtype, 'cmb', cfg.channelcmb);
=================================================================
=================================================================
=================================================================
cfg_freq.method = 'mtmconvol';
cfg_freq.output = 'powandcsd';
cfg_freq.channelcmb = {'E3','E60';'E3','E62';'E11','E60';'E11','E62'};
cfg_freq.channel = unique(cfg_freq.channelcmb);

cfg_freq.keeptrials = 'no';
cfg_freq.keeptapers = 'no';
cfg_freq.taper = 'hanning';

--------------------------------------
ft_freqanalysis
data_freq =
        label: {4x1 cell}
       dimord: 'chan_freq_time'
         freq: [2.9630 3.7037 4.4444 5.1852 5.9259 6.6667 7.4074 8.1481 8.8889]
         time: [1x33 double]
    powspctrm: [4x9x33 double]
     labelcmb: {4x2 cell}
    crsspctrm: [4x9x33 double]
    cumtapcnt: [173x9 double]
          cfg: [1x1 struct]

ft_connectivityanalysis with 'plv'
data_conn =
     labelcmb: {4x2 cell}
       dimord: 'chan_freq_time'
    plvspctrm: [4x9x33 double]
         freq: [2.9630 3.7037 4.4444 5.1852 5.9259 6.6667 7.4074 8.1481 8.8889]
         time: [1x33 double]
          cfg: [1x1 struct]
--------------------------------------
FAILURE: can't run ft_freqgrandaverage on data_conn because there is no label field

--------------------------------------
SUCCESS: ft_singleplotTFR successfully makes a plot

--------------------------------------
FAILURE: can't run ft_freqstatistics on data_conn because there's no label field

??? Reference to non-existent field 'label'.

Error in ==> prepare_timefreq_data>forcedimord at 509
  output.label  = input.label;

Error in ==> prepare_timefreq_data at 87
  [remember{c}, hascrsspctrm] = forcedimord(varargin{c});

Error in ==> statistics_wrapper at 217
  [cfg, data] = prepare_timefreq_data(cfg, varargin{:});

Error in ==> ft_freqstatistics at 127
[stat, cfg] = statistics_wrapper(cfg, varargin{:});
=================================================================
=================================================================
=================================================================
cfg_freq.method = 'mtmconvol';
cfg_freq.output = 'fourier';
cfg_freq.channelcmb = {'E3','E60';'E3','E62';'E11','E60';'E11','E62'};
cfg_freq.channel = unique(cfg_freq.channelcmb);

cfg_freq.keeptrials = 'no';
cfg_freq.keeptapers = 'no';
cfg_freq.taper = 'hanning';

--------------------------------------
ft_freqanalysis
data_freq =
            label: {4x1 cell}
           dimord: 'chan_freq_time'
             freq: [2.9630 3.7037 4.4444 5.1852 5.9259 6.6667 7.4074 8.1481 8.8889]
             time: [1x33 double]
    fourierspctrm: [4x9x33 double]
        cumtapcnt: [173x9 double]
              cfg: [1x1 struct]

--------------------------------------
FAILURE: can't run ft_connectivityanalysis on data_freq

??? Subscripted assignment dimension mismatch.

Error in ==> ft_checkdata>fixcsd at 851
        crsspctrm(p,:,:,m,k) = (tmpdat*tmpdat')./data.cumtapcnt(p);

Error in ==> ft_checkdata at 594
    data = fixcsd(data, cmbrepresentation, channelcmb);

Error in ==> univariate2bivariate at 29
        data    = ft_checkdata(data, 'cmbrepresentation', 'full');

Error in ==> ft_connectivityanalysis at 234
          [data, powindx, hasrpt] = univariate2bivariate(data, 'fourierspctrm', 'crsspctrm', dtype, 'cmb', cfg.channelcmb);
=================================================================
=================================================================
=================================================================
cfg_freq.method = 'mtmconvol';
cfg_freq.output = 'fourier';
cfg_freq.channelcmb = {'E3','E60';'E3','E62';'E11','E60';'E11','E62'};
cfg_freq.channel = unique(cfg_freq.channelcmb);

cfg_freq.keeptrials = 'yes';
cfg_freq.keeptapers = 'yes';
cfg_freq.taper = 'hanning';

--------------------------------------
ft_freqanalysis
data_freq = 
            label: {4x1 cell}
           dimord: 'rpttap_chan_freq_time'
             freq: [2.9630 3.7037 4.4444 5.1852 5.9259 6.6667 7.4074 8.1481 8.8889]
             time: [1x33 double]
    fourierspctrm: [4-D double]
        cumtapcnt: [173x9 double]
              cfg: [1x1 struct]

ft_connectivityanalysis with 'plv'
data_conn = 
        label: {4x1 cell}
       dimord: 'chan_chan_freq_time'
    plvspctrm: [4-D double]
         freq: [2.9630 3.7037 4.4444 5.1852 5.9259 6.6667 7.4074 8.1481 8.8889]
         time: [1x33 double]
          dof: [173 173 173 173 173 173 173 173 173]
          cfg: [1x1 struct]

--------------------------------------
FAILURE: can't run ft_freqgrandaverage on data_conn

??? Error using ==> ft_freqgrandaverage at 170
unsupported dimord

--------------------------------------
SUCCESS: ft_singleplotTFR makes a plot

--------------------------------------
FAILURE: can't do ft_freqstatistics on data_conn because of chan_chan in dimord

??? Error using ==> size
Dimension argument must be a positive integer scalar within indexing range.

Error in ==> prepare_timefreq_data>forcedimord at 540
    Nchan = size(output.dat, chandim);

Error in ==> prepare_timefreq_data at 87
  [remember{c}, hascrsspctrm] = forcedimord(varargin{c});

Error in ==> statistics_wrapper at 217
  [cfg, data] = prepare_timefreq_data(cfg, varargin{:});

Error in ==> ft_freqstatistics at 127
[stat, cfg] = statistics_wrapper(cfg, varargin{:});

Error in ==> mm_ft_ttestTFR at 228
  cfg_ana.(vs_str) = eval(sprintf('ft_freqstatistics(cfg_ft,%s);',subj_str));
=================================================================


More information about the fieldtrip mailing list