<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">As a short follow up on this, the behavior of ft_neighbourplot is suspect only when supplying a cfg.neighbours field and plotting the result using the 2d layout file (as in the example I gave below), so this issue may not be the same as for the channel repair function. Using no layout file, the 3D plotted locations and labels appear to be correct. I can verify that the lower level functions called by ft_neighbourplot such as channelposition.m are returning the correct position and label info, but haven't had time to track the 2d plotting result down further. The neighbours returned by ft_neighbourselection also appear to be okay given a specified input distance.<div><br><div><div>On Jul 8, 2011, at 1:17 PM, Rojas, Don ( Employee MEG-SOM ) wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div bgcolor="#ffffff" text="#000000">Jörn, Jim et al.</div><div bgcolor="#ffffff" text="#000000"><br></div><div bgcolor="#ffffff" text="#000000">There is indeed a general problem, most likely with channel indexing, in gradiometer systems. I think the data are read correctly with the low level functions, but functions like ft_channelrepair, ft_neighbourselection and ft_neighbourplot are not accounting for the locations correctly. I have attached a picture that I think illustrates this issue reasonably well. The following code was used t<span><neighbors.jpg></span>o generate this plot:</div><div bgcolor="#ffffff" text="#000000"><br></div><div bgcolor="#ffffff" text="#000000">% read in data</div><div bgcolor="#ffffff" text="#000000">cfg = [];</div><div bgcolor="#ffffff" text="#000000">cfg.dataset = 'e,rfhp1.0Hz,COH';</div><div bgcolor="#ffffff" text="#000000">coh = ft_preprocessing(cfg);</div><div bgcolor="#ffffff" text="#000000"><br></div><div bgcolor="#ffffff" text="#000000">% get neighbors and plot</div><div bgcolor="#ffffff" text="#000000">cfg = [];</div><div bgcolor="#ffffff" text="#000000">cfg.neighbourdist = .03;</div><div bgcolor="#ffffff" text="#000000">cfg.neighbours = ft_neighbourselection(cfg,coh);</div><div bgcolor="#ffffff" text="#000000">cfg.layout = '4D248.lay';</div><div bgcolor="#ffffff" text="#000000">ft_neighbourplot(cfg,coh);</div><div bgcolor="#ffffff" text="#000000"><br></div><div bgcolor="#ffffff" text="#000000">You can see that the channel selected is labeled A216, which is incorrect - it should be A248. It's three neighbors are also incorrect (A208, A118 and A134 should probably be A195, A228 and A247).</div><div bgcolor="#ffffff" text="#000000"><br></div><div bgcolor="#ffffff" text="#000000">I'm guessing this is the same indexing issue for gradiometers. Jan-Mathijs mentioned a fixed version of ft_channelrepair appearing today, so perhaps it will be the same problem and the fix can be propagated to these other functions.</div><div bgcolor="#ffffff" text="#000000"><br></div><div bgcolor="#ffffff" text="#000000">Don</div><div bgcolor="#ffffff" text="#000000"><br></div><div><div>On Jul 8, 2011, at 2:20 AM, Jörn M. Horschig wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div bgcolor="#ffffff" text="#000000">
    Dear Jim, Don and others,<br>
    <br>
    First of all, what Don suggested sounds indeed like the cause, if I
    remember things correctly (with my limited experience). <br>
    <br>
    Anyhow, could one of you check ft_neighbourplot with the dataset and
    the neighbourselection of choice? This allows you to see what
    neighbours are selected for which sensors and where they lie in
    space. If this looks fine, than the problem lies indeed in how
    sensor position is deduced from the data structure.<br>
    <br>
    Best,<br>
    Jörn<br>
    <br>
    <br>
    On 7/8/2011 9:11 AM, jan-mathijs schoffelen wrote:
    <blockquote cite="mid:BB75D7D8-68AD-4466-8B52-CFB2BC90E66E@donders.ru.nl" type="cite">Dear Don,
      <div><br>
      </div>
      <div>This sounds like a very likely cause of the problem. When we
        wrote the 4D reading code at the time, we had the 248-channel
        magnetometer system in mind. It could be that there are some
        flaws related to the handling of gradiometers. This should not
        only lead to (erratic) issues at the level of channelrepair, but
        may also cause mayhem when doing planar gradient transformation,
        or source reconstruction.</div>
      <div>Would you happen to</div>
      <div>1) feel like tackling this one with me, and improve FieldTrip
        to deal with gradiometer systems correctly? </div>
      <div><br>
      </div>
      <div>or</div>
      <div><br>
      </div>
      <div>2) have a small gradiometer dataset which you can send to me
        (e.g. through DropBox), so that I can look into it?</div>
      <div><br>
      </div>
      <div>We can further discuss this off the discussion list.</div>
      <div><br>
      </div>
      <div>Best wishes,</div>
      <div><br>
      </div>
      <div>Jan-Mathijs</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div><br>
        <div>
          <div>On Jul 8, 2011, at 3:36 AM, Rojas, Don ( Employee MEG-SOM
            ) wrote:</div>
          <br class="Apple-interchange-newline">
          <blockquote type="cite">
            <div style="word-wrap: break-word;">Jim et al.
              <div><br>
              </div>
              <div>In thinking about this further, it seems to me that
                it is the indexing that is incorrect. The problem I
                think is specific to gradiometer systems, which have two
                (or more) locations per channel. The function appears to
                assume that the sensor index based on the sens.label
                field (only 1 per channel) will correspond 1 to 1 with
                the sens.grad field (2 locations per channel), which is
                not correct. So, my guess is that for first-order
                gradiometer systems, the correct index for the sensor
                location is 2x the index in the sens.label field.</div>
              <div><br>
              </div>
              <div>So, in an example I have handy at home, the label
                index for channel A234 is 107. Since I think Fieldtrip
                stores gradiometer locations (by default) as:</div>
              <div><br>
              </div>
              <div>Chn 1 lower coil x, y z</div>
              <div>Chn 1 upper coil x, y z</div>
              <div>Chn 2 lower coil x, y z</div>
              <div>Chn 2 upper coil x, y z</div>
              <div>.</div>
              <div>.</div>
              <div>.</div>
              <div>Chn N</div>
              <div><br>
              </div>
              <div>I think the correct position info for channel A234
                would be found in sens.grad(214,:), not
                sens.grad(107,:), which is what the ft_channelrepair
                function chooses. So I think this is a bug in the
                function specific to gradiometer systems.</div>
              <div><br>
              </div>
              <div>Best,</div>
              <div><br>
              </div>
              <div>Don</div>
              <div><br>
                <div>
                  <div>On Jul 7, 2011, at 5:38 PM, Jim Li wrote:</div>
                  <br class="Apple-interchange-newline">
                  <blockquote type="cite">
                    <div>Thank you very much for confirming the problem,
                      Don, I appreciate it, :)</div>
                    <div> </div>
                    <div class="gmail_quote">Jim</div>
                    <div class="gmail_quote"> </div>
                    <div class="gmail_quote">On Thu, Jul 7, 2011 at 4:30
                      PM, Rojas, Don <span dir="ltr"><<a moz-do-not-send="true" href="mailto:Don.Rojas@ucdenver.edu" target="_blank">Don.Rojas@ucdenver.edu</a>></span>
                      wrote:<br>
                      <blockquote class="gmail_quote" style="padding-left: 1ex; margin: 0px 0px 0px
                        0.8ex; border-left: 1px solid rgb(204, 204,
                        204);">
                        <div style="word-wrap: break-word;">Jim,
                          <div><br>
                          </div>
                          <div>All I can do is confirm that this issue
                            exists for our 4D data as well, although we
                            don't use the ft_channelrepair function. The
                            same 4 quite distant channels (one had been
                            deleted in the dataset I had handy) were
                            chosen for repair when I ran this on one of
                            our datasets (also a 248 channel 4D system).
                            I agree the choice doesn't make any sense
                            given the 3 cm distance you define. A quick
                            look at the critical calculation in
                            ft_channelrepair, line 109 distance = ... is
                            correct given the inputs. So I wonder if the
                            issue is with the actual channel indices
                            used rather than the calculation, but I
                            don't have time to track that down. All I
                            can say is that for the distance you
                            specify, channels A235, A216, A199, A215
                            would be much closer to A234 than those that
                            are selected via the channel repair
                            function. Channel A8 is in fact nearly 21 cm
                            away from channel A234 in the array, based
                            on examination of the data read in from
                            Eugene Kronberg's pdf4D matlab object code,
                            which I think was originally the basis for
                            the FieldTrip 4D reader function.</div>
                          <div><br>
                          </div>
                          <div>Best,</div>
                          <div><br>
                          </div>
                          <div>Don Rojas</div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                          <div>
                            <div>
                              <div>
                                <div>
                                  <div>On Jul 7, 2011, at 1:26 PM, Jim
                                    Li wrote:</div>
                                  <br>
                                </div>
                              </div>
                              <blockquote type="cite">
                                <div>
                                  <div>
                                    <div>Dear Fieldtrip developer,</div>
                                    <div> </div>
                                    <div>Can anybody help me with this
                                      channel-repair issue I've been
                                      having? I can provide the raw data
                                      if you need. I really want to
                                      solve the problem, you know.</div>
                                    <div> </div>
                                    <div>Thanks a lot,</div>
                                    <div> </div>
                                    <div>Jim<br>
                                      <br>
                                    </div>
                                    <div class="gmail_quote">On Thu, Jul
                                      7, 2011 at 2:22 PM, Jim Li <span dir="ltr"><<a moz-do-not-send="true" href="mailto:megjim1@gmail.com" target="_blank">megjim1@gmail.com</a>></span>
                                      wrote:<br>
                                      <blockquote class="gmail_quote" style="padding-left: 1ex;
                                        margin: 0px 0px 0px 0.8ex;
                                        border-left: 1px solid rgb(204,
                                        204, 204);">
                                        <div>Hi Odelia,</div>
                                        <div> </div>
                                        <div>Yes, I downloaded the
                                          latest version of Fieldtrip
                                          and tried your suggestion
                                          "cfg.neighbourdist = 0.03",  
                                          but it still weirdly uses the
                                          far-away channels like A121 to
                                          do the channel-repair for A234
                                          (these two channels are
                                          24.1172cm apart!).  Here is
                                          the detail:</div>
                                        <div> </div>
                                        <div>---------------------------</div>
                                        <div>
                                          <div>cfg                        
                                            = [];<br>
                                            cfg.dataset                
                                            = 'e,rfhp0.1Hz'; </div>
                                          <div>cfg.trialdef.eventtype     
                                            = 'TRIGGER';<br>
                                            cfg.trialdef.eventvalue    
                                            = 320; </div>
                                        </div>
                                        <div>
                                          <div>cfg.trialdef.prestim       
                                            = 1;<br>
                                            cfg.trialdef.poststim      
                                            = 1;<br>
                                            cfg                        
                                            = ft_definetrial(cfg);<br>
                                          </div>
                                          cfg.blc                     =
                                          'yes';                             
                                          % do baseline correction with
                                          the complete trial
                                          <div><br>
                                            cfg.blcwindow              
                                            = [-1 0];<br>
                                            cfg.channel                
                                            = {'MEG'};<br>
                                            raw_DATA                   
                                            = ft_preprocessing(cfg);</div>
                                        </div>
                                        <div> </div>
                                        <div> </div>
                                        <div>cfg = [];<br>
                                          cfg.badchannel = {'A234'}; <br>
                                          cfg.neighbourdist =  0.03;
                                          <div><br>
                                            [raw_DATA] =
                                            ft_channelrepair(cfg,
                                            raw_DATA)</div>
                                        </div>
                                        <div> </div>
                                        <div>---------------------------------------------------------------------</div>
                                        <div> </div>
                                        <div>And here is the outcome:
                                          -----------------------------</div>
                                        <div>
                                          <div><br>
                                            the input is raw data with
                                            248 channels and 201 trials<br>
                                            repairing channel A234<br>
                                              using neighbour A121<br>
                                              using neighbour A143<br>
                                          </div>
                                            using neighbour A173<br>
                                            using neighbour A8
                                          <div><br>
                                            repairing bad channels for
                                            trial 1<br>
                                            repairing bad channels for
                                            trial 2<br>
                                            repairing bad channels for
                                            trial 3<br>
                                          </div>
                                          repairing bad channels for
                                          trial 4<br>
                                          repairing bad channels for
                                          trial 5<br>
                                          repairing bad channels for
                                          trial 6<br>
                                          repairing bad channels for
                                          trial 7<br>
                                          repairing bad channels for
                                          trial 8<br>
                                          repairing bad channels for
                                          trial 9<br>
                                          repairing bad channels for
                                          trial 10</div>
                                        <div>....</div>
                                        <div> </div>
                                        <div>-------------------------</div>
                                        <div> </div>
                                        <div>Thank you.</div>
                                        <div> </div>
                                        <font color="#888888">
                                          <div>Jim<br>
                                          </div>
                                        </font></blockquote>
                                    </div>
                                  </div>
                                </div>
                                _______________________________________________
                                <div><br>
                                  fieldtrip mailing list<br>
                                  <a moz-do-not-send="true" href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
                                  <a moz-do-not-send="true" href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></div>
                              </blockquote>
                            </div>
                            <br>
                            <div><span style="word-spacing: 0px; font:
                                medium Helvetica; text-transform: none;
                                color: rgb(0, 0, 0); text-indent: 0px;
                                white-space: normal; letter-spacing:
                                normal; border-collapse: separate;"><span style="word-spacing: 0px; font: medium
                                  Helvetica; text-transform: none;
                                  color: rgb(0, 0, 0); text-indent: 0px;
                                  white-space: normal; letter-spacing:
                                  normal; border-collapse: separate;">
                                  <div style="word-wrap: break-word;">-----------------------<br>
                                    Don Rojas, Ph.D.<br>
                                    Associate Professor of Psychiatry<br>
                                    U. of Colorado Denver Anschutz
                                    Medical Campus<br>
                                    Director, UCD
                                    Magnetoencephalography Lab<br>
                                    13001 E. 17th Pl F546<br>
                                    Aurora, CO 80045<br>
                                    <a moz-do-not-send="true" href="tel:303-724-4994" target="_blank" value="+13037244994">303-724-4994</a></div>
                                </span></span></div>
                            <br>
                          </div>
                        </div>
                        <br>
                        _______________________________________________<br>
                        fieldtrip mailing list<br>
                        <a moz-do-not-send="true" href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
                        <a moz-do-not-send="true" href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
                      </blockquote>
                    </div>
                    <br>
                    _______________________________________________<br>
                    fieldtrip mailing list<br>
                    <a moz-do-not-send="true" href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
                    <a moz-do-not-send="true" href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></blockquote>
                </div>
                <br>
                <div>
                  
                      <div style="word-wrap: break-word;">-----------------------<br>
                        Don Rojas, Ph.D.<br>
                        Associate Professor of Psychiatry<br>
                        U. of Colorado Denver Anschutz Medical Campus<br>
                        Director, UCD Magnetoencephalography Lab<br>
                        13001 E. 17th Pl F546<br>
                        Aurora, CO 80045<br>
                        303-724-4994</div>
                    
                </div>
                <br>
              </div>
            </div>
            _______________________________________________<br>
            fieldtrip mailing list<br>
            <a moz-do-not-send="true" href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
            <a class="moz-txt-link-freetext" href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></blockquote>
        </div>
        <br>
        <div>
          <span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; ">
              <div style="word-wrap: break-word;">
                <div>Dr. J.M. (Jan-Mathijs) Schoffelen </div>
                <div>Donders Institute for Brain, Cognition and
                  Behaviour, <br>
                  Centre for Cognitive Neuroimaging,<br>
                  Radboud University Nijmegen, The Netherlands</div>
                <div><a moz-do-not-send="true" href="mailto:J.Schoffelen@donders.ru.nl">J.Schoffelen@donders.ru.nl</a></div>
                <div>Telephone: 0031-24-3614793</div>
              </div>
            </span></span>
        </div>
        <br>
      </div>
      <pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
