[FieldTrip] automatic artifact rejection based on voltage threshold

eleonora parrotta eleonora_p at hotmail.it
Thu May 25 15:44:57 CEST 2023


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230525/3c700ed1/attachment.htm>


More information about the fieldtrip mailing list