[FieldTrip] Cluster-based permutation tests for between-subject design

Frédéric Roux f.roux at bcbl.eu
Tue Nov 4 11:59:18 CET 2014

Dear all,

I would like to follow up on this, as I am currently struggling myself with the coding of the design matrix of my analysis.

I have MEG data from n = 95 participants aged between 12 and 27 years on a WM-task with 3 WM-load conditions.

I would like to investigate the effects of age (continuous variable ranging from 12 to 27) and WM-load (categorical variable ranging from 1-3) on delay-activity
in different frequency-bands.

What would be the correct way to perform such an analysis in fieldtrip?

Would this be akin to a mixed-effects design?

Best regards,


Frédéric Roux

----- Original Message -----
From: "Eric Maris" <e.maris at psych.ru.nl>
To: "FieldTrip discussion list" <fieldtrip at science.ru.nl>
Sent: Friday, October 31, 2014 4:56:16 PM
Subject: Re: [FieldTrip] Cluster-based permutation tests for	between-subject	design

Dear Dylan, 

I replied to your question on the Fieldtrip faq page that you refer to. Although the problem can be solved, it is not implemented yet, because it requires the implementation of three new statfuns: Hotelling’s T-square for dependent samples, Hotelling’s T-square for independent samples, and Wilk’s lambda. A good statistics book (e.g., Johnson & Wichern) will show you how to do this yourself. Otherwise, you have to be patient. 

Although your statistical problem can be solved, with neurobiological data, it is almost never wise to statistically test interaction effects in designs more complicated than the 2-by-2 factorial design. In these more complicated designs, you always end up with F-tests, which do not inform you about the pattern in the data that is responsible for the interaction effect. 



From: Dylan DeLosAngeles [mailto:dylan.delosangeles at gmail.com] 
Sent: dinsdag 28 oktober 2014 13:22 
To: FieldTrip discussion list 
Subject: Re: [FieldTrip] Cluster-based permutation tests for between-subject design 

Thank you, Eelke. 
I'm sorry I am not picking this up more quickly. 

Your examples of passing either multiple structs or cell arrays to ft_freqstatistics deals with one group of subjects in multiple conditions, or two groups in one condition, respectively. I have two groups, both doing multiple (11) conditions and I would like to know how to handle that in ft_freqstatistics. What I require seems to be similar to what Eric Maris wrote about here: 


but instead of a 2-by-2 factorial design, I am using a 2-by-11 factorial design. As such, I am not sure how this translates when making difference data structures. I hope I am not missing something obvious. 

Thanks again, 


On Tuesday, 28 October 2014, Eelke Spaak < eelke.spaak at donders.ru.nl > wrote: 

Dear Dylan, 

You don't want (or need) a single struct with a subj X chan X freq X 
time powspctrm. Instead, it is often convenient to collect each 
individual subject's struct in a *cell* array (rather than a struct 
array). See, for example, here: 
http://www.mathworks.nl/help/matlab/cell-arrays.html and here: 

At the statistics step you should pass in multiple structs, each one 
corresponding to one unit-of-observation, to ft_freqstatistics. This 
can be done like so: 

stat = ft_freqstatistics(cfg, struct11, struct12, 
struct13,...struct21, struct22, ...); 

or, using the cell arrays, like so: 

stat = ft_freqstatistics(cfg, groupA{:}, groupB{:}); 

Make sure that each column in your design matrix describes one 
unit-of-observation, in the order in which the structs are passed into 


