Back to the main page.

Bug 1546 - calling resampledesign with a control variable can yield incoherent results

Status ASSIGNED
Reported 2012-06-21 21:31:00 +0200
Modified 2012-06-22 09:24:46 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P3 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Saskia Helbling - 2012-06-21 21:31:03 +0200

Hej, it seems to me that resampledesign implicitely assumes that levels of the control variable are entered into the design matrix in a blockwise fashion and in ascnding order. If these assumptions are violated columns of the returned resample matrix are not in the correct order. The following code snippet should produce the permutations for an independent T-test with a control variable in the second row of the design matrix. resampledesign would be expected to return a resample matrix where entries in odd columns were only permuted with entries in odd columns, and entries in even columns only with those in even columns, respectively. clear a = 2; b = 2; n = 3; design = [repmat([1 1 2 2],1,n); repmat([1,2],1,b*n)]; % design = % % 1 1 2 2 1 1 2 2 1 1 2 2 % 1 2 1 2 1 2 1 2 1 2 1 2 cfg.ivar = [1]; cfg.cvar = [2]; cfg.numrandomization = 10; cfg.resampling = 'permutation'; cd('PATH_TO_FIELDTRIP\private') resample = resampledesign(cfg, design); Instead, resampledesign returns a resample matrix where the first columns only contain odd and the later columns only even values. Replacing line 130 resample = cat(2, blockres{:}); with resample(:,cat(2, blocksel{:})) = cat(2, blockres{:}); seems to resolve the problem. I used version fieldtrip-20120618. Cheers Saskia


Robert Oostenveld - 2012-06-22 09:24:46 +0200

thanks! Mainly as a reminder to myself when I look in the details: have a look at http://fieldtrip.fcdonders.nl/faq/how_can_i_use_the_ivar_uvar_wvar_and_cvar_options_to_precisely_control_the_permutations and fieldtrip/test/test_resampledesign.m which is not in the ftp version (but is in svn), see http://code.google.com/p/fieldtrip/source/browse/trunk/test/test_resampledesign.m