Scrambled MEG sensor locations
Problem: the layout of the sensors is wrong. When plotting the position, they appear scrambled.
Plot the channel positions:
plot3(data.grad.chanpos(:,1), data.grad.chanpos(:,2), data.grad.chanpos(:,3), 'o')

How it should look:
Also, you cannot plot the sensor layout with ft_plot_sens(data.grad)
:
Error using ft_plot_sens (line 448)
cannot work with balanced gradiometer definition
The problem comes from the reconstruction of the channels when removing ICA components (ft_rejectcomponent
).
Solution
When using ft_rejectcomponent
make sure that you specify input data and set the configuration to NOT update sensor info:
% Remove components
cfg = [];
cfg.component = reject_comp;
cfg.channel = 'MEG';
cfg.updatesens = 'no';
icaclean_data = ft_rejectcomponent(cfg, comp, data);