[FieldTrip] ft_artifact_threshold not operating properly after resampling data

Korzeczek, Alexandra alexandra.korzeczek at med.uni-goettingen.de
Mon Oct 15 12:55:43 CEST 2018


Dear all,

does anyone know if ft_resampledata is affecting EEG-data in an adverse manner?
I’m asking because I’m having a similar problem wich was already described by Alexandrina Guran on Mon Mar 27 11:34:19 CEST 2017 (subject: Problem with downsampling / automatic artifact rejection) and wanted to ask if a solution has been found why this problem appears?

The problem (black and bold) occurs while using the function ft_artifact_threshold:
Example:
Warning: the trial definition in the configuration is inconsistent with the actual data
Warning: reconstructing sampleinfo by assuming that the trials are consecutive segments of a
continuous recording
threshold artifact scanning: trial 1 from 74 exceeds min-threshold
threshold artifact scanning: trial 2 from 74 is ok
threshold artifact scanning: trial 3 from 74 is ok
threshold artifact scanning: trial 4 from 74 is ok
threshold artifact scanning: trial 5 from 74 exceeds min-threshold
threshold artifact scanning: trial 6 from 74 exceeds max-threshold
Warning: data contains NaNs, no filtering or preprocessing applied

I have backtracked why theses NANs occour, and it happens when ft_artifact_threshold (line 160) calls the function ft_fetch data. Within this function (line 167) the Matlab function unique is called. The Warning is posted when the variable utrl stays empty (line 169). Then in line 178 the data (variable dat), which until then are NANs, in the matrix data.trial are not converted into proper values.

167 - utrl = unique(trialnum);
168 -  utrl(~isfinite(utrl)) = 0;
169 -  utrl(utrl==0) = [];
170 -  if length(utrl)==1
171 -    ok   = trialnum==utrl;
172 -    smps = samplenum(ok);
173 -    dat(:,ok) = data.trial{utrl}(chanindx,smps);
174 -  else
175 -    for xlop=1:length(utrl)
176 -      ok   = trialnum==utrl(xlop);
177 -      smps = samplenum(ok);
178 -      dat(:,ok) = data.trial{utrl(xlop)}(chanindx,smps);
179 -    end
180 -  end

This problem is independent of my cfg configurations for ft_artifact threshold. However, as Alexandrina found out, it does not appear when I leave out my previous ft_resampledata step.
So my question is: Can anybody explain, why resampling my data is giving this effect? And additionally if it is save to use resampling anyway (other ft functions as databrowser or rejectvisual do not seem to be affected by this resampling step – but maybe I just don’t notice that?).

I’m using the EGI system with a 256 EEG cap.
Here are my current steps before I call ft_artifact_threshold:

Definetrial:
cfg = [];
cfg.dataformat = 'egi_mff_v2';  %uses the new format for egi files
cfg.headerformat = 'egi_mff_v2';
cfg.eventformat = 'egi_mff_v2';
cfg.continuous = 'yes';
cfg.trialfun =  'ft_trialfun_general';
cfg.trialdef.eventtype = DIN4;
cfg.trialdef.eventvalue = ''; % necessary for mff files.
cfg.trialdef.prestim = 1;
cfg.trialdef.poststim = 2,5;
EEG_trldef_S1= ft_definetrial(cfg)

2x times Selectdata:
cfg.trials = keep_trlinf;% specific rules for my experiment
EEG_trls= ft_selectdata(cfg, EEG_trldef_S1);

Preprocessing:
EEG_trls.padding = Pad;
EEG_trls.chantype = {'eeg'};
EEG_trls.channel=(1:257);
EEG_trls.detrend = 'yes';
EEG_trls.trials  = 'all';
EEG_trls.lpfilter ='yes';
EEG_trls.lpfreq = 60;
EEG_preproc_1000Hz = ft_preprocessing (EEG_trls);

Resample data
cfg.resamplefs = 500;
EEG_preproc = ft_resampledata(cfg, EEG_preproc_1000Hz);


The difference between the data output of ft_preprocessing and ft_resampledata is that the variable sampleinfo is missing after ft_resampledata (see attached picture). Maybe this is the reason why ft_artifact_threshold is not working properly?


I hope someone has an explanation? Thank you in advance,

Alexandra


_________________________________________________________________

Alexandra Korzeczek
Wissenschaftliche Mitarbeiterin
Klinik für Klinische Neurophysiologie
Georg-August-Universität Göttingen
Robert-Koch.Str. 40, 37075 Göttingen
Tel. 0551- 39-65106
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20181015/a1c7181a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Matrix_ft_resampledata.png
Type: image/png
Size: 22979 bytes
Desc: Matrix_ft_resampledata.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20181015/a1c7181a/attachment-0001.png>


More information about the fieldtrip mailing list