Back to the main page.
Bug 3221 - ft_definetrial: The error message for non-existing cfg.trialfun throws an error itself.
Status | CLOSED FIXED |
Reported | 2016-12-15 00:52:00 +0100 |
Modified | 2019-08-10 12:32:56 +0200 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | All |
Operating System: | All |
Importance: | P5 minor |
Assigned to: | Lennart Verhagen |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Lennart Verhagen - 2016-12-15 00:52:57 +0100
Hi all, two small things. First, in ft_definetrial the cfg.trialfun is checked to exist by ft_getuserfun. If it does not exist it is returned empty. The subsequently, if cfg.trialfun is empty ft_definetrial tries to throw an error, but it falsely assumes that cfg.trialfun is NOT empty (but a string). Because cfg.trialfun is now in fact an empty double func2str fails itself. Here is the error output from line 158: Undefined function 'func2str' for input arguments of type 'double'. And here is the relevant code: cfg.trialfun = ft_getuserfun(cfg.trialfun, 'trialfun'); if isempty(cfg.trialfun) error('the specified trialfun ''%s'' was not found', func2str(cfg.trialfun)); else fprintf('evaluating trialfunction ''%s''\n', func2str(cfg.trialfun)); end Second (and this really is a trivial thing), ft_getuserfun gives confusing feedback. It erroneously uses a double negation where a single negation would be appropriate. This is the output warning if a cfg.trialfun has not been found (note the "no function A could not be found" phrasing): Warning: no function by the name 'ft_trialfun_DoesNotExist', 'trialfun_ft_trialfun_DoesNotExist', or 'ft_trialfun_ft_trialfun_DoesNotExist' could not be found
Jan-Mathijs Schoffelen - 2016-12-20 11:30:54 +0100
This has been fixed by Lennart.