Back to the main page.
Bug 2758 - ft_prepare_headmodel(cfg) fails with single argument
Status | CLOSED FIXED |
Reported | 2014-11-11 19:20:00 +0100 |
Modified | 2015-01-12 09:19:03 +0100 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P5 minor |
Assigned to: | Jan-Mathijs Schoffelen |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Marc Lalancette - 2014-11-11 19:20:22 +0100
ft_prepare_headmodel fails when the second argument 'data' is missing. This is allowed according to the function help and makes sense e.g. when providing cfg.hdmfile. The error is due to data being assigned an empty matrix: 192 data = []; and then when checking: 220 input_seg = ft_datatype(data, 'segmentation'); ft_datatype doesn't know how to deal with empty input and eventually we get: Undefined function 'fieldnames' for input arguments of type 'double'. Error in ft_datatype>check_chan (line 159) fn = fieldnames(data); Error in ft_datatype (line 50) ischan = check_chan(data); ... Possible fix: either modify ft_datatype to deal with empty input, or modify ft_prepare_headmodel 218-221 to: % boolean variables to manages the different geometrical input data objects if isempty(data) input_mesh = false; input_seg = false; input_elec = false; else input_mesh = isfield(data, 'pnt') && ~isfield(data, 'label'); input_seg = ft_datatype(data, 'segmentation'); input_elec = ft_datatype(data, 'sens'); end
Jan-Mathijs Schoffelen - 2014-11-12 13:12:50 +0100
Thanks Marc, we'll look into it.
Jan-Mathijs Schoffelen - 2014-11-12 15:52:57 +0100
If I do: x = []; y = ft_datatype(x, 'segmentation'); I don't get an error. Are you using a clean and up-to-date version of FieldTrip?
Marc Lalancette - 2014-11-12 17:41:02 +0100
I did an SVN update again just now: Completed: At revision: 9958 The only local edit I have is in lcmv. And I still get: >> ft_datatype([], 'segmentation') Undefined function 'fieldnames' for input arguments of type 'double'. Error in ft_datatype>check_chan (line 159) fn = fieldnames(data); Error in ft_datatype (line 50) ischan = check_chan(data); Possibly a Matlab version issue? I'm on 2011b on Windows. It doesn't like fieldnames on empty (double).
Jan-Mathijs Schoffelen - 2014-11-12 20:14:08 +0100
Sorry Marc, my bad. My private version of FieldTrip had a fix in place which I have never committed to SVN ;-). Apparently I have come across this one before.