<HTML><HEAD>
<META content="text/html; charset=iso-8859-15" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.23588"></HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma">
<DIV>Hello,</DIV>
<DIV> </DIV>
<DIV>I am not a fieldtrip expert, but I happen to use ft_channelrepair recently. </DIV>
<DIV> </DIV>
<DIV>In you code,  does the 'data' have FT9 or CP6? Are those electrodes missing or bad? If you construct neighbours based on less number of electrodes, you may still lack the neighbour-info to interpolate them. </DIV>
<DIV> </DIV>
<DIV>I suggest to check the dimension of neighbours and see if it contains the neighbours info for all electrodes (especially for FT9 and CP6). </DIV>
<DIV> </DIV>
<DIV>Also, you can try cfg.missingchannel instead of cfg.badchannel and see if that helps.</DIV>
<DIV> </DIV>
<DIV>p.s., in my case, I used a good data (meaning without missing or bad channels) to create the neighbours and use it for all others dataset with same type of EEG caps. </DIV>
<DIV> </DIV>
<DIV>Best,</DIV>
<DIV> </DIV>
<DIV>Xiaoming<BR><BR>>>> "Irene Sophia Mayer" <mi_mayer@gmx.de> 4/19/2016 2:07 PM >>><BR></DIV>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 12px">
<DIV>Dear fieldtrippers, </DIV>
<DIV> </DIV>
<DIV>When trying to repair bad channels, I get the following error message: </DIV>
<DIV> </DIV>
<DIV>
<DIV><SPAN style="FONT-FAMILY: courier new,courier,monospace">Index exceeds matrix dimensions.</SPAN></DIV>
<DIV><SPAN style="FONT-FAMILY: courier new,courier,monospace">Error in ft_channelrepair (line 177)<BR>      goodsensindx = a(b);</SPAN></DIV>
<DIV><SPAN style="FONT-FAMILY: courier new,courier,monospace">Error in prepro_neu (line 129)<BR>    data = ft_channelrepair(cfg,data);</SPAN></DIV>
<DIV> </DIV>
<DIV>This seems to happen for specific channels, e.g. 'FT9' and 'CP6', but the script works fine, if I don't try to interpolate those channels. </DIV>
<DIV> </DIV>
<DIV>Any ideas what the problem could be?</DIV>
<DIV> </DIV>
<DIV>My code: </DIV>
<DIV>
<DIV><SPAN style="FONT-FAMILY: courier new,courier,monospace">cfg                         = [];<BR>cfg.method                  = 'template';<BR>cfg.layout                  = 'EEG1010.lay';<BR>cfg.feedback                = 'yes';</SPAN></DIV>
<DIV><SPAN style="FONT-FAMILY: courier new,courier,monospace">neighbours = ft_prepare_neighbours(cfg,data);</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN style="FONT-FAMILY: courier new,courier,monospace">cfg                         = [];<BR>cfg.method                  = 'average'; % 'nearest', 'average', 'spline' or 'slap' (default='nearest')<BR>cfg.badchannel              = bad_chan{x}; % predefined list of channels<BR>cfg.elec                    = ft_read_sens('path');<BR>cfg.neighbours              = neighbours;<BR>cfg.trials                  = 'all';<BR>cfg.lambda                  = 1e-5;<BR>cfg.order                   = 4;</SPAN></DIV>
<DIV><SPAN style="FONT-FAMILY: courier new,courier,monospace">data = ft_channelrepair(cfg,data);</SPAN></DIV></DIV></DIV></DIV></BODY></HTML>