<div dir="ltr">Hi Jan-Matthijs,<div><br></div><div>It was quite a quest, but I think/hope I've located the problem. I was typing this email as I was troubleshooting, so skip to <b>3)</b> to get to the point:</div><div><br><div><br></div><div>I've tried setting both cfg.channel = 'all' and cfg.channel = cfg.label before calling ft_timelock_statistics. It makes no difference.</div><div><br></div><div><b>1) ft_timelock_statistics</b></div><div><br></div><div>I think the problem occurs at an earlier stage than what I thought at first, namely on line 105 of this function:</div><div>
<p><i>[varargin{:}] = ft_selectdata(tmpcfg, varargin{:});</i></p></div><div>After this, the varargin array of structures has the alphabetical channel order (while the input tmpcfg.channel was still good):</div><div><br></div><div><div><i>varargin{1}.cfg.channel</i></div><div><br></div><div>ans = </div><div><br></div><div> 'Af3'</div><div> 'Af4'</div><div> 'Af7'</div></div><div><br></div><div>etc</div><div><br></div><div>Then after the next line</div><div><i><br></i></div><div><i>[cfg, varargin{:}] = rollback_provenance(cfg, varargin{:});</i></div><div><br></div><div>cfg now also contains these channel orders.</div><div><br></div><div><b><br></b></div><div><b>2) ft_selectdata</b></div><div><b><br></b></div><div>on line 264 the contents of cfg.channel is changed from whatever was put in there (either the cfg.label order or 'all')</div><div>
<p class=""><i><span class="">if</span> haschan, [selchan, cfg] = getselection_chan (cfg, varargin{:}, cfg.select); <span class="">end</span></i></p></div>
<div>this jumps to subfunction get_selection on line 619:</div><div><br></div><div><b><br></b></div><div><b>3) ft_get_selection</b></div><div><br></div><div>line 630 then correctly selects the requested channels from the label list in varargin{k}.labels</div><div><i><br></i></div><div><i>selchannel = ft_channelselection(cfg.channel, varargin{k}.label);</i><br></div><div><br></div><div>selchannel still has the correct order of channels, but then line 631 calls "union" which puts things in alphabetical order:</div><div><b><br></b></div><div>
<p class=""><i>label = union(label, selchannel);</i></p><p class="">637 finds the correspondences between the two lists:</p><p class=""><i>[ix, iy] = match_str(label, varargin{k}.label);</i><br></p><p class=""><i><br></i></p><p class="">then there is a loop from 653-660 that does some more reordering/matching that I don't follow,<br></p><p class=""><b>but ultimately, on 677, the alphabetical list of channels is assigned to cfg.channel:</b></p><p class="">
</p><p class=""><i>cfg.channel = label;</i></p><p class=""><i><br></i></p><p class="">I believe this is where the error stems from, because the variable "label" has not had its alphabetical order changed since calling "union" on 631.</p><p class=""><br></p><p class="">Hope this helps,</p><p class=""><br></p><p class="">Roy</p></div><div><br></div><div><br></div>
</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 6, 2015 at 1:34 AM, Schoffelen, J.M. (Jan Mathijs) <span dir="ltr"><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
Hi Roy,
<div><br>
</div>
<div>The inadvertent alphabetization of channels should not occur. This issue has popped up in the past on several occasions (and on several locations in the code) and it has been a really tricky issue to deal with once and for all. Thanks for all the detective
work so far. From what you write, it seems that the cfg.channel that goes into channelconnectivity is already in alphabetical order. Would it be possible to track down where this happens? Do you explicitly add the alphabetical list to cfg.channel in your call
to ft_timelockanalysis? Does the problem persist if you define cfg.channel = data.label, i.e. the list in the order as it occurs in the data. (I would assume that the order of the channels is the same across all input data structures).</div>
<div><br>
</div>
<div>Best,</div>
<div>Jan-Mathijs</div>
<div><br>
<div><span class="">
<div>On Nov 5, 2015, at 8:58 PM, Roy Cox <<a href="mailto:roycox.roycox@gmail.com" target="_blank">roycox.roycox@gmail.com</a>> wrote:</div>
<br>
</span><blockquote type="cite">
<div dir="ltr"><span class="">hi all,
<div><br>
</div>
<div>I'm worried that something is not quite right with how the channel neighborhood configuration is used in the formation of spatial clusters.</div>
<div><br>
</div>
</span><div>I first noticed it when I got a significant cluster like below. Plotted are t statistics for a between-group comparison, with the significant "cluster" indicated with white electrodes. Notice F5 and P8 here which are disconnected from the rest. I should
also mention that I have only one "time point" (and no frequencies), so it's not possible that these channels are somehow connected via a "time bridge" (if that would even be possible).<span><cluster.jpg></span> </div><span class="">
<div><br>
</div>
<div>I've inspected my channel layout and that looks good:</div>
<div><br>
</div>
</span><div><span><2D_layout.jpg></span><br>
</div><span class="">
<div>I've looked at my neighborhood plot and that looks good too, although I notice that frontal channels are plotted to the right here (not sure if that's simply by default):</div>
<div><br>
</div>
</span><div><span><neighboorhood.jpg></span><br>
</div><span class="">
<div><br>
</div>
<div>Looking into the disconnected channel F5, the neighborhood structure seems in order:</div>
<div><br>
</div>
<div>
<div><i>cfg.neighbours(15)</i></div>
<div><br>
</div>
<div>ans = </div>
<div><br>
</div>
<div> label: 'F5'</div>
<div> neighblabel: {'Af7' 'F3' 'F7' 'Fc5'}</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>I call ft_timelockstatistics, which then calls ft_statistics_montecarlo, which, on line 165 calls </div>
<div><br>
</div>
<div><i>cfg.connectivity = channelconnectivity(cfg);</i></div>
<div><br>
</div>
<div>Stepping into this function, on line 20 it says:</div>
<div><br>
</div>
<div><i>chans=cfg.channel;</i></div>
<div><br>
</div>
<div>Checking what this variable contains, it has all my channels in <b>alphabetical order</b>, but my electrode location order is most definitely not. I've tried to force the orders to be the same by setting cfg.channel = cfg.label before calling ft_timelockstatistics,
but somewhere down the line my channel order is made alphabetical again.</div>
<div><br>
</div>
<div>So I suspect that the neighborhood structure, reflecting my actual channel order, is applied to the alphabetical channel order. That would explain why a cluster could be scattered across the brain (and also why there's still some spatial continuity given
that alphabetically close channels are usually close together in space).</div>
<div><br>
</div>
<div>Has anyone ever seen this? Any suggestions how to solve this (other than making my entire channel location file alphabetical)? I'm also posting this because it may be of relevance to others.</div>
<div><br>
</div>
<div>Roy</div>
<div><br>
</div>
<div><br>
</div>
</span></div><span class="">
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></span></blockquote>
</div>
<br>
</div>
</div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>