[FieldTrip] Help with between-trials single subject permutation (ft_freqstatistics output is stat.sta NaN NaN NaN ....)

Ana Pesquita anapesquita at gmail.com
Fri Feb 1 21:30:03 CET 2019


Hello,

My name is Ana and I have recently started using Fieldtrip.
I am trying to adapt the fieldtrip tutorial - 'Cluster-based permutation
tests on time-frequency data' - to my particular case (
http://www.fieldtriptoolbox.org/tutorial/cluster_permutation_freq/).

I have data from one MEG subject recorded in an Elekta Neuromag system and
would like to do a within trials analysis on that subject (experimental
trials vs. control trials). However,   my ft_freqstatistics outputs a
matrix stat.stat full of NaNs.
I am hoping to get some help with identifying the error in my pipeline.

These are my steps:

*1. I start by loading the two data structures corresponding to the Exp and
Ctr trials (selecting only the gradiometer channels).*
*Data fields*:
data_Exp =
struct with fields:
label: {202×1 cell}
trialinfo: [90×1 double]
sampleinfo: [90×2 double]
trial: {1×90 cell}
time: {1×90 cell}
cfg: [1×1 struct]
fsample: 1.0000e+03
 grad: [1×1 struct]

data_Ctr =
struct with fields:
label: {202×1 cell}
trialinfo: [90×1 double]
sampleinfo: [90×2 double]
trial: {1×90 cell}
time: {1×90 cell}
cfg: [1×1 struct]
fsample: 1.0000e+03
grad: [1×1 struct]

*3. Run the frequency analysis on both data structures. *
*CFG*:
cfg = [];
cfg.output = 'pow';
cfg.channel = {'MEGGRAD','-MEG1843', '-MEG2122'};
cfg.taper = 'hanning';
cfg.method = 'mtmconvol';
cfg.foi          = 10;%2:2:30;%1:30
numfoi = length(cfg.foi);
cfg.t_ftimwin    =  ones(length(cfg.foi),1).* 0.5;%1;
cfg.toi          = [-1 : 0.05: 3.6];
cfg.keeptrials = 'yes';
tfr_data_Exp = ft_freqanalysis(cfg, data_Exp);

cfg = [];
cfg.output = 'pow';
cfg.channel = {'MEGGRAD','-MEG1843', '-MEG2122'};
cfg.taper = 'hanning';
cfg.method = 'mtmconvol';
cfg.foi          = 10; %2:2:30;
numfoi = length(cfg.foi);
cfg.t_ftimwin    =  ones(length(cfg.foi),1).* 0.5;
cfg.toi          = [-1 : 0.05: 3.6];
cfg.keeptrials = 'yes';
tfr_data_Ctr = ft_freqanalysis(cfg, data_Ctr);

*Data fields:*
e.g. (and similar to the structure of  tfr_data_Exp)
tfr_data_Ctr =
  struct with fields:
       label: {202×1 cell}
       dimord: 'rpt_chan_freq_time'
       freq: 10.0000
       time: [1×93 double]
       powspctrm: [90×202×1×93 double]
      cumtapcnt: [90×1 double]
      grad: [1×1 struct]
       trialinfo: [90×1 double]
      cfg: [1×1 struct]

*3. Combine planar gradiometers of the time-frequency data (e.g.
tfr_data_Exp)*
*CFG*:
cfg = [];
cfg.method = 'sum';
freqEXP_planar_cmb = ft_combineplanar(cfg,tfr_data_Exp);

cfg = [];
cfg.method = 'sum';
freqCTR_planar_cmb = ft_combineplanar(cfg,tfr_data_Ctr);

*Data fields:*
e.g. (and similar to the structure of freqEXP_planar_cm)
freqCTR_planar_cmb =
struct with fields:
label: {102×1 cell}
dimord: 'rpt_chan_freq_time'
freq: 10.0000
time: [1×93 double]
powspctrm: [90×102×1×93 double]
cumtapcnt: [90×1 double]
grad: [1×1 struct]
trialinfo: [90×1 double]
cfg: [1×1 struct]

*4.  Combine planar gradiometers also for the initial data structures
(i.e. data_Exp )*
*CFG*:
cfg = [];
cfg.method = 'sum';
data_Exp_cmb = ft_combineplanar(cfg,data_Exp);

*Data fields:*
data_Exp_cmb =
struct with fields:
label: {102×1 cell}
trialinfo: [90×1 double]
sampleinfo: [90×2 double]
trial: {1×90 cell}
time: {1×90 cell}
cfg: [1×1 struct]
fsample: 1.0000e+03
grad: [1×1 struct]

*5. Prepare neighbours, design, and run ft_freqstatistics*
*CFG*:
cfg = [];
cfg.channel          = {'MEGGRAD','-MEG1843', '-MEG2122'};
cfg.latency          = 'all';
cfg.frequency        = 10;
cfg.method           = 'montecarlo';
cfg.statistic        = 'ft_statfun_indepsamplesT';
cfg.correctm         = 'cluster';
cfg.clusteralpha     = 0.05;
cfg.clusterstatistic = 'maxsum';
cfg.minnbchan        = 2;
cfg.tail             = 0;
cfg.clustertail      = 0;
cfg.alpha            = 0.025;
cfg.numrandomization = 500;
% prepare_neighbours determines what sensors may form clusters
cfg_neighb.method    = 'distance';
cfg_neighb.template  = 'neuromag306plan.mat';
cfg.neighbours       = ft_prepare_neighbours(cfg_neighb, *data_Exp_cmb*);

design = zeros(1,size(freqCTR_planar_cmb.powspctrm,1) +
size(freqEXP_planar_cmb.powspctrm,1));
design(1,1:size(freqCTR_planar_cmb.powspctrm,1)) = 1;
design(1,(size(freqCTR_planar_cmb.powspctrm,1)+1):(size(freqCTR_planar_cmb,1)+...
size(freqEXP_planar_cmb.powspctrm,1))) = 2;

cfg.design           = design;
cfg.ivar             = 1;

[stat] = ft_freqstatistics(cfg, *freqCTR_planar_cmb, freqEXP_planar_cmb*);

*Data fields:*
stat.stat is a matrix full of NaN

stat.prob is a matrix of just ones

stat =
struct with fields:
stat: [102×1×93 double]
prob: [102×1×93 double]
cirange: [102×1×93 double]
mask: [102×1×93 logical]
ref: [102×1×93 double]
dimord: 'chan_freq_time'
freq: 10.0000
grad: [1×1 struct]
label: {102×1 cell}
time: [1×93 double]
cfg: [1×1 struct]

*Warning:*
When running the ft_frestatistics I get the repeated warning:

(...)
Warning: Not all replications are used for the computation of the
statistic.
Warning: Not all replications are used for the computation of the
statistic.
Warning: Not all replications are used for the computing statistic 498 from
0
Warning: Not all replications are used for the computation of the
statistic.
Warning: Not all replications are used for the computation of the
statistic.
Warning: Not all replications are used for the computing statistic 500 from
0
(...)


Many many thanks!

Ana
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190201/dbb0e727/attachment-0001.html>


More information about the fieldtrip mailing list