too many trials/overlapping trials

Christian Hesse c.hesse at FCDONDERS.RU.NL
Fri Feb 9 16:21:15 CET 2007

Hi Sameer,

thanks for the additional info and data from the STI101 channel you
sent me.

I think that the double counting of your triggers must be caused by
the way that the function "trialfun_general.m" computes the (valid)
flanks for your data format (e.g., line 467, and see all the comments
in lines nearby). Using the content of your STI101 channel (referred
to as x below) I was unable to reproduce the double counting using a
slightly simpler approach:

d = [0, diff(x)];
ii = find((d~=0) & (x==7));
% length(ii) gives 30
ii = find((d~=0) & (x==11));
% length(ii) gives 30

For the time being, the easiest solution (in my view, since you have
the STI101 channel) is to construct the "trl" matrix from the content
of the ii arrays above for each trigger, and copy this into the cfg
structure used to call preprocessing.m:
cfg.trl = trl;

The more elegant solution in a Fieldtrip sense is to write your own
trialfun, which would consist of wrapper code around the essential
operations outlined above. I suggest you have a closer look at the
code and documentation in preprocessing.m and definetrial.m if you
decide to pursue this route.

Hope this helps,

On 7 Feb 2007, at 17:30, Sameer Walawalkar wrote:

> Thanks for the reply Robert. here's some more info.
>> Dear Sameer,
>> Maybe you could try
>> cfg =  []    ;
>> cfg.dataset = 'JD_012507_Beeps_One.fif' ;
>> cfg.trialdef.eventtype  = '?';
>> dum =  definetrial(cfg);
>> and look what is printed on screen.
> evaluating trialfunction 'trialfun_general'
> the following events were found in the datafile
> event type: 'STI101' with event values: 5      6      7      8
> 9 11     15  16388  16391  16392  16396
> event type: 'STI301' with event values: 5.0003      5.0018 ...(many
> more...)
> event type: 'trial' with event values:
> no trials have been defined yet, see DEFINETRIAL for further help
> found 61361 events
> created 0 trials
> (I address another point at the bottom of the email. I have left
> the following paragraphs in for refrence)
>>> My first problem is, I should have 30 trials for this event. The
>>> file
>>> contains a total of 60 trials, but the other 30 are for eventtype
>>> = 11
>>> So it is clearly doing something wrong.
>>> Next, I decided to see what is in cfg.trl and I get the Nx3
>>> matrix that I find the following problems with it
>>> 1> each trial should be 4000 milli seconds long. That happens here,
>>> however, there seem to be overlap between trials which does not make
>>> sense. This is what leads to the double counting. Thus I get 4000
>>> msec long trials bunched in group of two where the second trial
>>> starts about 1000 to 1300 msecs after the beginning of the first
>>> trial.
>> Please have a look in cfg.event.
>>> 2> If the first trial is at 8502, all subsequent trials should be in
>>> increments of integral multiples of 4000 ( plus or minus a few).
>>> But that does not seem to happen (and I am looking at on the
>>> leading trial of the pair and discounting the trials that follow
>>> 1000 msecs later.)
>> That means that there are events detected that are not supposed to
>> be there according to your knowledge of the dataset. Could it be
>> that both the positive and the negative flank of the trigger are
>> detected?
> I have looked into this as it was the first thing I suspected. What
> has been confusing me is that it seems to be counting the rising
> flank of the correct trigger and the falling flank of the earlier
> trigger, even though the event type for the earlier trigger is
> different. I am looking for
> cfg.trialdef.eventtype = 'STI101' and
> cfg.trialdef.eventvalue = 7 or 11.
> The earlier falling trigger  is 5,6 or 8.9 and so should not be
> considered at all. I never use STI301
> sameer

Christian Hesse, PhD, MIEEE

F.C. Donders Centre for Cognitive Neuroimaging
P.O. Box 9101
NL-6500 HB Nijmegen
The Netherlands

Tel.: +31 (0)24 36 68293
Fax: +31 (0)24 36 10989

Email: c.hesse at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the fieldtrip mailing list