Back to the main page.

Bug 3372 - ft_scalpcurrentdensity returns error with eeg data

Reported 2017-11-17 13:18:00 +0100
Modified 2018-01-26 09:51:59 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Jan-Mathijs Schoffelen
Depends on:
See also:

Tamas Minarik - 2017-11-17 13:18:18 +0100

I am using ft_scalpcurrentdensity on an eeg dataset, but it returns an error "This function requires EEG data with an ''elec'' field". The debugging indicates this is because of the part added to ft_checkdata (line 572): if ~isempty(iseeg) if isequal(iseeg, 'yes') okflag = isfield(data, 'grad'); elseif isequal(iseeg, 'no') okflag = ~isfield(data, 'grad'); end if ~okflag && isequal(iseeg, 'yes') ft_error('This function requires EEG data with an ''elec'' field'); elseif ~okflag && isequal(iseeg, 'no') ft_error('This function should not be given EEG data with an ''elec'' field'); end % if okflag end There is no grad field in the data structure given that it is eeg data. Please also note that the EEG data used in ft_scalcurrentdensity would not normally have an 'elec' field either at this stage. Previous version of Fieldtrip without this part of the ft_checkdata runs without problem.

Jan-Mathijs Schoffelen - 2017-11-20 15:04:05 +0100

Thanks for reporting: I suspect that there's a typo in the latest commit to ft_checkdata. My suspicion is that in the lines you quote from ft_checkdata 'grad' should be replaced with 'elec'. Upon Robert's confirmation I will fix this.

Tamas Minarik - 2017-11-20 17:33:59 +0100

Thanks for looking into this. The only thing is that changing to 'grad' to 'elec' would solve the problem only if there is an elec field in the data structure, which is not always the case. For instance, if CSD is applied to attenuate the effect of volume conduction at a relatively early stage of the processing pipeline, the data structure prior to the CSD may not have an elec field and so ft_checkdata may still return an error. The error occurs even if cfg.elec is specified within the cfg structure of the ft_scalpcurrentdensity.

Jan-Mathijs Schoffelen - 2017-11-21 09:38:23 +0100

I fixed it with the latest pull request (#585).