fieldtrip mailing list
<a class="moz-txt-link-abbreviated" href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a>
<a class="moz-txt-link-freetext" href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
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: <a class="moz-txt-link-abbreviated" href="mailto:jm.horschig@donders.ru.nl">jm.horschig@donders.ru.nl</a>
Tel:    +31-(0)24-36-68493
Web: <a class="moz-txt-link-freetext" href="http://www.ru.nl/donders">http://www.ru.nl/donders</a>

Visiting address:
Trigon, room 2.30
Kapittelweg 29
NL-6525 EN Nijmegen
The Netherlands</pre>
  </div>

_______________________________________________<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">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">-----------------------<br>Don Rojas, Ph.D.<br>Associate Professor of Psychiatry<br>U. of Colorado Denver Anschutz Medical Campus<br>Director, UCD Magnetoencephalography Lab<br>13001 E. 17th Pl F546<br>Aurora, CO 80045<br>303-724-4994</div></span></span>
</div>
<br></div>_______________________________________________<br>fieldtrip mailing list<br><a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">-----------------------<br>Don Rojas, Ph.D.<br>Associate Professor of Psychiatry<br>U. of Colorado Denver Anschutz Medical Campus<br>Director, UCD Magnetoencephalography Lab<br>13001 E. 17th Pl F546<br>Aurora, CO 80045<br>303-724-4994</div></span></span>
</div>

<br></div></body></html>