<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; } @font-face { font-family: AvenirNextRegular; src: url("chrome-extension://bmikpgodpkclnkgmnpphehdgcimmided/fonts/AvenirNextLTPro-Regular.otf") format("opentype"); font-weight: normal; font-style: normal; } @font-face { font-family: AvenirNextBold; src: url("chrome-extension://bmikpgodpkclnkgmnpphehdgcimmided/fonts/AvenirNextLTPro-Bold.otf") format("opentype"); font-weight: bold; font-style: normal; } .myki-preloader-input { transform: translateX(0px) !important; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi Carolina,<br>
</p>
<p><br>
</p>
<p>It is true that filtering can cause edge effects. If you use ft_preprocessing on continuous data, you can make use of the option cfg.padding. See here for details <a href="http://www.fieldtriptoolbox.org/faq/how_does_the_filter_padding_in_preprocessing_work/">http://www.fieldtriptoolbox.org/faq/how_does_the_filter_padding_in_preprocessing_work/</a>​<br>
</p>
<p><br>
</p>
<p>Doing it like this will save you the trouble of having to redefine trials after artifact rejection.<br>
</p>
<p><br>
</p>
<p>Hope this helps,<br>
</p>
<p>Sophie<br>
</p>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Carolina Ogawa <carolyogawa@gmail.com><br>
<b>Sent:</b> Thursday, July 18, 2019 7:55 PM<br>
<b>To:</b> Arana, S.L. (Sophie)<br>
<b>Subject:</b> Re: [FieldTrip] Updating trial information</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hi, Sophie,
<div><br>
</div>
<div>Thank you very much for your reply!</div>
<div><br>
</div>
<div>Filtering the data after cutting it into trials doesn't distort the edges of the trials? For this reason, I've always thought that it was better to filter the continuous data first and then cut it into trials. But maybe I should cut larger trials first
 and then cut the edges?</div>
<div><br>
</div>
<div>In case I want to stick to my order of processing steps (rereferencing / filtering => defining trials => rejecting segments with artifacts), how do I get the trial information (the time points for each event in my data, which is stored in "cfg.event" and
 "cfg.trl") updated after rejecting segments with  artifacts?</div>
<div><br>
</div>
<div><br>
</div>
<div>Best,</div>
<div>Carolina  </div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, Jul 18, 2019 at 4:07 AM Arana, S.L. (Sophie) <<a href="mailto:S.Arana@donders.ru.nl">S.Arana@donders.ru.nl</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi Carolina,<br>
</p>
<p><br>
</p>
<p>I am not sure whether there is a reason why you read the data in as continuous first? If not your pipeline might be more efficient if you first define the trials with ft_definetrial and then read in / segment / filter the data by passing the resulting cfgout
 to ft_preprocessing (basically following this tutorial <a href="http://www.fieldtriptoolbox.org/tutorial/preprocessing/" target="_blank">http://www.fieldtriptoolbox.org/tutorial/preprocessing/</a>) and subsequently use ft_databrowser on the already segmented
 trials.<br>
</p>
<p><br>
</p>
<p>If you need to stick to your order of processing steps, then maybe the function you are looking for is ft_redefinetrial, which allows you to cut data into trials at a later stage.<br>
</p>
<p><br>
</p>
<p>best,<br>
</p>
<p>Sophie<br>
</p>
<p><br>
</p>
<div style="color:rgb(33,33,33)">
<hr style="display:inline-block; width:98%">
<div id="gmail-m_-381234062613442423divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> fieldtrip <<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a>>
 on behalf of Carolina Ogawa <<a href="mailto:carolyogawa@gmail.com" target="_blank">carolyogawa@gmail.com</a>><br>
<b>Sent:</b> Wednesday, July 17, 2019 5:22 PM<br>
<b>To:</b> <a href="mailto:fieldtrip@science.ru.nl" target="_blank">fieldtrip@science.ru.nl</a><br>
<b>Subject:</b> [FieldTrip] Updating trial information</font>
<div> </div>
</div>
<div>
<div dir="ltr">Dear community,
<div><br>
</div>
<div>My name is Carolina Ogawa, and I'm working with EEG at the University of Sao Paulo, Brazil. I intend to analyze oscillatory gamma activity from the EEG data I recorded.</div>
<div><br>
</div>
<div>I'd like to know how I get the trial information (the information stored in "cfg.event" and "cfg.trl") updated after rejecting segments of data (due to artifacts), so that my data will be correctly segmented into trials afterwards.</div>
<div><br>
</div>
<div>My pipeline involves, in the following order:</div>
<div>
<ol>
<li>Rereferencing and filtering (ft_preprocesing)<br>
<br>
(cfg definition)<br>
...<br>
data_filt      = ft_preprocessing(cfg);<br>
<br>
</li><li>Defining trials with ft_definetrial (so that I have the trials information stored on "cfgout.trl")<br>
<br>
    cfg                            = [];<br>
    cfg.dataset                 = fullfile(path_inputData,subject{i});<br>
    cfg.trialdef.eventtype = 'Stimulus';<br>
    cfg.trialfun                   = 'ft_trialfun_general';<br>
    cfgout                         = ft_definetrial(cfg);<br>
<br>
</li><li>Removing segments with artifacts, using ft_databrowser and ft_rejectartifact. (EEG data is continuous up to this point).<br>
<br>
    cfg               = [];<br>
    cfg.continuous    = 'yes'; <br>
    cfg.channel       = 'all';<br>
    cfg.viewmode      = 'butterfly';<br>
    artif             = ft_databrowser(cfg, data_filt);<br>
<br>
    cfg                        = [];<br>
    cfg.artfctdef.minaccepttim = 0.010;<br>
    cfg.artfctdef.reject       = 'partial';<br>
    cfg.artfctdef.visual.artifact = artif.artfctdef.visual.artifact;<br>
    data_rejInt = ft_rejectartifact(cfg, data_filt);<br>
</li></ol>
<div><br>
</div>
<div><br>
</div>
<div>I tried using "ft_recodeevent", as follows:</div>
</div>
<div>
<blockquote style="margin:0px 0px 0px 40px; border:none; padding:0px">
<div>cfg = [];<br>
trl = cfgout.trl;<br>
cfg.trl = trl;<br>
cfg.eventtype = 'Stimulus';<br>
[ev] = ft_recodeevent(cfg, data_rejInt);<br>
</div>
<div><br>
</div>
</blockquote>
</div>
<div>
<div>but I get this error:</div>
</div>
<div>
<blockquote style="margin:0px 0px 0px 40px; border:none; padding:0px">
<div>Error using ft_recodeevent (line 114) could not locate event structure in the data<br>
</div>
<div><br>
</div>
</blockquote>
<br>
</div>
<div>Can someone tell me if there something wrong with the "cfg" settings of if I'm using an improper function to this situation? I also tried running "ft_rejectartifact" with "cfg" as the only input parameter, expecting that the output would be a "cfg" structure
 with an updated "trl" (as described in the "ft_rejectartifact" reference page). Instead, what I receive is the error:</div>
<div><br>
</div>
<blockquote style="margin:0px 0px 0px 40px; border:none; padding:0px">Undefined function or variable "trl".<br>
Error in ft_rejectartifact (line 252) if isempty(trl) <br>
<br>
<br>
</blockquote>
Any help would be appreciated,
<div><br>
</div>
<div>Best,</div>
<div>Carolina</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>