[FieldTrip] Cluster-based permutation tests - indepedent variable with 3 levels
Matteo Maran
maran at cbs.mpg.de
Mon Mar 16 11:41:11 CET 2020
Dear Fieldtrip users,
I would like to ask you if it is possible to run the cluster-based permutation tests in a within-subject design where one independent variable has more than two levels (e.g. 3). I have a 3x2 within-subject design, with subjects doing a language task in three different settings (A, B and C, which were administered in three different sessions). Factor 1 refers to the setting (setting A, setting B, setting C) and factor 2 to a contrast within the language task (correct item, incorrect item).
I have created 3 cells (all_setting_A, all_setting_B, all_setting_C) with, for each subject, the average of all the trials that were recorded respectively in the session with setting A, B and C. I then tried to run the cluster-based permutation test with the following code:
Nsub = length( all_setting_A);
cfg = [];
cfg.channel = 'EEG';
cfg.latency = [0 1];
cfg.avgovertime = 'no';
cfg.parameter = 'avg';
cfg.method = 'montecarlo';
cfg.statistic = 'depsamplesT';
cfg.correctm = 'cluster';
cfg.clusteralpha = 0.05;
cfg.clusterstatistic = 'maxsum';
cfg.minnbchan = 2;
cfg.neighbours = neighbours;
cfg.tail = 0;
cfg.clustertail = 0;
cfg.alpha = 0.025;
cfg.numrandomization = 1000;
cfg.design(1,1:3*Nsub) = [ones(1,Nsub) 2*ones(1,Nsub), 3*ones(1, Nsub)];
cfg.design(2,1:3*Nsub) = [1:Nsub 1:Nsub 1:Nsub];
cfg.ivar = 1; % the 1st row in cfg.design contains the independent variable
cfg.uvar = 2; % the 2nd row in cfg.design contains the subject number
main_setting_stat = ft_timelockstatistics(cfg, all_setting_A{:}, all_setting_B{:}, all_setting_C{:});
I then get the following error:
- Error using ft_statfun_depsamplesT (line 79)
Invalid specification of the design array.
- Error using ft_statistics_montecarlo (line 244)
could not determine the parametric critical value for clustering
-Error in ft_timelockstatistics (line 184)
[stat, cfg] = statmethod(cfg, dat, design);
If I check the line 79 of ft_statfun_depsamplesT, I see that the first error that I get (which then triggers the other two in ft_statistics_montercarlo and in ft_timelockstatistics) refers to this section:
% perform some checks on the design
sel1 = find(design(cfg.ivar,:)==1);
sel2 = find(design(cfg.ivar,:)==2);
n1 = length(sel1);
n2 = length(sel2);
if (n1+n2)<size(design,2) || (n1~=n2)
ft_error('Invalid specification of the design array.');
end
The design check generates the error because, since I have a third level, the statement (n1+n2)<size(design,2) is true (n1+n2 would be equal to 2/3 of size(design,2)). Should I then assume that the maximum number of levels of a variable for cluster-based permutation tests is 2? Or is it sufficient to create a copy of ft_statfun_depsamplesT where I allow a third level:
% perform some checks on the design
sel1 = find(design(cfg.ivar,:)==1);
sel2 = find(design(cfg.ivar,:)==2);
sel3 = find(design(cfg.ivar,:)==3);
n1 = length(sel1);
n2 = length(sel2);
n3 = length(sel3);
if (n1+n2+n3)<size(design,2) || (n1~=n2~=n3)
ft_error('Invalid specification of the design array.');
end
Since in principle by using difference waves it is possible to analyze any K-by-L factorial design (http://www.fieldtriptoolbox.org/faq/how_can_i_test_an_interaction_effect_using_cluster-based_permutation_tests/), I thought that it could be possible to analyze also a main effect with an independent variable with three levels. For example, with K = 3 and L = 2, a 3x2 interaction would be tested by comparing three difference waves.
Thank you for your help!
Best wishes,
Matteo Maran
More information about the fieldtrip
mailing list