[FieldTrip] using triggers building my own function

Lam, N.H.L. (Nietzsche) n.lam at donders.ru.nl
Fri May 29 11:59:33 CEST 2015


Hi Moran,

It was a bit difficult to understand your question, but I've tried to answer them below.
For your main question: Yes, it is possible to cut up your EEG data into individual trials, with the time (i.e. 1 second) that you specify.

The function that cuts up your EEG data is known as ft_definetrial.  However, ft_definetrial needs to read information from another function that explicitly tells it how to do the cutting.  Usually, that function is "ft_trialfun_general"  (this is the tutorial link you mentioned).   However, if you have a complicated set of triggers or ways you want to cut up your data, you will be better off writing your own trialfun (" trial function").

If you need to write your trialfun, you should check out these example scripts / tutorials:
http://www.fieldtriptoolbox.org/example/making_your_own_trialfun_for_conditional_trial_definitionhttp://www.fieldtriptoolbox.org/example/making_your_own_trialfun_for_conditional_trial_definition

http://www.fieldtriptoolbox.org/tutorial/eeg_preprocessing_erphttp://www.fieldtriptoolbox.org/tutorial/eeg_preprocessing_erp

To answer your " little " questions
1. cfg.trialdef.eventvalue = [3 5 9];
3 5 9 are trigger codes.   This tells your function to go into your data, look for these trigger codes, and cut your data with respect to the location of these triggers

E.g., your data trigger codes look like this  ----1 ----- 3 ------ 4 ------5 ----- 9 ----.
In this case, the ft_definetrial will only use  triggers 3, 5, and 9 as relative points for cutting your data,  trigger 1 and 4 will be ignored.
N.B. The data at trigger 1 might end up in your time window that contains trigger 3 if you define your time window to be very. To understand this, see below.

2. cfg.trialdef.prestim    = 1;
cfg.trialdef.poststim   = 2;

These 2 parameters are important.  The values are defined in seconds.  So  cfg.trialdef.prestim refers to 1s before your trigger (i.e. prestim = prestimulus onset, where stimulus onset is referred to the sample point of your chosen trigger).  cfg.trialdef.poststim refers to 2s after your trigger.
In this way  you would end up with a 3 second time window (1 second before trigger, and 2 seconds after).

You mentioned you wanted " specific time [in data] + one second".
So you 1) determine which triggers mark the " specific time [in your data]"
2) specify cfg.trialdef.poststim = 1.

Hope this helps and good luck,
Nietzsche
________________________________
From: fieldtrip-bounces at science.ru.nl [fieldtrip-bounces at science.ru.nl] on behalf of moran abilea [mor2451 at gmail.com]
Sent: 28 May 2015 16:56
To: FieldTrip discussion list
Subject: [FieldTrip] using triggers building my own function

hi everyone,
so i'm trying to create my own function for using triggers with EEG raw data.
i used this tutorial:
http://www.fieldtriptoolbox.org/tutorial/preprocessing

my question is if i can somehow specify the time i want to record my EEG data?
for example i would like my function to get 'time' as parameter to the function and returns the EEG raw data of this specific time+one second.
if so, can some one give me a piece of code for example to understand what to do?

also 2 more little questions:
1. cfg.trialdef.eventvalue = [3 5 9]; what does the 3 5 9 stands for? i don't understand what is the meaning of those (or any other) numbers. can i get definition for what is event value?
2. cfg.trialdef.prestim    = 1;
cfg.trialdef.poststim   = 2;
does it means it takes exactly one second for the buffer to give me the EEG raw data? or does it means wait one second and then take the data from the buffer or something like that (1 second the trigger will "pop out" and finish taking the data from the buffer after 2 seconds)

the triggers are new to me, so i have some problems to understand the concept of it, thus my questions for you guys.

i hope i explained myself as clear as possible, i really would like to understand what i'm doing.

regards,
Moran Abilea
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150529/015b5c2a/attachment-0001.html>


More information about the fieldtrip mailing list