Is it possible to keep track of trial-specific information in my analysis pipeline?
Sometimes it may be useful to keep trial-specific information tightly linked to your data structure. This trial-specific information for example can relate to the experimental condition, or to behavioral parameters.
Before July 2010 this was implemented in a rather obscure and undocumented way. It was possible to encode trial-specific information in additional columns to the trl-matrix, generated by a custom-written trialfun. The
trl matrix was passed on from one analysis step to another in the cfg structure, which in its turn was appended to the output data-structure. Subsequently, the
trl matrix was accessible by using the following command:
trl = findcfg(data.cfg, 'trl');This procedure was not only obscure, as mentioned, but also not consistent with the notion that a FieldTrip data structure should be self contained, and with the notion that the cfg-field in a FieldTrip data structure just serves the purpose to keep track of previous analysis steps. Therefore we extended the FieldTrip data structures with two field
- the sampleinfo field, [Ntrials x 2] corresponding to the first 2 columns of the original trl-matrix
- the trialinfo field, [Ntrials x M] corresponding to the optional 4th and upwards columns of the original trl-matrix.
Note that the 3rd column of the original
trl matrix is not represented in a separate field. In raw data (data structure containing trials) the offset is represented in each trial’s time axis. A few things can be mentioned about the sampleinfo/trialinfo field:
the sampleinfo field is only meaningful if the data structure is of datatype raw, and consists of epochs which were acquired in a single file, and with a sampling rate equal to the original digitization rate.
the trialinfo field is an optional field, which the user can manually add to a data structure. Alternatively, when a custom-written trialfun outputs a
trlmatrix with more than 3 columns, the subsequent call to ft_preprocessing will automatically create a data structure with a trialinfo (and sampleinfo) field.
old-style (pre July 2010) FieldTrip data structures without sampleinfo/trialinfo can be created by
data = checkdata(data, 'hastrialdef', 'yes');Obviously, only a sampleinfo field will be appended if the data is a raw datatype and a trialinfo will only be appended if the original trl matrix contains more than 3 columns.