<div dir="ltr"><div><div><div><div>Hi Hayes,<br><br></div>This isn't really about Fieldtrip specifically, but is a MATLAB programming issue; that is to say, the solution isn't a special Fieldtrip function or anything like that, just basic MATLAB coding. (There might be a Fieldtrip-internal solution, like there is in ERPLAB for relatively complex trial selection, but I'm not aware of it.)<br><br></div>All you really need to do is rewrite the trigger numbers so they distinguish the kinds of triggers you actually need. For example, rather than all trials of a given condition being coded as 30, you might want correct trials in that condition to be 31 and incorrect trials 32; the same logic also goes for recoding the trials based on whether or not there was a 20 nearby. All this information about trial timing is available in the 'cfg.trl' matrix that is created after you run ft_definetrial (see <a href="http://www.fieldtriptoolbox.org/reference/definetrial">http://www.fieldtriptoolbox.org/reference/definetrial</a> for details about how this matrix is organized). So all you need to do is write a FOR loop that iterates through each row of the trl matrix, and for each row checks (using an IF statement) whether that row meets the various conditions you outlined, and rewrites that row's trigger code if it meets those conditions. Then you can pull out a list of which trials you want (this is doable with basic MATLAB code, e.g., find(cfg.trl(:,3)==31) gives you a list of the row numbers of every trial with a code of 31) and use that list with ft_preprocessing to process just the trials you want.<br><br></div>Best,<br></div>Steve<br><div><div><div><div><div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span><div><br><br>---<br></div>Stephen Politzer-Ahles<br>University of Oxford<br>Language and Brain Lab<br>Faculty of Linguistics, Phonetics & Philology<br><a href="http://users.ox.ac.uk/~cpgl0080/" target="_blank">http://users.ox.ac.uk/~cpgl0080/</a></span></div></div></div></div></div></div></div>
<div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Message: 3<br>
Date: Wed, 27 Jan 2016 20:57:20 -0600<br>
From: Hayes Brenner <<a href="mailto:hayes.brenner@gmail.com">hayes.brenner@gmail.com</a>><br>
To: <a href="mailto:fieldtrip@science.ru.nl">fieldtrip@science.ru.nl</a><br>
Subject: [FieldTrip] How to select trials based on their timing<br>
Message-ID:<br>
<<a href="mailto:CAB--YMYoCGP7KKCW-a7DwP2iZgyCVO-D_SJh1dmjUP79NtcLow@mail.gmail.com">CAB--YMYoCGP7KKCW-a7DwP2iZgyCVO-D_SJh1dmjUP79NtcLow@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hello everyone! I'm fairly new to Fieldtrip, so I apologize if this<br>
question seems trivial, but I've been stuck for a while and I would greatly<br>
appreciate everyone's help.<br>
<br>
I have a set of data that I'm working on to get a better sense of how to<br>
process EEG data. I'm having trouble with this part when given these<br>
instructions:<br>
<br>
"let's only grab trials in which a '30' also appeared along side the '20'.<br>
[These labels are a part of cfg.trialdef.eventtype]. This '30' event code<br>
denotes a certain kind of trial in the experiment in which only the colored<br>
square was presented. The '30' event code should onset at the same time or<br>
within just a few milliseconds of the onset of the '20'. Third, let's also<br>
only grab trials in which subjects correctly responded with a button press<br>
to the stimulus (i.e., the colored square). To do this, you'll need to make<br>
sure there is a '90' following the '20'. The button press (or event code<br>
'90') should appear within 1000 ms of the onset of the '20'.<br>
<br>
My question is: how can I designate my code so that I can have a data set<br>
that meets the following conditions? I know I should use an 'if' or 'for'<br>
but I'm not sure how to write it exactly. Any advice? I've included my code<br>
as is without including the file upload. As of now, I created 3 data sets,<br>
each one with the required markers (20, 30, and 90).<br>
<br>
ft_defaults;<br>
cfg = [];<br>
cfg.trialdef.eventtype = '?';<br>
ft_definetrial(cfg);<br>
cfg.trialdef.eventtype = 'Stim';<br>
cfg.trialdef.prestim = 0.2;<br>
cfg.trialdef.poststim = .8;<br>
cfg.trialdef.eventvalue = '20';<br>
cfg1=ft_definetrial(cfg);<br>
cfg.trialdef.eventvalue = '30';<br>
cfg2=ft_definetrial(cfg);<br>
cfg.trialdef.eventvalue = '90';<br>
cfg3=ft_definetrial(cfg);<br>
cfg.lpfilter='yes';<br>
cfg.lpfreq = 30;<br>
cfg.reref = 'yes';<br>
cfg.implicitref = 'REF';<br>
cfg.refchannel = {'LM' 'REF'};<br>
trialdata1 = ft_preprocessing(cfg1);<br>
trialdata2 = ft_preprocessing(cfg2);<br>
trialdata3 = ft_preprocessing(cfg3);<br>
<br>
Thank you all so much!<br>
<br>
Hayes Brenner<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20160127/b0726da2/attachment-0001.html" rel="noreferrer" target="_blank">http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20160127/b0726da2/attachment-0001.html</a>><br>
<br>
------------------------------<br><br></blockquote></div><br></div></div></div></div></div></div></div>