I have a dataset where some of the channels don't have channel location information (EMG sensors). It usually isn't a problem for some channels to have location information and others to be blank, but I recently encountered a bug that happens when the very first channel has no X position information.
Steps to Reproduce
Have a dataset that contains an EEG.chanlocs structure, complete with electrode position information, but make sure the first channel is missing electrode position info. Specifically make sure EEG.chanlocs(1).X is empty.
Use the GUI to select "Locate Dipoles using dipfit / Head model settings"
Click on "co-register" and get the following error:
Error in coregister (line 314)
elec1 = cfg.elec;
Error using inputgui (line 218)
Error while evaluating UIControl Callback.
Alternative Steps to Reproduce errors deriving from same bug
Steps 1 and 2 the same
Use matlab workspace to call dipfit and specify to only use channels with electrode position information. Here "EEG_chans" is my vector list of channels that are good to use (all their chanlocs fields are complete)
This error is because data is an empty set so data.elec.elecpos doesn't exist. data is empty because an IF statement in eeglab2fieldtrip skips doing necessary steps because it assumes that all channels are missing electrode position information if the very first channel doesn't have position information
Expected behavior:
I expect dipfit to auto ignore channels without position information assuming that at least some of the channels in the EEG structure do in fact have position information.
Actual behavior:
It fails because of a signle line in eeglab2fieldtrip.m
HOW TO FIX
replace line 81 in eeglab2fieldtrip. Specifically, the original is:
You need to remove the "&& ~isempty(EEG.chanlocs(1).X)" so it becomes simply:
"if ~isempty(EEG.chanlocs)"
There is no need to specifically check the existence of the first channel's X position field here before executing the rest of the code. There is a for loop later that checks each channel individually to make sure it has location information. I commented the extra part out and everything works perfectly without it
OK, we will have a look. I am not sure how channel with no position are handled in Fieldtrip. For now, I would suggest using NaN everywhere hen no position is available.
I have a dataset where some of the channels don't have channel location information (EMG sensors). It usually isn't a problem for some channels to have location information and others to be blank, but I recently encountered a bug that happens when the very first channel has no X position information.
Steps to Reproduce
Error in coregister (line 314) elec1 = cfg.elec;
Error using inputgui (line 218) Error while evaluating UIControl Callback.
Alternative Steps to Reproduce errors deriving from same bug
Steps 1 and 2 the same
EEG = pop_dipfit_settings( EEG, .................................. 'coord_transform',[0 0 0 0 0 -1.5708 1 1 1] ,... 'chansel',EEG_chans ); EEG = pop_multifit(EEG, 1:size(EEG.icaact,1) ,'threshold',100,'plotopt',{'normlen' 'on'});
Dot indexing is not supported for variables of this type.
Error in eeglab2fieldtrip (line 101) data.elec.elecpos = transfmat * [ data.elec.elecpos ones(size(data.elec.elecpos,1),1) ]';
Error in dipfit_gridsearch (line 80) comp = eeglab2fieldtrip(EEG, 'componentanalysis', 'dipfit');
Error in pop_dipfit_gridsearch (line 135) EEGOUT = dipfit_gridsearch(EEG, 'component', select, 'xgrid', xgrid, 'ygrid', ygrid, 'zgrid', zgrid, options{:});
Error in pop_multifit (line 133) EEG = pop_dipfit_gridsearch( EEG, [1:ncomps], ...
This error is because data is an empty set so data.elec.elecpos doesn't exist. data is empty because an IF statement in eeglab2fieldtrip skips doing necessary steps because it assumes that all channels are missing electrode position information if the very first channel doesn't have position information
Expected behavior:
I expect dipfit to auto ignore channels without position information assuming that at least some of the channels in the EEG structure do in fact have position information.
Actual behavior:
It fails because of a signle line in eeglab2fieldtrip.m
HOW TO FIX
replace line 81 in eeglab2fieldtrip. Specifically, the original is:
"if ~isempty(EEG.chanlocs) && ~isempty(EEG.chanlocs(1).X)".
You need to remove the "&& ~isempty(EEG.chanlocs(1).X)" so it becomes simply:
"if ~isempty(EEG.chanlocs)"
There is no need to specifically check the existence of the first channel's X position field here before executing the rest of the code. There is a for loop later that checks each channel individually to make sure it has location information. I commented the extra part out and everything works perfectly without it
Versions