[FieldTrip] automatic artifact rejection based on voltage threshold

Arnaud Delorme arnodelorme at gmail.com
Thu May 25 20:31:49 CEST 2023


Dear Eleonora,

Look up this repository for automated artifact rejection in FieldTrip and EEGLAB (and MNE and Brainstorm as well).

https://urldefense.com/v3/__https://github.com/sccn/eeg_pipelines__;!!HJOPV4FYYWzcc1jazlU!5sfv_OhNHLSLY_BgkHGi7RqlIPu6iW2Y9PhPyQOnQhX9R8U_g880eftaTZkjRcK8xmc5HpZ2Kw99tTbMjJPMNYrFpA$ 

Arno

> On May 25, 2023, at 4:11 AM, eleonora parrotta via fieldtrip <fieldtrip at science.ru.nl> wrote:
> 
> That would be awesome, Dr. Ivaylo!
> I've been trying to implement it for weeks!
> Thank you so much for any help
> 
> Eleonora 
> 
> 
> Eleonora Parrotta,  Doctoral Researcher in Social Neuroscience 
> School of Psychology | University of Aberdeen | Aberdeen | AB24 3FX
> e.parrotta.20 at abdn.ac.uk
> 
> Da: Ivaylo Iotchev <ivaylo.iotchev at gmail.com>
> Inviato: giovedì 25 maggio 2023 14:50
> A: FieldTrip discussion list <fieldtrip at science.ru.nl>
> Cc: eleonora parrotta <eleonora_p at hotmail.it>
> Oggetto: Re: [FieldTrip] automatic artifact rejection based on voltage threshold
>  
> Hey Eleonora,
> 
> I might be able to send you some lines tomorrow which implement thresholding, these lines do not make direct use of FieldTrip I think, but they are MATLAB intern and thus can be coordinated within a script that uses Fieldtrip functions, too (basically that's what we are doing at the moment).
> 
> Best wishes,
> 
> (Dr.) Ivaylo (Ivo) Iotchev
> 
> Am Do., 25. Mai 2023 um 15:45 Uhr schrieb eleonora parrotta via fieldtrip <fieldtrip at science.ru.nl>:
> Dear Fieldtrippers,
> I am trying to implement an automatic artifact rejection on epoched data. 
> The aim of this process would be to compare the same dataset, analyzed both in fieldtrip and eeglab. To do so, I would need to efficiently implement the same EEGLAB parameters used for the artifact rejection in fieldtrip. 
> I have two options
> 	• eliminate the trials based on a peak-to-peak artifact rejection, which detects and remove trials in which the EEG signal exceeds of a threshold of 100 microvolt
> 	• eliminate the trials based on simple threshold voltage, that is, eliminate trials in which the voltage exceeds of +- 50 microvolts.
> Both options would be fine as both are implemented in eeglab, but I do not manage to implement neither of the two into fieldtrip.
>  I've tried to use both ft_artifact_threshold and ft_rejectartifact, even by combining the two.
> 
> ft_rejectartifact is not able not detect artifacts in the data, the output is always :
> 
> %artifact rejection
> cfg = [];
> cfg.artfctdef.channel = [1:28 31:65];
> cfg.artfctdef.threshold.min = -50;
> cfg.artfctdef.threshold.max = 50;
> cfg.artfctdef.prestim = -0.1;
> cfg.artfctdef.poststim = 0.6;
> cfg.artfctdef.window = 'trial';
> data_clean = ft_rejectartifact(cfg, clean_data);
> 
> the call to "ft_preprocessing" took 111 seconds
> rejected   0 trials completely
> rejected   0 trials partially
> filled parts of   0 trials with NaNs
> filled parts of   0 trials with zeros
> filled parts of   0 trials with a specified value 
> 
> 
> This is an example of what I get when using the functions together..
> 
> cfg = [];
> cfg.continuous = 'no';
> cfg.artfctdef.channel = {'all', '-ECG1', '-ECG2', '-IO'};
> cfg.dataset =clean_data.trial(:,:);
> % cfg.artfctdef.threshold.min = -50;
> % cfg.artfctdef.threshold.max = 50;
> % cfg.artfctdef.threshold.range=100;
> cfg.artfctdef.prestim = -0.1;
> cfg.artfctdef.poststim = 0.6;
> cfg.trl=trl;
> [~, artData] = ft_artifact_threshold(cfg, clean_data);
> 
> cfg = [];
> cfg.artfctdef.xxx.artifact = artData;
> cfg.artfctdef.reject = 'complete';
> fnData = ft_rejectartifact(cfg, clean_data);
> 
> The output seems to not be able to read the trials information, as it does not mark the trials but only segments in which there are artifacts: 
> searching for artifacts in 65 channels
> applying preprocessing options
> searching in trial 643 from 643
> detected 7172 artifacts
> the call to "ft_artifact_threshold" took 25 seconds
> >>
> cfg = [];
> cfg.artfctdef.xxx.artifact = artData;
> cfg.artfctdef.reject = 'complete';
> fnData = ft_rejectartifact(cfg, clean_data);
> detected   1 xxx artifacts
> Index in position 2 exceeds array bounds. Index must not exceed 1.
> 
> Error in ft_rejectartifact (line 305)
>     endsample = artifact{i}(:,2);
> 
> Please help me!!
> Any support is appreciated 
> Thank you very much 
> Eleonora Parrotta,  Doctoral Researcher in Social Neuroscience 
> School of Psychology | University of Aberdeen | Aberdeen | AB24 3FX
> e.parrotta.20 at abdn.ac.uk
> 
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!5sfv_OhNHLSLY_BgkHGi7RqlIPu6iW2Y9PhPyQOnQhX9R8U_g880eftaTZkjRcK8xmc5HpZ2Kw99tTbMjJNonGx1HA$ 
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!5sfv_OhNHLSLY_BgkHGi7RqlIPu6iW2Y9PhPyQOnQhX9R8U_g880eftaTZkjRcK8xmc5HpZ2Kw99tTbMjJNonGx1HA$ 




More information about the fieldtrip mailing list