On 21 October 2014 03:41, Dylan DeLosAngeles 
< dylan.delosangeles at gmail.com > wrote: 
> Dear Eelke, 
> Thank you for help regarding cluster-based permutation analysis of two or more conditions. 
> I am using time-frequency data (not time-lock structures). My first problem seems to be getting my 12 subjects into the 4D powspectrum. 
> My code below loads 12 subjects from the first group, but I end up with a 1 x 12 struct where each struct's .powspctrm is 1 subject x 11 electrodes x 3 frequencies x 2049 time points, rather than one struct with a 4D powspctrm with 12 subjects as rows x electrodes x freqs x time points. 
> for k = 1:Nmt, % states 
> for i = 1%:Ng, % groups 
> for j = 1:Ns, % subjects 
> % load files 
> p(j) = eeg3.eeg.load(fullfile(fpath,fname2)); 
> % convert to eeglab to get channel locations 
> EEG(j) = eeg2eeglab( p(j)); 
> EEG(j) = pop_chanedit( EEG(j), 'lookup', chanlocfile); 
> % preprocessing in fieldtrip 
> d(j) = eeglab2fieldtrip( EEG(j), 'preprocessing'); 
> % specify length of time to use in config 
> time = EEG(j).xmax-EEG(j).xmin; 
> % setup configuration for freqanalysis 
> cfg = []; % clear cfg 
> cfg.output = 'pow'; 
> cfg.channel = 'EEG'; 
> cfg.method = 'mtmconvol'; 
> cfg.taper = 'hanning'; 
> cfg.foi = 0.5:3; % delta 
> cfg.toi = 1:0.05:time; % length of each state 
> cfg.t_ftimwin = 7./cfg.foi; % 7 cycles 
> cfg.keeptrials = 'yes'; 
> % do freqanalysis 
> freqdata(j) = ft_freqanalysis( cfg, d(j)); 
> end 
> end 
> end 
> My second problem is loading in the second group of 12 subjects and what that will look like when I run ft_freqstatistics. 
> Lastly, I just want to confirm what you said in your previous email, that I should be using indepsamplesF for more than two conditions (I have 11), and therefore my design should look like this; 
> 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 (two groups) 
> 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 (11 conditions) 
> Any help would be appreciated. 
> Kind regards, 
> Dylan 
> On Wed, Sep 24, 2014 at 3:29 PM, Eelke Spaak < eelke.spaak at donders.ru.nl <mailto: eelke.spaak at donders.ru.nl >> wrote: 
> Hello Dylan, 
> You can analyse a between-subjects design exactly as you would a 
> between-trials design (at least as far as the statistics step is 
> concerned), in both cases the two conditions correspond to two groups 
> of observations, and not to the same group of observations measured in 
> two separate conditions (which would be a within-UO design). In 
> FieldTrip, you would typically compute averages per subject, then use 
> an "indepsamplesT" (or indepsamplesF with >2 conditions) statistic 
> (not depsamples). indepsamplesT only requires one row in the design 
> matrix, indicating the condition. 
> Note that if you have e.g. timelock structures in two (or more) cell 
> arrays, corresponding to the conditions, you can input them into the 
> statistics function as follows: 
> stat = ft_timelockstatistics(cfg, tlCondA{:}, tlCondB{:}); 
> without having to call ft_timelockgrandaverage. In fact, the above is 
> the preferred way to do statistics now. (The same holds for 
> ft_freqstatistics.) 
> Hope that helps, 
> Best, 
> Eelke 
> On 24 September 2014 02:32, Dylan DeLosAngeles 
> < dylan.delosangeles at gmail.com <mailto: dylan.delosangeles at gmail.com >> wrote: 
>> Hello, 
>> So far, the tutorial on "Cluster-based permutation tests on time-frequency 
>> data" has been very helpful. 
>> Out of the four combinations from the two UO-types (subjects and trials) and 
>> the two experimental designs (between- and within-UO), the tutorial covers 
>> statistics on data in two conditions in a between-trials, in a within-trials 
>> and in a within-subjects design. However, I am wondering if there is any 
>> information about the fourth type of experiment design: between-subjects. 
>> I have data for 2 groups with 12 subjects in each group. Both groups are 
>> measured during 11 conditions. 
>> Can I approach this in a similar fashion to within-subjects design (multiple 
>> subjects in multiple experimental conditions), such that my design is 
>> multiple groups in multiple experimental conditions. Is it a case of first 
>> averaging over all trials belonging to each of the experimental conditions 
>> for each subject (as instructed in tutorial), and then averaging over all 
>> subjects in each group? 
>> Configuration code for setting up the design currently looks like this; 
>> grp = 2; 
>> subj = 11; 
>> design = zeros(2, subj*grp); 
>> for i = 1:grp 
>> design(1,i:2:end) = i; 
>> end 
>> idx = 1; 
>> for i = 1:subj 
>> design(2,idx:idx+1) = i; 
>> idx = idx+2; 
>> end 
>> Is there anything else I need to take into consideration when doing these 
>> statistics? 
>> Thank you, 
>> Dr Dylan DeLosAngeles 
>> Research Fellow 
>> Brain Signal Laboratory 
>> Flinders University 
>> _______________________________________________ 
>> fieldtrip mailing list 
>> fieldtrip at donders.ru.nl <mailto: fieldtrip at donders.ru.nl > 
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip 
> _______________________________________________ 
> fieldtrip mailing list 
> fieldtrip at donders.ru.nl <mailto: fieldtrip at donders.ru.nl > 
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip 

fieldtrip mailing list 
fieldtrip at donders.ru.nl 
fieldtrip mailing list
fieldtrip at donders.ru.nl

More information about the fieldtrip mailing list