how to edit Neuromag trigger list

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Tue Feb 15 13:03:51 CET 2005

Hi Daniel

[I am forwarding this mail to the FieldTrip list, since other people
there might be interested as well or may be able to help you out]

> I've just started using Fieldtrip and I want to use it with Neuromag
> system, which is in BioMag laboratory in Helsinki.

Am I correct that that is a 306 channel Vectorview?

> Could you please tell me is it equally easy to import EEG channels,
> that were recorded together with MEG or I should do some additional
> things?

FieldTrip is using Kimmo Uutela's meg-pd toolbox to read in the fif
files. I have not tested it on fif files that also contain eeg
channels, so I am not sure how the meg-pd toolbox handles them.
However, I would expect that they are treated identically as MEG
channels, which means that FieldTrip will also treat them the same.

A couple of days ago, there was a thread on the mailing list on reading
in CFT data. Jan-Mathijs replied and explained how to test the support
for a specific dataformat using READ_FCDC_HEADER and READ_FCDC_DATA.
You can try that as well (see

> I also would like to edit the list of triggers in the recorded file.
> The thing is, that Neuromag system allows only 16 triggers, while I
> need 32 of them. It's a language study and I need to mark differently
> different syntactic members of the sentence. Could you kindly tell if
> there is a way to edit triggers in Fieldtrip before averaging MEG and
> EEG data.

We don't have options to "edit" triggers in the raw data files, but we
do have options to handle complicated experimental designs in

I assume that you have recorded triggers along with the MEG signal
during the experiment. Furthermore, I also assume that you somehow have
encoded your 32 different events in the 16 Neuromag trigger channels in
such a way, that you can determine afterwards which sequence of
triggers corresponds with which experimental condition/stimulus. Right?

In FieldTrip we work with a trial definition ("trl"), where a trial is
a piece of data that you consider to be interesting. The DEFINETRIAL
function looks at the data, and returns such a trial definition. The
trial definition is subsequently used for artifactdetection and for
preprocessing (i.e. filtering ad baselinecorrection of the data). The
DEFINETRIAL supports "simple" trial definitions, such as plain
triggers, but it also supports an external trialfuncion (cfg.trialfun).
With an external trialfunction, you can combine a sequence of multiple
triggers into a trial definition ("trl"). Please read the help of
DEFINETRIAL. Furthermore, probably you can use the READ_FCDC_EVENT
function to collect the interesting events (i.e. the triggers) from
your fif file.

This is an example trialfun (it should be a separate matlab function)
function trl = trialfun(cfg);
hdr = read_fcdc_header(cfg.dataset);
event = read_fcdc_event(cfg.dataset);
trl = [];
for i=1:length(event)
   if strcmp(event(i).type, 'backpanel trigger')
     % it is a trigger, see whether it has the right value
     if event(i).value==3
       % add this to the trl definition
       begsample = event(i).sample - 0.1*hdr.Fs;
       endsample = event(i).sample + 0.4*hdr.Fs - 1;
       offset    = - 0.1*hdr.Fs;
       trl(end+1, :) = round([begsample endsample offset]);

best regards,

More information about the fieldtrip mailing list