[FieldTrip] Antw: Re: Wrong clustering of electrodes in newer FT versions?

"Jörn M. Horschig" jm.horschig at donders.ru.nl
Thu Nov 24 08:58:41 CET 2011


Hi Tobias,

thank you very much for tracking this down. I encountered a similar 
issue in ft_channelrepair a few months ago - some built-in 
Matlab-functions rearrange a cell-array of string alphabetically.
I'm gonna look into this now and also try to find out in which revision 
this lead to a problem.

Best,
Jörn

On 11/23/2011 7:08 PM, Tobias Staudigl wrote:
> Hi Gregor and Jörn,
>
> I find a simliar problem in my data (bti148).
> 2 sets of channels that share no connections across the sets are 
> included in one cluster.
>
> I am not sure, whether spm_bwlabel is the actual problem. However, I 
> do not really understand why calling that function would be necessary.
> FT calls the function spm_bwlabel during findcluster.m, line 95. 
> (findcluster.m is called by clusterstat.m).
> As far as I understand, spm_bwlabel is similar to bwlabel.m which 
> searches for connected bins in a matrix.
> The input to spm_label is the vector 'onoff' (in may case :148x1 
> logical), which already contains information about neighboring channels.
> Searching for connected bins in this vector does seem odd to me.
>
> However, I supsect something else to be the reason for the wrong 
> clustering, at least in my data.
> In line 166, ft_freqstatistics.m changes the order of the channel labels:
>
> chan = intersect(chan, varargin{i}.label);
>
> Original order: {'A68'; 'A58'; 'A148';...}
> Re-arranged in 'chan': {'A1';'A10';'A100'; 'A101'; 'A102';...}
>
> in line 193, ft_freqstatistics calls:
> cfg.channel = ft_channelselection(cfg.channel, chan);
>
> now cfg.channel contains the re-aranged order.
> On the basis of cfg.channel, the 'channeighbstructmat' is computed by 
> makechanneighbstructmat(cfg) in clusterstat.m.
> The statistics on the data is computed without re-arranging the 
> channels in statfun_depsamplesT.m ('statobs').
> In findcluster.m, line 84 (called during clusterstat.m, l. 197), the 
> matrices 'onoff' and 'selectmat' are multiplied.
> To my understanding, 'onoff' is based on the statistics that is 
> computed with the originial channel order.
> 'selectmat' is based on the re-arranged order.
> If true, the multiplication of these matrices is wrong.
>
> Hope this helps, although I might have missed something obvious and 
> might be totally wrong then.
>
> best,
> tobias
>
>
> Am 14.11.2011 17:46, schrieb Gregor Volberg:
>> Hi Jörn,
>> yes, sure I can provide you with some more information. I hope to do 
>> so due Wednesday.
>> Thanks a lot again for your kind support!
>> Gregor
>> -- 
>> Dr. rer. nat. Gregor Volberg 
>> <gregor.volberg at psychologie.uni-regensburg.de 
>> <mailto:gregor.volberg at psychologie.uni-regensburg.de>> ( 
>> mailto:gregor.volberg at psychologie.uni-regensburg.de )
>> University of Regensburg
>> Institute for Experimental Psychology
>> 93040 Regensburg, Germany
>> Tel: +49 941 943 3862
>> Fax: +49 941 943 3233
>> http://www.psychologie.uni-regensburg.de/Greenlee/team/volberg/volberg.html
>>
>>
>> >>> "Jörn M. Horschig"<jm.horschig at donders.ru.nl> 14.11.2011 09:51 >>>
>> Hi Gregor,
>>
>> that sounds indeed odd - although I am glad that I did not mess up 
>> something in prepare_neighbours ;)
>> However, when I look at the code, it seems that channeighbstructmat 
>> will only be used when ~issource, and the call to the spm function 
>> will only be when issource, so I cannot see a direct relation between 
>> these two. Could you provide some more information, e.g. in what line 
>> and function you observed the call to the spm function? If you like 
>> you could also create a bugreport on http://bugzilla.fcdonders.nl/ 
>> for this. In any case, one of us will then tackle your problem as 
>> soon as possible and try to solve it. I hope that we can reproduce 
>> your bug here, else we might ask for a snippet of your data/workspace.
>>
>> Thanks in any case for having a precise look at what is going on!
>>
>> Best,
>> Jörn
>>
>> On 11/11/2011 6:08 PM, Gregor Volberg wrote:
>>>
>>> Hi Jörn,
>>>
>>>
>>> thanks a lot for your response. I meanwhile checked some possible 
>>> reasons for the different clusterings and I am coming closer.
>>>
>>> I could reproduce the described error with two different datasets 
>>> (62 channel and 29 channel EEG), on two different computers and with 
>>> two different versions of fieldtrip (2011 versions).  First of all, 
>>> I checked the neighbourhood structures. They are identical in my two 
>>> analyses - same number of electrodes, same order, same neighbours. I 
>>> checked that before and after entering neighbours into the analyses 
>>> (by comparing the stat.cfg.neighbours) - they are the same.
>>>
>>> I then searched through the code and found the channeighbstructmat 
>>> that is constructed during the call of "clusterstat.m". I saved 
>>> these matrices during the call of ft_freqstatistics and found that, 
>>> with the same neighbourhood structures, the channeighbstructmat 
>>> looked  completely different in the old and new version. I then 
>>> changed the code of the new FT "clusterstat.m" so that it reads in 
>>> the channeighbstructmat obtained with the old FT version - then 
>>> everything works perfect.
>>>
>>>
>>> Thus, the problem is most likely an incorrect channeighbstructmat. I 
>>> figured out that in my case, FT calls an SPM8 function spm_bwlabeln 
>>> during construction of the channeighbstructmat, which older version 
>>> do not do. However, if I understood the code correctly, the SPM 
>>> function should only be called for source data?! Could it be that, 
>>> because my data is a 4D grand-average structure ( dimord: 
>>> 'subj_chan_freq_time'), FT assumes source data?
>>>
>>>
>>> Thanks again for your help,
>>>
>>> Gregor
>>>
>>>
>>>
>>>
>>>
>>> -- 
>>> Dr. rer. nat. Gregor Volberg 
>>> <gregor.volberg at psychologie.uni-regensburg.de> ( 
>>> mailto:gregor.volberg at psychologie.uni-regensburg.de )
>>> University of Regensburg
>>> Institute for Experimental Psychology
>>> 93040 Regensburg, Germany
>>> Tel: +49 941 943 3862
>>> Fax: +49 941 943 3233
>>> http://www.psychologie.uni-regensburg.de/Greenlee/team/volberg/volberg.html 
>>> <http://www.psychologie.uni-regensburg.de/Greenlee/team/volberg/volberg.html%0D>
>>>
>>>
>>> >>> "Jörn M. Horschig"<jm.horschig at donders.ru.nl> 11/9/2011 4:00 PM >>>
>>> Hi Gregor,
>>>
>>> did you check your neighbourselection? Maybe something is going 
>>> wrong there, given that a lot in this code has changed since 2010. 
>>> Could you check that using ft_neighbourplot? This would be the most 
>>> logical explanation why the results differ. It does not really make 
>>> sense that these three sensors form one cluster, because they should 
>>> not be neighbours of each other. So i would suppose that something 
>>> is going wrong there.
>>>
>>> Best,
>>> Jörn
>>>
>>>
>>> On 11/3/2011 4:57 PM, Michael Wibral wrote:
>>>
>>>> Hi Gregor,
>>>>
>>>> in principle the first level statistics that determine cluster 
>>>> membership (and thereby cluster shapes etc.)  can also vary from 
>>>> one set of permutations to the next, esp. on the borders of a 
>>>> cluster (this is why it is typically said that the localization of 
>>>> a cluster is not as trustworthy as its existence). Other resaons 
>>>> for differences are differing number of permutations - did you set 
>>>> everything the same?
>>>>
>>>> This said there might well be another problem - I hope the cluster 
>>>> people can have a look into it.
>>>>
>>>> Best ,
>>>> Michael
>>>>
>>>>
>>>>     ------------------------------------------------------------------------
>>>>     *Von:* "Gregor Volberg"
>>>>     <Gregor.Volberg at psychologie.uni-regensburg.de>
>>>>     *Gesendet:* Nov 2, 2011 6:34:43 PM
>>>>     *An:* fieldtrip at donders.ru.nl
>>>>     *Betreff:* [FieldTrip] Wrong clustering of electrodes in newer
>>>>     FT versions?
>>>>
>>>>     Dear fieldtrip community,
>>>>
>>>>
>>>>     I just encountered an unexpected behavior of FT that I would
>>>>     like to share with the list. It is that the cluster permutation
>>>>     test formed incorrect clusters from a given set of significant
>>>>     electrodes in newer FT versions (ft-20111012; I also tried with
>>>>     ft-20111028).
>>>>
>>>>
>>>>     For example, when using an old ft version (ft-20100810)  and
>>>>     freqstatistics I get a negative cluster with 17 contiguous
>>>>     electrodes. With the newer ft version, using the same data and
>>>>     the same cfg, three significant  electrodes that are spatially
>>>>     contiguous to the other significant electrodes are not included
>>>>     in the cluster. Also, three electrodes that are spatially
>>>>     seperated and are actually part of the first cluster are
>>>>     grouped into a separate cluster.  I attached a picture with the
>>>>     respective clusterplots where differences are marked with red
>>>>     arrows.
>>>>
>>>>     I am aware that the permutation p-value for a given cluster can
>>>>     be different in two separate analyses, but the grouping of
>>>>     significant electrodes into clusters should always be the same,
>>>>     am i right? I double-checked the cfg.neighbours, after
>>>>     conversion to new 'struct' style, and they were identical in
>>>>     the "old ft" and "new ft"  analysis. Also, the stat.stat field
>>>>     and the stat.cfg.clustercritval were the same for both
>>>>     analyses. Thus, the same neighbourhood relations and the same
>>>>     significant electrodes should be used for grouping. Yet I get
>>>>     different results...
>>>>
>>>>
>>>>     I am almost sure that this is trivial, but I could not yet
>>>>     replicate my old results with new FT and this makes me nervous.
>>>>     Has someone made a similar experience? Or do newer versions of
>>>>     ft use some further information besides cfg.neighbours for
>>>>     clustering, somewhere in the *cfg.previuous perhaps, that I am
>>>>     not aware of? Any comments are highly welcome.
>>>>
>>>>
>>>>     Best regards,
>>>>
>>>>     Gregor
>>>>
>>>>
>>>>     cfg = [];
>>>>
>>>>     cfg.neighbours    = neighbours;
>>>>
>>>>     cfg.minnbchan=1;
>>>>
>>>>     cfg.avgoverfreq   = 'yes';
>>>>
>>>>     cfg.avgovertime   = 'yes';
>>>>
>>>>     cfg.method        = 'montecarlo';
>>>>
>>>>     cfg.correctm       = 'cluster';
>>>>
>>>>     cfg.statistic     = 'depsamplesT';
>>>>
>>>>     cfg.tail          = 0;
>>>>
>>>>     cfg.alpha         = 0.05;
>>>>
>>>>     cfg.clusteralpha = 0.05;
>>>>
>>>>     cfg.numrandomization = 1000;
>>>>
>>>>     cfg.design = [[1:14 1:14]; [zeros(1,14)+1 zeros(1,14)+2]];
>>>>
>>>>     cfg.uvar          = 1;
>>>>
>>>>     cfg.ivar          = 2;
>>>>
>>>>     cfg.latency       = [2.24 2.53];
>>>>
>>>>     cfg.frequency     = [17 21];%
>>>>
>>>>     stat = ft_freqstatistics(cfg, DC, TC);
>>>>
>>>>
>>>>     --
>>>>     Dr. rer. nat. Gregor Volberg
>>>>     <gregor.volberg at psychologie.uni-regensburg.de> (
>>>>     mailto:gregor.volberg at psychologie.uni-regensburg.de )
>>>>     University of Regensburg
>>>>     Institute for Experimental Psychology
>>>>     93040 Regensburg, Germany
>>>>     Tel: +49 941 943 3862
>>>>     Fax: +49 941 943 3233
>>>>     http://www.psychologie.uni-regensburg.de/Greenlee/team/volberg/volberg.html
>>>>     <http://www.psychologie.uni-regensburg.de/Greenlee/team/volberg/volberg.html%0A>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>>
>>>>
>>>>      
>>>>
>>>> fieldtrip mailing list
>>>>
>>>>
>>>>    
>>>>
>>>> fieldtrip at donders.ru.nl
>>>>
>>>>
>>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>>
>>>>
>>>
>>>
>>> -- 
>>>
>>>
>>> Jörn M. Horschig
>>>
>>>
>>> PhD Student
>>>
>>>
>>> Donders Institute for Brain, Cognition and Behaviour
>>>
>>>
>>> Centre for Cognitive Neuroimaging
>>>
>>>
>>> Radboud University Nijmegen
>>>
>>>
>>> Neuronal Oscillations Group
>>>
>>>
>>>
>>>
>>> P.O. Box 9101
>>>
>>>
>>> NL-6500 HB Nijmegen
>>>
>>>
>>> The Netherlands
>>>
>>>
>>>
>>>
>>> Contact:
>>>
>>>
>>> E-Mail: 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
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>>
>> -- 
>> Jörn M. Horschig
>> PhD Student
>> Donders Institute for Brain, Cognition and Behaviour
>> Centre for Cognitive Neuroimaging
>> Radboud University Nijmegen
>> Neuronal Oscillations Group
>>
>> P.O. Box 9101
>> NL-6500 HB Nijmegen
>> The Netherlands
>>
>> Contact:
>> E-Mail: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
>>
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
> -- 
> Tobias Staudigl
> Fachbereich Psychologie - ZPR
> Postfach ZPR
> 78457 Konstanz
> ZPR, Haus 12
> Tel.: +49 (0)7531 / 88 - 5703
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip


-- 
Jörn M. Horschig
PhD Student
Donders Institute for Brain, Cognition and Behaviour
Centre for Cognitive Neuroimaging
Radboud University Nijmegen
Neuronal Oscillations Group

P.O. Box 9101
NL-6500 HB Nijmegen
The Netherlands

Contact:
E-Mail: 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/20111124/8bad60c9/attachment-0002.html>


More information about the fieldtrip mailing list