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

Eelke Spaak eelke.spaak at donders.ru.nl
Tue Oct 28 09:15:12 CET 2014

```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:
http://blogs.mathworks.com/loren/2006/06/21/cell-arrays-and-their-contents/
.

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
ft_freqstatistics.

Best,
Eelke

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
>

```