[FieldTrip] High pass filtering before epoching

Frans Nord fnorden at gmail.com
Fri Feb 17 11:59:16 CET 2023


Thank you for sharing your code Julian. Looks like a good approach!

Also, thank you for sharing the preprocessing pipeline from your spring
school. Can I ask you what the motivation is behind doing the ICA before
the electrode interpolation?

Best,
Frans

On Wed, Feb 15, 2023 at 12:29 PM Julian Keil via fieldtrip <
fieldtrip at science.ru.nl> wrote:

> Hello Frans,
>
> 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 (
> https://urldefense.com/v3/__https://github.com/BioPsychKiel/SpringSchool2022/blob/main/track_02/01_Code/sc01_preproc.m__;!!HJOPV4FYYWzcc1jazlU!_aEDEsb7ydsax2OVHHDDpqnHPIUFI-6pcv8G6sYmsU4N6TNd5kEOITO2SHwH7dWoa0Pwsc2gfAKB6m5D9acS$ 
> <https://urldefense.com/v3/__https://github.com/BioPsychKiel/SpringSchool2022/blob/main/track_02/01_Code/sc01_preproc.m__;!!HJOPV4FYYWzcc1jazlU!_yF8KxqbQ9i7O04I1jY6rUBExCiDZCkq2juuIOst9PZY0BoNkNcN_XM_EdKi85VuqUKBBTFIkjVBq0cmPuLpKQN0Bg$>
> ):
>
> % 1.1. First, read in the header to define the trials
> cfg = []; % Always clear the configuration
> cfg.dataset = [inpath,indat(v).name]; % Set the dataset
> cfg.trialdef.eventtype = 'Markers'; % We now know that the trigger
> channel is called 'Stimulus'
> cfg.trialdef.eventvalue = {20,30}; % Define the relevant triggers
> cfg.trialdef.prestim = 1.5; % Seconds before the stimulus
> cfg.trialdef.poststim = 1.5; % Seconds after the stimulus
> cfg = ft_definetrial(cfg); % Store the trial definition
> % 1.2. Save the trial-definition
> trl = cfg.trl;
> % 1.3. Then define the entire dataset
> cfg = []; % Always clear the configuration
> cfg.dataset = [inpath,indat(v).name]; % Set the dataset
> cfg.trialdef.ntrials = 1; % One long trial to cover the entire dataset
> cfg = ft_definetrial(cfg); % Store the trial definition
> %% 2. Preprocessing
> % This step will read, filter and cut the raw data
> % 2.1. Read in the raw data and filter
> cfg.demean = 'yes'; % Remove mean across time to get rid of offset
> cfg.hpfilter = 'yes'; % Highpassfilter to remove slow drifts
> cfg.hpfreq = .1; % Highpass frequency. 0.1 removes most slow drifts
> cfg.hpfilttype = 'firws'; % Type of filter
> cfg.lpfilter = 'yes'; % The same for lowpass
> cfg.lpfreq = 45; % 50Hz line noise destroys the data, only take data below
> cfg.lpfilttype = 'firws'; % Again the type
> data_p = ft_preprocessing(cfg);
>
> % 2.2. Cut the data according to the trial definition
> cfg = [];
> cfg.trl = trl; % Use the trl-structure defined above
>
> data_t = ft_redefinetrial(cfg,data_p);
>
> Please not that this takes quite a bit longer than doing it the FT-way.
> I hope this helps,
>
> Julian
>
>
> Am 15.02.2023 um 11:33 schrieb Frans Nord via fieldtrip <
> fieldtrip at science.ru.nl>:
>
> Hello mailing-list,
>
> 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:
>
> "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."
>
> 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:
>
> cfg = [];
> cfg.continuous ='yes';
> cfg.trialfun = 'ft_trialfun_general';
> cfg.trialdef.eventtype = 'STATUS';
> cfg.trialdef.eventvalue = {1,2,3,4}; % Trigger values
> cfg.trialdef.prestim =.5; % -500 ms before the stimulation
> cfg.trialdef.poststim = 2; % +2000ms after the stimulation
> cfg.dataset = path_to_dataset; % set the name of the dataset
> cfg = ft_definetrial(cfg); % read the list of the specific stimulus
> cfg.hpfilter = 'yes';
> cfg.hpfreq = 1;[data] =ft_preprocessing(cfg);
>
> 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.
>
> Thank you for providing the Fieldtrip toolbox
> Best
> Frans
>
> [1] Delorme, A. EEG is better left alone. *Sci Rep* 13, 2372 (2023).
> https://urldefense.com/v3/__https://doi.org/10.1038/s41598-023-27528-0__;!!HJOPV4FYYWzcc1jazlU!_aEDEsb7ydsax2OVHHDDpqnHPIUFI-6pcv8G6sYmsU4N6TNd5kEOITO2SHwH7dWoa0Pwsc2gfAKB6pH1uGcr$ 
> <https://urldefense.com/v3/__https://doi.org/10.1038/s41598-023-27528-0__;!!HJOPV4FYYWzcc1jazlU!4hjKg111dQ7s9-L3G_ddKy01SDzvgiEvo8gLx_R-WDx6Qxj6JJS0HuEwuUx1atexqoHmVc8kvd5ouM4p4smQ$>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_aEDEsb7ydsax2OVHHDDpqnHPIUFI-6pcv8G6sYmsU4N6TNd5kEOITO2SHwH7dWoa0Pwsc2gfAKB6js7iloz$ 
> <https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_yF8KxqbQ9i7O04I1jY6rUBExCiDZCkq2juuIOst9PZY0BoNkNcN_XM_EdKi85VuqUKBBTFIkjVBq0cmPuL82C-wOg$>
>
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!_aEDEsb7ydsax2OVHHDDpqnHPIUFI-6pcv8G6sYmsU4N6TNd5kEOITO2SHwH7dWoa0Pwsc2gfAKB6js7iloz$ 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230217/0512a299/attachment.htm>


More information about the fieldtrip mailing list