Back to the main page.

Bug 3339 - it would be nice if trialinfo could be a table rather than a numeric array

Reported 2017-08-25 11:13:00 +0200
Modified 2019-08-10 12:36:41 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P5 enhancement
Assigned to: Robert Oostenveld
Depends on:
See also:

Robert Oostenveld - 2017-08-25 11:13:58 +0200

the table class in MATLAB allows for columns to have a label, and for elements of different types in the different columns (like the string on/off in one, and 1..4 in another column) . A bit like a cell-array, but more strict. I propose to investigate what would be neededd to support this. Perhaps it is sufficient that the trialfun returns "trl" as a table rather than numeric array.

Jan-Mathijs Schoffelen - 2017-08-25 11:20:48 +0200

(In reply to Robert Oostenveld from comment #0) I think that this should only be realistically considered if the table-class is backward compatible with a matrix given the bunch of user scripts that depend on trialinfo being a matrix.

Robert Oostenveld - 2017-08-30 09:28:17 +0200

Note that default behavior would not change, i.e. it will only apply if people use a table as output to their own trialfun. LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'}; Age = [38;43;38;40;49]; Height = [71;69;64;67;64]; Weight = [176;163;131;133;119]; BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80]; T = table(Age,Height,Weight,BloodPressure,LastName); All indexing operations in the table that use round brackets () return a table. All operations that use {} return an array (like table2array). >> T(:,1) ans = 5×1 table Age ___ 38 43 38 40 49 >> T{:,1} ans = 38 43 38 40 49 I think that FieldTrip code would only do the first type of indexing, e.g. when rejecting trials. The user could to use the 2nd type of indexing when doing something like this cfg.trials = data.trialinfo{:,1)>40 % age > 40 but could also do cfg.trials = data.trialinfo.Age>40 Sorry, age is a stupid example here. Think of reaction time instead, or some other per-trial measure. I realize that simply making a trialfun that returns trl as table will fail, since ft_preprocessing will do for i=1:ntrl begsample = trl(i,1) endsample = trl(i,2) data.trial{i} = ft_read_data(...) end some changes to ft_read_data (if istable(begsample) ...) would get us quite far.

Robert Oostenveld - 2017-09-22 13:48:36 +0200

I implemented ft_steadystatesimulation to return trialinfo as a table. This subsequently required some changes to the code in ft_rejectartifact, ft_selectdata and convert_event. Rather than to have it percolate slowly, more efficient would be to use ft_checkdata for this. Functions that don't like tables could use 'trialinfostyle' = table/array. When empty, it should remain as it is. Otherwise it should be converted.

Robert Oostenveld - 2017-09-22 13:55:47 +0200

I started with a personal branch to implement this mac011> git commit -a [bug3339-table 934e898] implemneted conversion between table and matrix in ft_checkdata, see 1 file changed, 17 insertions(+) mac011> git push --set-upstream origin bug3339-table Counting objects: 68, done. Delta compression using up to 4 threads. Compressing objects: 100% (68/68), done. Writing objects: 100% (68/68), 7.78 KiB | 0 bytes/s, done. Total 68 (delta 56), reused 0 (delta 0) remote: Resolving deltas: 100% (56/56), completed with 26 local objects. To * [new branch] bug3339-table -> bug3339-table Branch bug3339-table set up to track remote branch bug3339-table from origin.

Robert Oostenveld - 2018-01-07 14:35:50 +0100

this has been slightly further improved in relation to iMotions data and merged into master with

Robert Oostenveld - 2019-08-10 12:36:41 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue on