[FieldTrip] ft_freqstatistics on grandaveraged TFR data

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Thu Jan 12 17:06:05 CET 2017


No worries, Kelly, but just to be sure: from your initial e-mail I got the impression that you wanted to do statistical inference across subjects, not across trials (within a signle subject).
Specifying cfg.keeptrials before calling ft_freqanalysis should be done for the latter, not for the former type of statistical inference.

Best,
Jan-Mathijs


J.M.Schoffelen
Senior Researcher, VIDI-fellow
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands

On 12 Jan 2017, at 16:17, Murphy, Kelly (Research Student) <murphyk5 at aston.ac.uk<mailto:murphyk5 at aston.ac.uk>> wrote:

Thank you for your help Jan.  Indeed, it was as simple as adding 'cfg.keeptrials = 'yes'' in my initial time-frequency analyses.

Sorry to have encumbered you with what turned out to be a very trivial problem.

Your help is much appreciated!

K
________________________________
From: fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl> [fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>] on behalf of Schoffelen, J.M. (Jan Mathijs) [jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>]
Sent: 12 January 2017 11:19
To: FieldTrip discussion list
Subject: Re: [FieldTrip] ft_freqstatistics on grandaveraged TFR data

Hi Kelly,

Well, obviously ‘chan_freq_time’ as a dimord is not appropriate to do an inferential statistical test. You need a ‘rpt’ (or ‘subj’) dimension in your data.

As long as this has not been sorted out, it is no use to call ft_clusterplot.

The best current practice is to input into ft_freqstatistics a cell-array of structures (so ft_freqgrandaverage should not be used).
An alternative would be to use ft_appendfreq

The following pseudo-code should get you on track. If not, please consult the fieldtrip-wiki for similar examples

Nsubj = <the number of subjects>
for k = 1:Nsubj
  load(<data for subject k in condition 1>);
  S1{k} = data;
  load(<data for subject k in condition 2>);
  S2{k} = data;
end

cfg = [];
cfg ….
cfg.design = [ones(1,Nsubj) ones(1,Nsubj)*2;1:Nsubj 1:Nsubj];
cfg.ivar = 1;
cfg.uvar = 2;
cfg.statistic = ‘depsamplesT’;
stat = ft_freqstatistics(cfg, S1{:}, S2{:});


Best,
Jan-Mathijs



J.M.Schoffelen
Senior Researcher, VIDI-fellow
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands

On 10 Jan 2017, at 15:36, Murphy, Kelly (Research Student) <murphyk5 at aston.ac.uk<mailto:murphyk5 at aston.ac.uk>> wrote:

Many thanks for your reply Jan-Mathijs,

Indeed for both structures, '.dimord' reads 'chan_freq_time'.  I can now get ft_freqstatistics to run sensibly but only when I add code so design(2,:)  to show 18 and 28 (i.e. group 1 n=8, group 2 n=8).  However, when I try to run ft_clusterplot I get the following error message, when stat.stat has the same chan_freq_time dimensions as ft_freqanalysis and ft_freqstatistics outputs (204x48x76).  This leads me to believe you are correct in pointing out that I have made a mistake in formatting my variables along the line:

"Error using ft_clusterplot (line 144)
this only works if either frequency or time is a singleton dimension"

Your help so far has been very valuable; but I am still unsure as to where I have gone wrong.

Thank you

Kelly

PhD candidate
Department of Psychology
Aston University
Birmingham B4 7ET
United Kingdom


________________________________
From: fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl> [fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>] on behalf of Schoffelen, J.M. (Jan Mathijs) [jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>]
Sent: 10 January 2017 13:40
To: FieldTrip discussion list
Subject: Re: [FieldTrip] ft_freqstatistics on grandaveraged TFR data

Hi Kelly,
It could be that you made a small mistake in formatting the input data to ft_freqstatistics (T_LLL and T_LLH). You may want to check whether these data structures have a ‘dimord’ which reads ‘rpt_chan_freq(_time)' or ‘subj_chan_freq(_time)’.

Best,
Jan-Mathijs



J.M.Schoffelen
Senior Researcher, VIDI-fellow
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands



On 09 Jan 2017, at 22:44, Murphy, Kelly (Research Student) <murphyk5 at aston.ac.uk<mailto:murphyk5 at aston.ac.uk>> wrote:

Hello Fieldtrippers,

I am trying to use a monte carlo permutation test using ft_freqstatistics on grandaveraged data over 8 participants for two independent conditions but I am struggling to create the correct design matrix using the following code:

cfg = [];   cfg.method = 'montecarlo';    cfg.computestat = 'yes';  cfg.statistic = 'indepsamplesT'; cfg.numrandomization = 500;   cfg.correctm = 'fdr';  cfg.computecritval = 'yes'; cfg.alpha = 0.025; cfg.tail = 0; cfg.clustertail = 0;   cfg.clusterstatistic = 'maxsum';    cfg.minnbchan = 2;
design = zeros(1,size(T_LLL.powspctrm,1) + size(T_LLH.powspctrm,1));
design(1,1:size(T_LLL.powspctrm,1)) = 1;
design(1,(size(T_LLL.powspctrm,1)+1):(size(T_LLL.powspctrm,1)+size(T_LLH.powspctrm,1))) = 2;
cfg.design           = design;
cfg.ivar             = 1;
[stat] = ft_freqstatistics(cfg, T_LLL, T_LLH);

I am left with the following error message:
"Error using ft_freqstatistics (line 174)
the length of the design matrix (1) does not match the number of observations
in the data (2)"


I am struggling to see what errors I am making and I have tried my best to adhere to the guidelines outlined on the Fieldtrip tutorials, so if anyone with a keen eye can offer any help it would be most appreciated!

Many thanks

Kelly


PhD candidate
Department of Psychology
Aston University
Birmingham B4 7ET
United Kingdom

_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip


_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip



_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170112/35354fa1/attachment-0002.html>


More information about the fieldtrip mailing list