<div dir="ltr">Dear fieldrip forum,<div><br></div><div>First, as someone originally from Ukraine it was heartwarming for me to see your yellow-blue logo. Thank you.</div><div><br></div><div>I am confused with regard to the stage to filter the data of the ERP experiment (hpfilter and lpfilter). According to tutorials, the hpfilter and lpfilter are done at trials level (i.e., not for continuous data):</div><div><a href="https://www.fieldtriptoolbox.org/workshop/baci2017/preprocessing/">https://www.fieldtriptoolbox.org/workshop/baci2017/preprocessing/</a><br></div><div><a href="https://www.fieldtriptoolbox.org/workshop/oslo2019/introduction/">https://www.fieldtriptoolbox.org/workshop/oslo2019/introduction/</a><br></div><div><br></div><div>However, this clearly resulted in an artifact in my case. In the attached graph I compared this result to filtering at

the stage of continuous data  and just having a notch electricity line filter (without fieldtrip). For some reason neither bsfilter nor dftfilter work for me (this is a separate issue). Below is the code I used. I am using the fieldtrip version that I downloaded several weeks ago.</div><div><br></div><div>Thank you for the help.</div><div>Vadim</div><div><br></div><div>function FilterTimeLockedData(fileName, condNameArr)<br></div><div><br></div><div>    cfg                    = [];<br>    cfg.trialdef.prestim   = 0.5;% in seconds<br>    cfg.trialdef.poststim  = 1; %in seconds<br>    cfg.trialdef.eventtype = condNameArr;<br>    cfg.dataset            = fileName;           <br>    cfg_tr_def             = ft_definetrial(cfg);   <br><br>    cfg                    = [];<br>    cfg.dataset            = fileName;<br>    data_continous         = ft_preprocessing(cfg); % read raw data<br>      <br>    data                   = ft_redefinetrial(cfg_tr_def, data_continous);  <br>    <br>    cfg                = [];<br>    cfg.hpfilter       = 'yes';        % enable high-pass filtering<br>    cfg.lpfilter       = 'yes';        % enable low-pass filtering<br>    cfg.hpfreq         = 0.2;           % set up the frequency for high-pass filter<br>    cfg.lpfreq         = 30;          % set up the frequency for low-pass filter</div><div><br>    data               = ft_preprocessing(cfg,data); <br>        <br>  function FilterContinousData(fileName, condNameArr)<br><br>    cfg                    = [];<br>    cfg.trialdef.prestim   = 0.5;% in seconds<br>    cfg.trialdef.poststim  = 1; %in seconds<br>    cfg.trialdef.eventtype = condNameArr;<br>    cfg.dataset            = fileName;             <br>    cfg_tr_def             = ft_definetrial(cfg);   <br><br>    cfg                    = [];<br>    cfg.dataset            = fileName;<br>    cfg.hpfilter           = 'yes';        % enable high-pass filtering<br>    cfg.lpfilter           = 'yes';        % enable low-pass filtering<br>    cfg.hpfreq             = 0.2;           % set up the frequency for high-pass filter<br>    cfg.lpfreq             = 30;          % set up the frequency for low-pass filter<br>    data_continous         = ft_preprocessing(cfg); % read raw data<br>      <br>    data                   = ft_redefinetrial(cfg_tr_def, data_continous);  <br><br></div></div>