[FieldTrip] [fieldtrip] Re: Still Reading a Trigger Channel

Ivano Triggiani ivano_triggiani at yahoo.it
Wed Mar 16 12:55:29 CET 2011

Hi Dear,

Jan had a good idea... it seems that .edf files are not good to be read 
automatically for a trigger channel... but writing a simple function on my own I 
found some error (of course...):

evaluating trialfunction 'fun2'
error opening file: pippo.edf
??? One or more output arguments not assigned during call to "read_16bit".

Error in ==> read_edf>readLowLevel at 374
  buf = read_16bit(filename, offset, numwords);

Error in ==> read_edf at 334
      buf = readLowLevel(filename, offset, epochlength); % see below in 

Error in ==> ft_read_data at 562
    dat = read_edf(filename, hdr, begsample, endsample, chanindx);

Error in ==> fun2 at 13
trg = ft_read_data(cfg.datafile, 'header', hdr, ...

Error in ==> ft_definetrial at 123
    trl   = feval(cfg.trialfun, cfg);

Error in ==> program1 at 11
cfg = ft_definetrial(cfg);

have anyone some ideas about it ?


Dear Ivano,

I would first check what 'triggers' fieldtrip automatically detects  
from your data. As far as I am aware, there is no default reading of a  
'trigger' channel for .edf data, but I am not sure.

You can get an idea bout the event-info, by specifying

cfg = [];
cfg.dataset = ...
cfg.trialdef.eventtyp = '?';

This outputs some info to your screen, about which events are in the  
data. Each event is of a certain type 'type' , and may have a value  
'value', e.g. when the acquisition system has an explicit trigger  
channel to which your stimulus presentation program, or response  
device sends discrete trigger pulses of varying height.

In your case, I suspect that something else needs to be done (in case  
definetrial does not show triggers related to your trigger channel),  
i.e. you need to write your own 'trialfun'. Rather than using  
cfg.trialdef.eventtype/eventvalue, you need to specify cfg.trialfun =  
'ivanoscooltrialfun', and you need to write your own file:  
trialfun_ivanoscooltrialfun which defines your segments of interest  
based on some feature in your trigger channel. Here's an example which  
uses an EMG-channel as epoch-defining signal. Of course your trigger  
channel needs to be processed in a different way but at least it gives  
you an impression.


Good luck


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20110316/01fbc34a/attachment-0001.html>

More information about the fieldtrip mailing list