[FieldTrip] Problem with clustering across electrode neighbours

Duncan Astle Duncan.Astle at mrc-cbu.cam.ac.uk
Fri Sep 14 16:58:26 CEST 2012

Thanks for your help. You were spot on; now the version is updated it runs perfectly.


Dr. Duncan Astle,
Programme Leader Track,
British Academy Research Fellow,
MRC Cognition and Brain Sciences Unit,
Chaucer Road,
Duncan.Astle at mrc-cbu.cam.ac.uk

From: fieldtrip-bounces at science.ru.nl [mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of "Jörn M. Horschig"
Sent: 13 September 2012 12:11
To: FieldTrip discussion list
Subject: Re: [FieldTrip] Problem with clustering across electrode neighbours

Hey Duncan,

it looks pretty much like you are using an old FieldTrip version with a new neighbourhood-structure. Could you check the with the most recent version again?
Some months (about a year?) ago we changed the neighbour definition from cell arrays to structure arrays, so any attempt to access cfg.neighbours{i} will fail, cause it has to be cfg.neighbours(i) instead. But as I already said, this has been changed quite some time back in the past :)

Essentially, your code is fine, but some note that cfg.neighbourdist should be a scalar, not the string 'number', but only if cfg.method='distance'. If you choose cfg.method = 'template' then cfg.neighbourdist is not used, cause a template is loaded.


On 9/13/2012 12:46 PM, Duncan Astle wrote:
Dear Fieldtrippers,

I am rather new to this, but am attempting to do some cluster stats on my ERP sensor level data. It is working well, and I can cluster across time, but I can't get it to cluster across electrode locations. I think it is because of a mistake that I am making in my 'neighbours' file, although it looks fine when I inspect it. This is the error message that I get:

??? Cell contents reference from a non-cell array object.

Error in ==> clusterstat>makechanneighbstructmat at 520
    [seld] = match_str(cfg.channel, cfg.neighbours{chan}.label);

Error in ==> clusterstat at 60
    channeighbstructmat = makechanneighbstructmat(cfg);

Error in ==> statistics_montecarlo at 322
  [stat, cfg] = clusterstat(cfg, statrand, statobs,'issource',issource);

Error in ==> statistics_wrapper at 285
    [stat, cfg] = statmethod(cfg, dat, cfg.design, 'issource',issource);

Error in ==> ft_timelockstatistics at 119
[stat, cfg] = statistics_wrapper(cfg, varargin{:});

Can anyone spot what I am doing wrong?

This is how I make my neighbour file:

cfg = [];
cfg.layout      = 'EEG1010.lay'; % try 'distance' as well
cfg.feedback    = 'yes'; % show a neighbour plot
cfg.method      = 'template';
cfg.neighbourdist = 'number';
cfg.template      = 'EEG1010_neighb.mat'
cfg.channel       = 'all'
cfg.feedback      = 'yes';
neighbours      = ft_prepare_neighbours(cfg, Load5Hard); % define neighbouring channels

This is how I then try the stats:

    cfg = [];
    cfg.channel     = 'all';
    cfg.latency     = [0.1 1.3];
    cfg.avgovertime = 'no';
    cfg.avgoverchannel = 'no';
    cfg.parameter   = 'individual';
    cfg.method      = 'montecarlo';
    cfg.statistic   = 'depsamplesT'
    cfg.alpha       = 0.05;
    cfg.correctm    = 'cluster';
    cfg.correcttail = 'prob';
    cfg.numrandomization = 1000;
    cfg.feedback    = 'yes'; % show a neighbour plot
    cfg.neighbours  = neighbours;
    %cfg.minnbchan        = 2;
    cfg.clusterstatistic = 'maxsum';
    cfg.clusterthreshold = 'nonparametric';
    cfg.clusteralpha     = 0.01;
    cfg.clustercritval   = 0.06;
   % cfg.clustertail      = 0;
    cfg.tail = 0;
    Nsub = 19;
    cfg.design(1,1:2*Nsub)  = [ones(1,Nsub) 2*ones(1,Nsub)];
    cfg.design(2,1:2*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

[stat] = ft_timelockstatistics(cfg, Load3Hard, Load3Easy)

Any suggestions very gratefully received.

Dr. Duncan Astle,
Programme Leader Track,
British Academy Research Fellow,
MRC Cognition and Brain Sciences Unit,
Chaucer Road,
Duncan.Astle at mrc-cbu.cam.ac.uk<mailto:Duncan.Astle at mrc-cbu.cam.ac.uk>


fieldtrip mailing list

fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>



Jörn M. Horschig

PhD Student

Donders Institute for Brain, Cognition and Behaviour

Centre for Cognitive Neuroimaging

Radboud University Nijmegen

Neuronal Oscillations Group

FieldTrip Development Team

P.O. Box 9101

NL-6500 HB Nijmegen

The Netherlands


E-Mail: jm.horschig at donders.ru.nl<mailto:jm.horschig at donders.ru.nl>

Tel:    +31-(0)24-36-68493

Web: http://www.ru.nl/donders

Visiting address:

Trigon, room 2.30

Kapittelweg 29

NL-6525 EN Nijmegen

The Netherlands
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20120914/7507790a/attachment-0002.html>

More information about the fieldtrip mailing list