<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello Frans,<div class=""><br class=""></div><div class="">I don’t know whether there is a specific reason that TF segments first and filters later, but here’s what I do in order to be sure that the filtering is done on the whole epoch (<a href="https://urldefense.com/v3/__https://github.com/BioPsychKiel/SpringSchool2022/blob/main/track_02/01_Code/sc01_preproc.m__;!!HJOPV4FYYWzcc1jazlU!_yF8KxqbQ9i7O04I1jY6rUBExCiDZCkq2juuIOst9PZY0BoNkNcN_XM_EdKi85VuqUKBBTFIkjVBq0cmPuLpKQN0Bg$" class="">https://github.com/BioPsychKiel/SpringSchool2022/blob/main/track_02/01_Code/sc01_preproc.m</a>):</div><div class=""><br class=""></div><div class=""><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC35" class="js-file-line blob-code-inner blob-code"><span class="pl-c" style="font-style: normal; font-size: 12px;"><font face="Monaco" class=""><span class="pl-c">%</span> 1.1. First, read in the header to define the trials</font></span></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC36" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg <span class="pl-k">=</span> []; <span class="pl-c"><span class="pl-c">%</span> Always clear the configuration</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC37" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.dataset <span class="pl-k">=</span> [<span class="pl-smi">inpath</span>,<span class="pl-en">indat</span>(<span class="pl-smi">v</span>).name]; <span class="pl-c"><span class="pl-c">%</span> Set the dataset</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC39" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class="">cfg.trialdef.eventtype <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>Markers<span class="pl-pds">'</span></span>; <span class="pl-c"><span class="pl-c">%</span> We now know that the trigger channel is called 'Stimulus'</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC40" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.trialdef.eventvalue <span class="pl-k">=</span> {<span class="pl-c1">20</span>,<span class="pl-c1">30</span>}; <span class="pl-c"><span class="pl-c">%</span> Define the relevant triggers</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC41" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.trialdef.prestim <span class="pl-k">=</span> <span class="pl-c1">1.5</span>; <span class="pl-c"><span class="pl-c">%</span> Seconds before the stimulus</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC42" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.trialdef.poststim <span class="pl-k">=</span> <span class="pl-c1">1.5</span>; <span class="pl-c"><span class="pl-c">%</span> Seconds after the stimulus</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC43" class="js-file-line blob-code-inner blob-code">
</td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC44" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg <span class="pl-k">=</span> <span class="pl-en">ft_definetrial</span>(<span class="pl-smi">cfg</span>); <span class="pl-c"><span class="pl-c">%</span> Store the trial definition</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC45" class="js-file-line blob-code-inner blob-code">
</td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC46" class="js-file-line blob-code-inner blob-code"> <span class="pl-c" style="font-style: normal; font-size: 12px;"><font face="Monaco" class=""><span class="pl-c">%</span> 1.2. Save the trial-definition</font></span></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC47" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> trl <span class="pl-k">=</span> <span class="pl-smi">cfg</span>.<span class="pl-smi">trl</span>;</span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC48" class="js-file-line blob-code-inner blob-code">
</td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC49" class="js-file-line blob-code-inner blob-code"> <span class="pl-c" style="font-style: normal; font-size: 12px;"><font face="Monaco" class=""><span class="pl-c">%</span> 1.3. Then define the entire dataset</font></span></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC50" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg <span class="pl-k">=</span> []; <span class="pl-c"><span class="pl-c">%</span> Always clear the configuration</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC51" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.dataset <span class="pl-k">=</span> [<span class="pl-smi">inpath</span>,<span class="pl-en">indat</span>(<span class="pl-smi">v</span>).name]; <span class="pl-c"><span class="pl-c">%</span> Set the dataset</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC52" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.trialdef.ntrials <span class="pl-k">=</span> <span class="pl-c1">1</span>; <span class="pl-c"><span class="pl-c">%</span> One long trial to cover the entire dataset</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC53" class="js-file-line blob-code-inner blob-code">
</td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC54" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg <span class="pl-k">=</span> <span class="pl-en">ft_definetrial</span>(<span class="pl-smi">cfg</span>); <span class="pl-c"><span class="pl-c">%</span> Store the trial definition</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC55" class="js-file-line blob-code-inner blob-code"> </td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC56" class="js-file-line blob-code-inner blob-code"> <span class="pl-c" style="font-style: normal; font-size: 12px;"><font face="Monaco" class=""><span class="pl-c">%%</span> <span class="pl-en">2. Preprocessing</span></font></span></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC57" class="js-file-line blob-code-inner blob-code"> <span class="pl-c" style="font-style: normal; font-size: 12px;"><font face="Monaco" class=""><span class="pl-c">%</span> This step will read, filter and cut the raw data</font></span></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC58" class="js-file-line blob-code-inner blob-code"> </td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC59" class="js-file-line blob-code-inner blob-code"> <span class="pl-c" style="font-style: normal; font-size: 12px;"><font face="Monaco" class=""><span class="pl-c">%</span> 2.1. Read in the raw data and filter</font></span></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC60" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.demean <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>yes<span class="pl-pds">'</span></span>; <span class="pl-c"><span class="pl-c">%</span> Remove mean across time to get rid of offset</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC61" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.hpfilter <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>yes<span class="pl-pds">'</span></span>; <span class="pl-c"><span class="pl-c">%</span> Highpassfilter to remove slow drifts</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC62" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.hpfreq <span class="pl-k">=</span> <span class="pl-c1">.1</span>; <span class="pl-c"><span class="pl-c">%</span> Highpass frequency. 0.1 removes most slow drifts</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC63" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.hpfilttype <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>firws<span class="pl-pds">'</span></span>; <span class="pl-c"><span class="pl-c">%</span> Type of filter</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC64" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.lpfilter <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>yes<span class="pl-pds">'</span></span>; <span class="pl-c"><span class="pl-c">%</span> The same for lowpass</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC65" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.lpfreq <span class="pl-k">=</span> <span class="pl-c1">45</span>; <span class="pl-c"><span class="pl-c">%</span> 50Hz line noise destroys the data, only take data below</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC66" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.lpfilttype <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>firws<span class="pl-pds">'</span></span>; <span class="pl-c"><span class="pl-c">%</span> Again the type</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC67" class="js-file-line blob-code-inner blob-code">
</td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC68" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> data_p <span class="pl-k">=</span> <span class="pl-en">ft_preprocessing</span>(<span class="pl-smi">cfg</span>);</span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC69" class="js-file-line blob-code-inner blob-code"><br class=""></td></tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC75" class="js-file-line blob-code-inner blob-code"> <span class="pl-c" style="font-style: normal; font-size: 12px;"><font face="Monaco" class=""><span class="pl-c">%</span> 2.2. Cut the data according to the trial definition</font></span></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC76" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg <span class="pl-k">=</span> [];</span></font></td>
</tr>
<tr class="">
</tr></tbody></table><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC77" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class=""> cfg.trl <span class="pl-k">=</span> <span class="pl-smi">trl</span>; <span class="pl-c"><span class="pl-c">%</span> Use the trl-structure defined above</span></span></font></td>
</tr>
<tr class="">
</tr></tbody></table><br class=""><table data-hpc="" class="js-tagsearch-file highlight tab-size js-file-line-container js-code-nav-container" data-tab-size="8" data-paste-markdown-skip="" data-tagsearch-lang="MATLAB" data-tagsearch-path="track_02/01_Code/sc01_preproc.m"><tbody class=""><tr class=""><td id="LC78" class="js-file-line blob-code-inner blob-code"><font face="Monaco" class=""><span style="font-style: normal; font-size: 12px;" class="">data_t <span class="pl-k">=</span> <span class="pl-en">ft_redefinetrial</span>(<span class="pl-smi">cfg</span>,<span class="pl-smi">data_p</span>);</span></font></td></tr></tbody></table><div><br class=""></div><div>Please not that this takes quite a bit longer than doing it the FT-way.</div><div>I hope this helps,</div><div><br class=""></div><div>Julian</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">Am 15.02.2023 um 11:33 schrieb Frans Nord via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello mailing-list,<div class=""><br class=""></div><div class="">I have a question regarding the comment about Fieldtrip in the recently published paper "EEG is better left alone" [1]. While I don't agree with the conclusions of the paper there is a specific comment regarding Fieldtrip that I would like some comments about:</div><div class=""><span style="color:rgb(29,28,29);font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif;font-size:15px;font-variant-ligatures:common-ligatures;background-color:rgb(248,248,248)" class=""><br class=""></span></div><div class=""><font color="#1d1c1d" face="Slack-Lato, Slack-Fractions, appleLogo, sans-serif" class=""><span style="font-size:15px;font-variant-ligatures:common-ligatures;background-color:rgb(248,248,248)" class="">"</span></font><span style="font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:18px" class="">We realized that the FieldTrip preprocessing function extracts data epochs before filtering the data when provided with both filter settings and epoch information. After consulting with FieldTrip developers, for all analyses using FieldTrip, we used an alternate multi-step implementation allowing us to extract epochs after the raw data had been filtered."</span></div><div class=""><span style="color:rgb(29,28,29);font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif;font-size:15px;font-variant-ligatures:common-ligatures;background-color:rgb(248,248,248)" class=""><br class=""></span></div><div class="">Looking through the code of ft_preprocessing and how the preproc function is used in my own preprocessing pipeline i realized that I seem to do the filtering on raw data epochs with this code:<span style="color:rgb(29,28,29);font-family:Slack-Lato,Slack-Fractions,appleLogo,sans-serif;font-size:15px;font-variant-ligatures:common-ligatures;background-color:rgb(248,248,248)" class=""><br class=""></span></div><div class=""><br class=""></div><div class=""><div class="gmail-rtcContent" style="padding:30px"><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre" class="">cfg = [];</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre" class="">cfg.continuous =<span style="color:rgb(167,9,245)" class="">'yes'</span>;</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre" class="">cfg.trialfun = <span style="color:rgb(167,9,245)" class="">'ft_trialfun_general'</span>;</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre" class="">cfg.trialdef.eventtype = <span style="color:rgb(167,9,245)" class="">'STATUS'</span>;</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre" class="">cfg.trialdef.eventvalue = {1,2,3,4}; <span style="color:rgb(0,128,19)" class="">% Trigger values</span></span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre" class="">cfg.trialdef.prestim =.5; <span style="color:rgb(0,128,19)" class="">% -500 ms before the stimulation</span></span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre" class="">cfg.trialdef.poststim = 2; <span style="color:rgb(0,128,19)" class="">% +2000ms after the stimulation</span></span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre" class="">cfg.dataset = path_to_dataset; <span style="color:rgb(0,128,19)" class="">% set the name of the dataset</span></span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre" class="">cfg = ft_definetrial(cfg); <span style="color:rgb(0,128,19)" class="">% read the list of the specific stimulus</span></span>cfg.hpfilter<span style="white-space:pre;font-size:10pt" class=""> = </span><span style="white-space:pre;font-size:10pt;color:rgb(167,9,245)" class="">'yes';</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="white-space:pre;font-size:10pt" class="">cfg.hpfreq = 1;</span><span style="font-size:10pt;white-space:pre" class="">[data] =ft_preprocessing(cfg);</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="font-size:10pt;white-space:pre" class=""><br class=""></span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small" class="">I did however think that the code above would apply the high pass filter on the continuous data and not on the epochs but it seems that I was wrong. Or am I? So I'm now consulting the E-mail list to get some clarity about this and a potential recommendation on what to do instead. Basically, how to implement the "multi-step implementation" within Fieldtrip.</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small" class=""><br class=""></span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small" class="">Thank you for providing the Fieldtrip toolbox</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small" class="">Best</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small" class="">Frans</span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small" class=""><br class=""></span></div><div class="gmail-lineNode" style="font-size:10pt;font-family:Menlo,Monaco,Consolas,"Courier New",monospace"><span style="font-family:Arial,Helvetica,sans-serif;font-size:small" class="">[1] </span><span style="font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:16px" class="">Delorme, A. EEG is better left alone. </span><i style="box-sizing:inherit;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:16px" class="">Sci Rep</i><span style="font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:16px" class=""> </span><span style="font-weight:bolder;box-sizing:inherit;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:16px" class="">13</span><span style="font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:16px" class="">, 2372 (2023). <a href="https://urldefense.com/v3/__https://doi.org/10.1038/s41598-023-27528-0__;!!HJOPV4FYYWzcc1jazlU!4hjKg111dQ7s9-L3G_ddKy01SDzvgiEvo8gLx_R-WDx6Qxj6JJS0HuEwuUx1atexqoHmVc8kvd5ouM4p4smQ$" class="">https://doi.org/10.1038/s41598-023-27528-0</a></span></div></div></div></div>
_______________________________________________<br class="">fieldtrip mailing list<br class=""><a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class=""><a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_yF8KxqbQ9i7O04I1jY6rUBExCiDZCkq2juuIOst9PZY0BoNkNcN_XM_EdKi85VuqUKBBTFIkjVBq0cmPuL82C-wOg$">https://doi.org/10.1371/journal.pcbi.1002202</a><br class=""></div></blockquote></div><br class=""></div></body></html>