<div dir="ltr"><div>Hello everyone! I'm fairly new to Fieldtrip, so I apologize if this question seems trivial, but I've been stuck for a while and I would greatly appreciate everyone's help.</div><div><br></div><div>I have a set of data that I'm working on to get a better sense of how to process EEG data. I'm having trouble with this part when given these instructions: </div><div><br></div><div>"<span style="font-size:12.8px">let's only grab trials in which a '30' also appeared along side the '20'. [These labels are a part of cfg.trialdef.eventtype]. This '30' event code denotes a certain kind of trial in the experiment in which only the colored square was presented. The '30' event code should onset at the same time or within just a few milliseconds of the onset of the '20'. Third, let's also only grab trials in which subjects correctly responded with a button press to the stimulus (i.e., the colored square). To do this, you'll need to make sure there is a '90' following the '20'. The button press (or event code '90') should appear within 1000 ms of the onset of the '20'.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">My question is: how can I designate my code so that I can have a data set that meets the following conditions? I know I should use an 'if' or 'for' but I'm not sure how to write it exactly. Any advice? I've included my code as is without including the file upload. As of now, I created 3 data sets, each one with the required markers (20, 30, and 90).</span></div><div><span style="font-size:12.8px"><br></span></div><div><div style=""><span style="font-size:12.8px">ft_defaults;</span></div><div style=""><span style="font-size:12.8px">cfg = [];</span></div><div style=""><span style="font-size:12.8px">cfg.trialdef.eventtype = '?';</span></div><div style=""><span style="font-size:12.8px">ft_definetrial(cfg);</span></div><div style=""><span style="font-size:12.8px">cfg.trialdef.eventtype = 'Stim';</span></div><div style=""><span style="font-size:12.8px">cfg.trialdef.prestim = 0.2;               </span></div><div style=""><span style="font-size:12.8px">cfg.trialdef.poststim = .8; </span></div><div style=""><span style="font-size:12.8px">cfg.trialdef.eventvalue = '20';</span></div><div style=""><span style="font-size:12.8px">cfg1=ft_definetrial(cfg);</span></div><div style=""><span style="font-size:12.8px">cfg.trialdef.eventvalue = '30';</span></div><div style=""><span style="font-size:12.8px">cfg2=ft_definetrial(cfg);</span></div><div style=""><span style="font-size:12.8px">cfg.trialdef.eventvalue = '90';</span></div><div style=""><span style="font-size:12.8px">cfg3=ft_definetrial(cfg);</span></div><div style=""><span style="font-size:12.8px">cfg.lpfilter='yes';</span></div><div style=""><span style="font-size:12.8px">cfg.lpfreq = 30;</span></div><div style=""><span style="font-size:12.8px">cfg.reref         = 'yes';</span></div><div style=""><span style="font-size:12.8px">cfg.implicitref   = 'REF';</span></div><div style=""><span style="font-size:12.8px">cfg.refchannel    = {'LM' 'REF'};</span></div><div style=""><span style="font-size:12.8px">trialdata1 = ft_preprocessing(cfg1);</span></div><div style=""><span style="font-size:12.8px">trialdata2 = ft_preprocessing(cfg2);</span></div><div style=""><span style="font-size:12.8px">trialdata3 = ft_preprocessing(cfg3);</span></div></div><div style=""><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thank you all so much!</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Hayes Brenner</span></div></div>