[FieldTrip] Question about ft_read_event and read_trigger - Neuromag .fif file

Justyna Gula justyna.j.gula at gmail.com
Thu Aug 20 16:51:27 CEST 2020


Dear all,
I have a problem using the ft_read_event function. I am trying to read
events from MEG data in a .fif file (306-channel Vectorview system, Elekta
Neuromag, Helsinki, Finland). I am interested in the STI101 channel which
is described as 'digital trigger' in the header. Unfortunately, the value
field of the output is different than expected (I read the file in Python
using the MNE library and I get correct results).

I noticed that in line 1463 of the ft_read_event function binaryindx is
found as 'digital trigger' in channel type, but later read_trigger function
is called (line 1473), which looks for 'binary trigger' in channel type
(line 139 of read_triger function). If I stop the code before line 139 in
read_trigger function, change the type of the channel STI101 into 'binary
trigger' from 'digital trigger' and continue, I get correct results.

I would like to ask if my change makes sense and what can be the cause of
the wrong value field of the output without the change.

Thank you for your help and best wishes,
Justyna Gula

%%
I call the function:
events= ft_read_event(filename,'type','STI101');

Part of the ft_read_event function:

analogindx = find(strcmp(ft_chantype(hdr), 'analog trigger'));
otherindx  = find(strcmp(ft_chantype(hdr), 'other trigger'));
binaryindx = find(strcmp(ft_chantype(hdr), 'digital trigger'));

and later:

if ~isempty(binaryindx)
        trigger = read_trigger(filename, 'header', hdr, 'dataformat',
dataformat, 'begsample', flt_minsample, 'endsample', flt_maxsample,
'chanindx', binaryindx, 'detectflank', detectflank, 'trigshift', trigshift,
'fixneuromag', false);
        event   = appendevent(event, trigger);
 end

Part of the read_trigger function:

switch hdr.chantype{chanindx(1)}
      case 'binary trigger'
        if any(dat(k,:)<0)
          dat(k,:) = double(typecast(int16(dat(k,:)), 'uint16'));
        end
      case 'analog trigger'
        % keep it as it is
      case 'other trigger'
        % keep it as it is
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200820/49de923f/attachment.htm>


More information about the fieldtrip mailing list