Back to the main page.

Bug 2606 - Problem with ft_timelockstatistics (montecarlo) with avgoverchan = 'yes'

Status CLOSED DUPLICATE
Reported 2014-06-10 15:18:00 +0200
Modified 2019-08-10 12:28:30 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P5 normal
Assigned to: Eelke Spaak
URL:
Tags:
Depends on:
Blocks:
See also:

Heidi - 2014-06-10 15:18:39 +0200

I tried running a cluster test on some MEG data where I'd like to average over selected sensors. This does not work. The test runs just fine if i do it without averaging over sensors, so clearly this seems to be the problem... --- Configuration --- cfg = []; cfg.avgovertime = 'no'; cfg.parameter = 'avg'; cfg.method = 'montecarlo'; % see ft_statistics_montecarlo cfg.correctm = 'cluster'; % multiple-comparison correction cfg.statistic = 'depsamplesT'; cfg.tail = 0; % two-sided test cfg.alpha = 0.05; cfg.correcttail = 'alpha'; % bonferroni correction cfg.clusteralpha = 0.05; cfg.clusterstatistic = 'maxsum'; % load('/home/predatt/heisol/3018012.05_heisol/meg/gavg/neighbours.mat'); cfg.neighbours = neighbours; design = zeros(2,2*Nsub); for i = 1:Nsub design(1,i) = i; end for i = 1:Nsub design(1,Nsub+i) = i; end design(2,1:Nsub) = 1; design(2,Nsub+1:2*Nsub) = 2; cfg.design = design; cfg.uvar = 1; % "unit variable" (subject) cfg.ivar = 2; % independent variable (condition) cfg.numrandomization = 5000; cfg.latency = [0.1 0.4]; cfg.channel = sensors_lefttemp; cfg.avgoverchan = 'yes'; Test = ft_timelockstatistics(cfg, Condition1{:}, Condition2{:}); --- Input data and sensor selection --- % 24 subject averages: Condition1 = Columns 1 through 7 [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] Columns 8 through 14 [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] Columns 15 through 21 [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] Columns 22 through 24 [1x1 struct] [1x1 struct] [1x1 struct] % .. of which one looks like this: Condition1{1} = time: [1x1560 double] label: {274x1 cell} dimord: 'chan_time' cfg: [1x1 struct] avg: [274x1560 double] % selected sensors: sensors_lefttemp = 104 99 100 108 101 106 109 102 110 107 --- Matlab output --- averaging over 10 channels selected 361 time bins selected 1 frequency bins using "ft_statistics_montecarlo" for the statistical testing using "ft_statfun_depsamplesT" for the single-sample statistics constructing randomized design total number of measurements = 48 total number of variables = 2 number of independent variables = 1 number of unit variables = 1 number of within-cell variables = 0 number of control variables = 0 using a permutation resampling approach repeated measurement in variable 1 over 24 levels number of repeated measurements in each level is 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 computing a parametric threshold for clustering computing statistic estimated time per randomization is 0.02 seconds computing statistic 5000 from 5000 Error using findcluster (line 56) invalid dimension of spatdimneighbstructmat Error in clusterstat (line 185) posclusobs = findcluster(reshape(postailobs, [cfg.dim,1]),channeighbstructmat,cfg.minnbchan); Error in ft_statistics_montecarlo (line 369) [stat, cfg] = clusterstat(cfg, statrand, statobs); Error in statistics_wrapper (line 308) [stat, cfg] = statmethod(cfg, dat, design); Error in ft_timelockstatistics (line 113) [stat, cfg] = statistics_wrapper(cfg, varargin{:});


Eelke Spaak - 2014-06-10 15:29:19 +0200

(In reply to Heidi from comment #0) I can reproduce this with artificial data.


Jan-Mathijs Schoffelen - 2014-06-10 15:32:19 +0200

this sounds like a duplicate of bug 2479 a workaround would be to specify cfg.neighbours = [] and cfg.connectivity = true; prior to calling ft_timelockstatistics. The clustering code gets confused when avgoverchan = 'yes', essentially reducing the spatial dimensionality to a singleton, while the cfg.neighbours are converted into an nchanxnchan connectivity matrix.


Eelke Spaak - 2014-06-10 15:50:50 +0200

indeed duplicate, will commit fix soon *** This bug has been marked as a duplicate of bug 2479 ***


Robert Oostenveld - 2019-08-10 12:28:30 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on https://github.com/fieldtrip/fieldtrip/issues.