[FieldTrip] automatic artifact rejection based on voltage threshold

Ivaylo Iotchev ivaylo.iotchev at gmail.com
Thu May 25 16:50:28 CEST 2023


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
>
>    1. 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
>
>
>    1. 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!8X0kphJff_7BqOs3VUJZHHgkGXvuM2fuw3Mc2xdJUx_owXx2Zb6tA-C8K7PjUdkw8qMnYbIgWKOvN5qCo8h0Nw_prsHVVw$ 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230525/9878c3d5/attachment.htm>


More information about the fieldtrip mailing list