[FieldTrip] efficiently handling multiple events within a trial

Eelke Spaak eelke.spaak at donders.ru.nl
Mon May 19 09:20:26 CEST 2014

Hi Anne,

What I usually do is segment my data initially such that a "trial" in
the data structure really corresponds to a logical trial in the
experiment. So, in your case, it would contain the data for both
stimuli and the maintenance period.

I assume you are writing your own trialfun for this (if not, see
In your trialfun, you can specify arbitrary metadata for every trial
by adding extra columns to the output trl-matrix. The 4th and higher
columns in the trl matrix will end up in data.trialinfo in the output
data. This trialinfo field is kept throughout your analysis pipeline,
as long as the data still contains trials. You could, for instance,
store the time index of the response as the 4th column of your trl,
the time index of the feedback onset as the 5th, etc. I always make
sure that at least a condition identifier and a reaction time (if
applicable) appear the trialinfo field.

Once this information is present in data.trialinfo, you can use
ft_selectdata and ft_redefinetrial to select the appropriate trials
and (if necessary) shift the time axis, respectively.

Hope that helps,

On 18 May 2014 19:41,  <anne.urai at gmail.com> wrote:
> Hi Fieldtrippers,
> I have a design in which every trial has several events of interest (two
> stimuli with a maintenance period in between, response and feedback) - all
> of which I’d like to analyse at some point. I started by drafting my
> pipeline separately for stimulus-, response- and feedback-locked trial
> definitions, but this leads me to do the artefact rejection and ICA multiple
> times for each subject. I would prefer to reject whole trials and not use
> any of the events in there, rather than eg. use the response for some and
> the stimulus for others.
> I was wondering if you have any advice on how to best store multiple events
> in one trial (which would be, say, 12 seconds long, and have 4 different
> evens in it, at times that would also need to be stored). Would it work
> better to (1) make one big trialfun and store the onset and offset of each
> of those events in the trl matrix, or (2) have several trl matrices for each
> event and redefine the trials based on this trl matrix after I applied some
> other analyses? For example, it would be nice to run ft_freqanalysis once on
> the whole trial, and then redefine which part of the trial I’m interested in
> for plotting.
> Thanks for your thoughts on this!
> Best,
> ---
> Anne E. Urai, MSc
> PhD student | Institut für Neurophysiologie und Pathophysiologie
> Universitätsklinikum Hamburg-Eppendorf
> Martinistrasse 52, 20246 Hamburg, Germany
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

More information about the fieldtrip mailing list