clusterstats empty cfg.neighbours, cfg.neighbours example

Chetan Sharma chesharm at STANFORD.EDU
Sat Feb 27 08:15:21 CET 2010

Hello everyone,

I'm trying to run the coherence Z nonparametric test to detect synchrony
between two channels of MEG data. Because of how restrictive bonferoni, FDR,
and all are, we wanted to use the 'cluster' function for cfg.correctm. This
call to statistics_montecarlo.m, which says in the description that to do
clustering in frequency and time, as we want to do, we should use an empty
cfg.neighbours structure. However, when the function calls clusterstats.m,
it looks like there is a bug in the code. The relevant code is at line 38 in
clusterstats.m, and is:

if isfield(cfg, 'neighbours') && ~isempty(cfg.neighbours)
  channeighbstructmat = makechanneighbstructmat(cfg);
  issource = 0;
  issource = 1;
  % cfg contains dim and inside that are needed for reshaping the data to a
volume, and inside should behave as a index vector
  cfg = fixinside(cfg, 'index');

The issue is that the case for an empty cfg.neighbours isn't handled.
Running the function with an empty cfg.neighbours leads to a bug when
calculating the clusters, and makes issource=1, when it should be zero for
freq_time data. The function runs through when I manually set issource=0,
but I don't know if that is the intended purpose.

Has anyone else run into this problem? Without an example of what
cfg.neighbours should look like, it's hard to determine if we are doing a
correct setup. Could someone either send an example of cfg.neighbours, or
verify this bug and suggest solutions?

thanks and regards,

The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also and
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the fieldtrip mailing list