[FieldTrip] Help with between-trials single subject permutation (ft_freqstatistics output is stat.sta NaN NaN NaN ....)
Arana, S.L. (Sophie)
S.Arana at donders.ru.nl
Mon Feb 4 13:16:05 CET 2019
Hi Tara,
indeed the powspctrm fields are the same.
However, in the code the field 'powspctrm' is missing alltogether so that size(freqCTR_plana_cmb) is simply 1 as that is the size of the structure not the powspctrm field.
As Ana is using the ft_statfun_indepsamplesT.m , the design matrix should have the length equivalent to number of trials across both conditions and each trial coded as either 1 or 2 depending on which condition it belongs to.
(see http://www.fieldtriptoolbox.org/walkthrough/ for more detailed description of design matrix)
Ana's code as far as I can see would lead to an unintended design matrix, containing 0s, which also results in the warning "Not all replications are used ..."
Best,
Sophie
________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of Tara van Viegen <taravanviegen at gmail.com>
Sent: Monday, February 4, 2019 12:19 PM
To: FieldTrip discussion list
Subject: Re: [FieldTrip] Help with between-trials single subject permutation (ft_freqstatistics output is stat.sta NaN NaN NaN ....)
Hi both,
I don't think that causes the problem, because from my understanding the powspctrm fields are the same size for both TFR structures.
Ana, are there NaNs in your powspctrm? (Just trying to figure out if there might already be an issue before the call to ft_freqstatistics).
Best,
Tara
On Mon, Feb 4, 2019 at 10:35 AM Arana, S.L. (Sophie) <S.Arana at donders.ru.nl<mailto:S.Arana at donders.ru.nl>> wrote:
Hi Ana,
I see one small mistake in your code, that might be causing your error message. It is in the way you define your design matrix. It should be
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.powspctrm,1)+...
size(freqEXP_planar_cmb.powspctrm,1))) = 2;
Hope this will fix your issue.
Best,
Sophie
___________________
M.Sc. Sophie L. Arana
Doctoral researcher
Neurobiology of Language - MPI for Psycholinguistics
Max Planck Institute for Psycholinguistics
PO Box 310, 6500 AH Nijmegen
Netherlands
T +31 24-3610887
E sophie.arana at mpi.nl<https://email.gwdg.de/owa/redir.aspx?C=vAwsHEoGIsQ-2a4fJkW7ELQAQ-WiQ9bLBwPShd-w11hUpFFgiRDVCA..&URL=mailto%3asophie.arana%40mpi.nl>
________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> on behalf of Ana Pesquita <anapesquita at gmail.com<mailto:anapesquita at gmail.com>>
Sent: Friday, February 1, 2019 9:30 PM
To: fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>
Subject: [FieldTrip] Help with between-trials single subject permutation (ft_freqstatistics output is stat.sta NaN NaN NaN ....)
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
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190204/bb73ecff/attachment-0002.html>
More information about the fieldtrip
mailing list