Back to the main page.
Bug 2410 - isfunction error upon a call to ft_getuserfun
Status | CLOSED FIXED |
Reported | 2013-12-04 08:33:00 +0100 |
Modified | 2014-01-29 13:38:01 +0100 |
Product: | FieldTrip |
Component: | preproc |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P3 normal |
Assigned to: | Roemer van der Meij |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Eric Maris - 2013-12-04 08:33:56 +0100
When specifying a trial function in the cfg of ft_definetrial, I get an error on line 39 of ft_getuserfun. This is due to isfunction which does not take char arguments, as in my case (cfg.trialfun is a string). Undefined function 'isfunction' for input arguments of type 'char'. Error in ft_getuserfun (line 39) elseif isfunction(func) && ~iscompatwrapper(func) Error in ft_definetrial (line 140) cfg.trialfun = ft_getuserfun(cfg.trialfun, 'trialfun');
Robert Oostenveld - 2013-12-04 08:46:41 +0100
mac001> find . -name ft_getuserfun\* ./private/ft_getuserfun.m mac001> ls private/isfunction.m private/isfunction.m Could you check whether private/isfunction.m is present in your FT installation? It should take a char input argument.
Eric Maris - 2013-12-04 09:07:30 +0100
(In reply to comment #1) > Could you check whether private/isfunction.m is present in your FT > installation? It should take a char input argument. Yes it is, but it is in the same private directory as the calling function (ft_getuserfun). Doesn't that create problems (fieldtrip/private is not in my path, as it should). Btw, what an enormous path has been added by Fieldtrip! I can't find my own contributions to the path anymore. Best, Eric
Robert Oostenveld - 2013-12-04 11:25:11 +0100
(In reply to comment #2) Both in private should be fine. might it be that you have another "isfunction" function different than the one that is expected by ft_getuserfun? Coudl you add a breakpoint in ft_getuserfun and type "which isfunction"? Regarding private, please see http://fieldtrip.fcdonders.nl/faq/matlab_does_not_see_the_functions_in_the_private_directory Regarding the path, please see http://fieldtrip.fcdonders.nl/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path which directories are on the path that you had not expected there? The ft_defaults function is used to set the minimum fieldtrip path. All other toolboxes are only added if they are being used (with the ft_hastoolbox helper function).
Eric Maris - 2013-12-04 12:18:01 +0100
Created attachment 571 My horribly long path
Eric Maris - 2013-12-04 12:24:46 +0100
(In reply to comment #3) With the breakpoint as suggested, Matlab does NOT see isfunction and neither ft_getuserfun (!). These are the last lines of my path settings: % Fieldtrip directory addpath /vol/optdcc/fieldtrip-latest ft_defaults addpath /vol/optdcc/fieldtrip-latest/qsub addpath ~/Matlab/OverruledFieldtripFuncs; The last line does not do anything. When I ask for the path, ~/Matlab/OverruledFieldtripFuncs is after the regular Fieldtrip folders. The path must have been set again after the first call to ft_defaults. I have attached a file with my horribly long path. best, Eric
Robert Oostenveld - 2013-12-04 12:47:03 +0100
(In reply to comment #4) and what makes you think that fieldtrip added that path? Seeing e.g. spm2 and spm8 both on the path and /vol/optdcc/fieldtrip-latest/external/dmlt/external/gpstuff/SuiteSparse/MATLAB_Tools/waitmex strongly suggests that you did not adhere to the instructions at http://fieldtrip.fcdonders.nl/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path and used addpath(genpath(...)). Please see the red warning in the middle of that faq. Do you not see regular warnings like these? Warning: Multiple versions of spm on your path will confuse FieldTrip > In fieldtrip/private/warning_once at 158 In ft_defaults>checkMultipleToolbox at 233 In ft_defaults at 89 Warning: one version of spm is found here: /Volumes/Data/roboos/matlab/fieldtrip/external/spm8/spm.m > In ft_defaults>checkMultipleToolbox at 236 In ft_defaults at 89 Warning: one version of spm is found here: /Volumes/Data/roboos/matlab/fieldtrip/external/spm2/spm.m > In ft_defaults>checkMultipleToolbox at 236 In ft_defaults at 89 Warning: You probably used addpath(genpath('path_to_fieldtrip')), this can lead to unexpected behaviour. See http://fieldtrip.fcdonders.nl/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path > In fieldtrip/private/warning_once at 158 In ft_defaults>checkMultipleToolbox at 239 In ft_defaults at 89
Robert Oostenveld - 2013-12-04 12:49:24 +0100
(In reply to comment #6) having 9 different fieldtrip versions on the path, all with addpath(genpath(...)) does not comply with the installation instructions ;-) I suggest Roemer takes a look at your path settings.
Eric Maris - 2013-12-04 13:15:31 +0100
(In reply to comment #7) I know that I should not use addpath(genpath('path_to_fieldtrip')) and I also did not include it in my path settings. Therefore, what makes you think that I did so ...(-;
Eric Maris - 2013-12-04 13:53:09 +0100
(In reply to comment #7) Restarted Matlab with exactly the same path settings, the error does not appear anymore and the Fieldtrip path settings are slim again.
Robert Oostenveld - 2013-12-04 15:44:30 +0100
> Therefore, what makes you think that I did so ...(-; the fact that you have 9 different fieldtrip versions on your path and for each of them have directories on the path that fieldtrip would never add itself. If it had been on the mentat cluster, I would have thought that you had done addpath(genpath('/home/common/matlab')). You might also have used the graphical "pathtool" to set the path and clicked on the "Add with subfolders" button, which results in the same as addpath(genpath()). I suggest you do restoredefaultpath cd fieldtrip ft_defaults and you should be all fine again. You might have to do it every time you start MATLAB though, since your problematic path might be represented on disk (either in pathdef.m or in startup.m) and be executed every time you start. Can you please tell whether the reported bug persists after you have cleaned up your path?
Roemer van der Meij - 2013-12-04 16:47:50 +0100
Actually, there was an unexpected interaction with an update script I use to maintain our version here at the DCC cluster and our file server (since a few weeks ago), which in the end caused a nesting of partially deleted versions. This is fixed now. However, Eric, it would still have been avoided if you used something like Robert suggested in your startup.m: restoredefaultpath cd fieldtrip ft_defaults Or restoredefaultpath your_own_paths Or if you already do this in your startup.m, then restart your matlab a little more often ;) Setting bug as fixed.