Skip to content

Commit

Permalink
ENH - include a check with a heuristic to investigate whether the use…
Browse files Browse the repository at this point in the history
…r accidentally forgot the cfg, and put a data argument upfront as input variable
  • Loading branch information
schoffelen committed Jan 25, 2018
1 parent 6bb14e4 commit 83f0148
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions utilities/private/ft_preamble_init.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@
error(msg);
end % if nargin

% check if there are fieldnames in the cfg that suggest as if the user
% erroneously inputted a data argument
checkdatafields = isfield(cfg, {'label' 'dimord' 'time' 'trialinfo' 'avg'});
if any(checkdatafields)
stack = dbstack('-completenames');
stack = stack(3);
help(stack.name);
% throw the error as if it happened in the original function
msg.message = 'It seems as if the first input argument is a FieldTrip data structure, while a cfg is expected';
msg.identifier = '';
msg.stack = stack;
error(msg);
end

% convert automatically from cell-array to structure
if iscell(cfg)
cfg = ft_keyval2cfg(cfg);
Expand Down

0 comments on commit 83f0148

Please sign in to comment.