[FieldTrip] ft_channelrepair: index exceeds matrix dimensions

Xiaoming Du XDu at mprc.umaryland.edu
Wed Apr 20 11:19:23 CEST 2016

Hi Irene,
Here is the code I used:
cfg = [];
cfg.method = 'triangulation'
cfg.senstype = 'EEG'
neighbours_66 = ft_prepare_neighbours(cfg, data_intact);
    cfg = [];
    cfg.method = 'average';
    cfg.neighbours = neighbours_66;
    cfg.missingchannel = missingChann;
    cfg.senstype = 'EEG';
    data_clean = ft_channelrepair(cfg, data);
Here is an example from Fieldtrip website 

>>> "Irene Sophia Mayer" <mi_mayer at gmx.de> 4/20/2016 3:07 AM >>>
The data does always have those channels, they are bad and not missing. All electrodes have neighbours assigned to them and I'm doing this on the original data without having changed anything before that. 
Did you use the same code as I did?
  Gesendet: Dienstag, 19. April 2016 um 20:38 Uhr
Von: "Xiaoming Du" <XDu at mprc.umaryland.edu>
An: fieldtrip at science.ru.nl
Betreff: Re: [FieldTrip] ft_channelrepair: index exceeds matrix dimensions
I am not a fieldtrip expert, but I happen to use ft_channelrepair recently.
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.
I suggest to check the dimension of neighbours and see if it contains the neighbours info for all electrodes (especially for FT9 and CP6).
Also, you can try cfg.missingchannel instead of cfg.badchannel and see if that helps.
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.

>>> "Irene Sophia Mayer" <mi_mayer at gmx.de> 4/19/2016 2:07 PM >>>
Dear fieldtrippers, 
When trying to repair bad channels, I get the following error message: 
Index exceeds matrix dimensions.
Error in ft_channelrepair (line 177)
      goodsensindx = a(b);
Error in prepro_neu (line 129)
    data = ft_channelrepair(cfg,data);
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. 
Any ideas what the problem could be?
My code: 
cfg    	    	    	 = [];
cfg.method    	    	  = 'template';
cfg.layout    	    	  = 'EEG1010.lay';
cfg.feedback    	    	= 'yes';
neighbours = ft_prepare_neighbours(cfg,data);
cfg    	    	    	 = [];
cfg.method    	    	  = 'average'; % 'nearest', 'average', 'spline' or 'slap' (default='nearest')
cfg.badchannel    	      = bad_chan{x}; % predefined list of channels
cfg.elec    	    	    = ft_read_sens('path');
cfg.neighbours    	      = neighbours;
cfg.trials    	    	  = 'all';
cfg.lambda    	    	  = 1e-5;
cfg.order    	    	   = 4;
data = ft_channelrepair(cfg,data);
_______________________________________________ fieldtrip mailing list fieldtrip at donders.ru.nl http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20160420/769f7eac/attachment-0002.html>

More information about the fieldtrip mailing list