[FieldTrip] filtering continuous vs. time-locked data

Vadim Axelrod axel.vadim at gmail.com
Sun Apr 10 22:13:04 CEST 2022


Dear fieldrip forum,

First, as someone originally from Ukraine it was heartwarming for me to see
your yellow-blue logo. Thank you.

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):
https://www.fieldtriptoolbox.org/workshop/baci2017/preprocessing/
https://www.fieldtriptoolbox.org/workshop/oslo2019/introduction/

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.

Thank you for the help.
Vadim

function FilterTimeLockedData(fileName, condNameArr)

    cfg                    = [];
    cfg.trialdef.prestim   = 0.5;% in seconds
    cfg.trialdef.poststim  = 1; %in seconds
    cfg.trialdef.eventtype = condNameArr;
    cfg.dataset            = fileName;
    cfg_tr_def             = ft_definetrial(cfg);

    cfg                    = [];
    cfg.dataset            = fileName;
    data_continous         = ft_preprocessing(cfg); % read raw data

    data                   = ft_redefinetrial(cfg_tr_def, data_continous);

    cfg                = [];
    cfg.hpfilter       = 'yes';        % enable high-pass filtering
    cfg.lpfilter       = 'yes';        % enable low-pass filtering
    cfg.hpfreq         = 0.2;           % set up the frequency for
high-pass filter
    cfg.lpfreq         = 30;          % set up the frequency for low-pass
filter

    data               = ft_preprocessing(cfg,data);

  function FilterContinousData(fileName, condNameArr)

    cfg                    = [];
    cfg.trialdef.prestim   = 0.5;% in seconds
    cfg.trialdef.poststim  = 1; %in seconds
    cfg.trialdef.eventtype = condNameArr;
    cfg.dataset            = fileName;
    cfg_tr_def             = ft_definetrial(cfg);

    cfg                    = [];
    cfg.dataset            = fileName;
    cfg.hpfilter           = 'yes';        % enable high-pass filtering
    cfg.lpfilter           = 'yes';        % enable low-pass filtering
    cfg.hpfreq             = 0.2;           % set up the frequency for
high-pass filter
    cfg.lpfreq             = 30;          % set up the frequency for
low-pass filter
    data_continous         = ft_preprocessing(cfg); % read raw data

    data                   = ft_redefinetrial(cfg_tr_def, data_continous);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220410/15e9f18b/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filtering_comparison.jpg
Type: image/jpeg
Size: 115514 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220410/15e9f18b/attachment.jpg>


More information about the fieldtrip mailing list