Back to the main page.

Bug 3187 - matlab version specific behavior of cfg-tracking (cleanup)

Status RESOLVED WONTFIX
Reported 2016-10-21 10:03:00 +0200
Modified 2022-11-10 09:24:33 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Jan-Mathijs Schoffelen - 2016-10-21 10:03:06 +0200

Here's the problem: starting from >=matlab2015b the cfg-tracking leads to different results compared to <=matlab2014b (I haven't checked matlab2015a). I came across this when doing a simple ft_freqanalysis (without any fancy cfg arguments: importantly the cfg.channel defaulted to 'all') The function call crashes >=matlab2015b (with ft_default.trackconfig = 'cleanup', not when ft_default.trackconfig = 'off'). I tracked this down to a difference in the output of the call to ft_selectdata, where the dataout.cfg contains a channel field (enumerated list of labels) for the older matlab versions, whereas the dataout.cfg.channel field is not present in output from a newer version. Looking a bit further into this, it seems that the config bookkeeping (i.e. tracking access to config fields in the config object) works slightly differently in both versions. For now it can be worked around by specifying ft_default.trackconfig = 'off', but it may be relevant to look into at some point.


Jan-Mathijs Schoffelen - 2017-01-17 14:19:02 +0100

I narrowed it down to the @config/private/increment function not incrementing for 2015b.


Jan-Mathijs Schoffelen - 2017-01-17 14:52:21 +0100

So, in short: there seems to be an issue with the low level tracking of referencing/assigning fields of a config object. This is reproducible on Linux (DCCN cluster) and my Macbook, comparing MATLAB2014b and MATLAB2015b to reproduce: cfg = struct([]); cfg = config(cfg); cfg.somefield = 'somevalue'; y = cfg.somefield; access(cfg) gives expected output for 2014b, but not for 2015b For now, as discussed with Robert, I will override any trackconfig value other than 'off' in ft_checkconfig when the Matlab version is > 2015a (to be safe), and assign the bug to Robert


Jan-Mathijs Schoffelen - 2017-01-23 10:33:08 +0100

some update: I recompiled the @config/private/*.c files with matlab2016b. The compilation went fine, but the functions still don't work as expected. Interestingly, when compiled with 2016b the functionality is preserved in lower matlab versions (<=2014b). So it seems as if matlab all of a sudden prevents adjustment of the right hand side argument. I recompiled an own version of increment.c including a printf, and indeed, although internally the variable increments, the workspace variable doesn't. I googled around a bit, and there's some chatter about an mxUnshareArray function (undocumented matlab), but I couldn't get this to work, because it requires the library and somehow I can't get this compiled. </p>

Jan-Mathijs Schoffelen - 2017-02-09 12:18:47 +0100

Created attachment 828 low level pointers to mex-file variables matlab version 2013b


Jan-Mathijs Schoffelen - 2017-02-09 12:19:14 +0100

Created attachment 829 low level pointers to mex-file variables matlab version 2016b


Robert Oostenveld - 2022-11-10 09:24:33 +0100

the config object will be removed from FieldTrip, see https://github.com/fieldtrip/fieldtrip/issues/2127