Back to the main page.

Bug 2528 - ft_math problem with .avg in timelock data

Status ASSIGNED
Reported 2014-04-08 14:53:00 +0200
Modified 2014-04-08 22:35:19 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also: http://bugzilla.fcdonders.nl/show_bug.cgi?id=2185

Johanna - 2014-04-08 14:53:52 +0200

I see related bug 2051 (now closed). My data is timelock with keeptrials='yes' and it also has .avg field. I want to call ft_math as such: cfg=[]; cfg.operation='subtract'; cfg.parameter='avg'; data1_data2=ft_math(cfg,data1,data2); I first received an error due to not finding .avg field. This is because it was removed by ft_selectdata (line 99). But then I realised I was on FT version r9293, and so did an SVN update to current (r9378). Now I get an error within ft_selectdata_new (called by ft_math line 99) My input looks like: data1 = avg: [63x2000 double] var: [63x2000 double] time: [1x2000 double] dof: [63x2000 double] label: {63x1 cell} trial: [42x63x2000 double] dimord: 'rpt_chan_time' trialinfo: [42x5 double] cfg: [1x1 struct] The error now is: Index exceeds matrix dimensions. Error in ft_selectdata_new>cellmatselect (line 1323) x = x(:,:,selindx,:,:,:); Error in ft_selectdata_new>makeselection (line 670) data.(datfields{i}) = cellmatselect(data.(datfields{i}), seldim, selindx); Error in ft_selectdata_new (line 385) varargin{i} = makeselection(varargin{i}, find(strcmp(dimtok,'time')), seltime{i}, avgovertime, datfields, cfg.select); Error in ft_selectdata (line 51) [varargout{1:nargout}] = ft_selectdata_new(varargin{:}); Error in ft_math (line 99) [varargin{:}] = ft_selectdata(tmpcfg, varargin{:});


Johanna - 2014-04-08 14:59:31 +0200

An easy workaround is below, but just wondering if this is something that should be fixed. cfg=[]; cfg.operation='subtract'; cfg.parameter='avg'; data1_data2=ft_math(cfg,ft_timelockanalysis([],data1),ft_timelockanalysis([],data2));


Robert Oostenveld - 2014-04-08 22:35:05 +0200

I made a test script (see below) that confirms the problem. If the dimord is chan_time instead of rpt_chan_time, it works fine. The output in that case does not contain any trial-related fields. mbp> svn commit test/test_bug2528.m Adding test/test_bug2528.m Transmitting file data . Committed revision 9383. I have a plan for an improved ft_selectdata. It should perform selections (along data dimensions) regardless of the selection of data fields. The trick would be that it would start by first making all fields explicitly described by a dimord. So rather than data1.dimord, there would be data1.avgdimord = chan_time data1.vardimord = chan_time data1.dofdimord = chan_time data1.trialdimord = rpt_chan_time data1.trialinfodimord = rpt_unknown so even trialinfo (and cumtapcnt, cov, crsspctrm and the likes) would have a dimord. Each of the selections would them be performed explicitly in whatever data field with that dimension. The selection of the parameter on which the subsequent computation is performed then becomes a different issue. In the output of ft_selectdata the temporary dimords would be scrubbed, i.e. the main dimord would again be called dimord. This implementation of ft_selectdata is high on my priority and relates to bug 2185, on which I am also working.