[FieldTrip] Problem with downsampling / automatic artifact rejection
Alexandrina Guran
alexandrina.guran at uni-luebeck.de
Mon Mar 27 11:34:19 CEST 2017
Dear FieldTrip Community,
My name is Alexandrina Guran, I am a PhD Student at the University of Lübeck and I have recently started working with FieldTrip in order to preprocess (and later analyse) EEG data. I have encountered an odd problem, that I nor people I asked in the lab could solve, also using the help function and google:
After running the epoching (trial length 5s), filtering (high-pass, low-pass and notch, for a time-frequency analysis) and downsampling (to 250 Hz), I wanted to do an automatic artifact rejection, in order to have exploratory information of how many of my trials would be affected by artifacts and if there were participants that blinked on a majority of trials in order to determine whether I should shorten my trial length and/or conduct an ICA.
I used the ft_artifact_threshold function, in Matlab R2016b, with different FieldTrip versions (march 2017 as well as end 2016 and end 2015).
However, the automatic artifact detection did not work – that is, it would stop rejecting artifacts after a number x of trials (usually between 90 and 140 trials), depending on participant. I would get an error message but then the artifact rejection would go on, telling me all trials were ok (even if I set 1 microvolt as a threshold).
The error message I got is the following:
“(…) threshold artifact scanning: trial 128 from 320 exceeds max-threshold
threshold artifact scanning: trial 129 from 320 is ok
threshold artifact scanning: trial 130 from 320 is ok
threshold artifact scanning: trial 131 from 320 is ok
Warning: data contains NaNs, no filtering or preprocessing applied
> In ft_warning (line 184)
In preproc (line 283)
In ft_artifact_threshold (line 164)
In preprocessing (line 266)
threshold artifact scanning: trial 132 from 320 is ok
threshold artifact scanning: trial 133 from 320 is ok
threshold artifact scanning: trial 134 from 320 is ok
threshold artifact scanning: trial 135 from 320 is ok
threshold artifact scanning: trial 136 from 320 is ok
threshold artifact scanning: trial 137 from 320 is ok
threshold artifact scanning: trial 138 from 320 is ok
threshold artifact scanning: trial 139 from 320 is ok
threshold artifact scanning: trial 140 from 320 is ok
threshold artifact scanning: trial 141 from 320 is ok
threshold artifact scanning: trial 142 from 320 is ok (…)”
This was however only the case if I ran the artifact detection on down-sampled data. It worked fine with just filtered data.
However, I checked the preprocessed (downsampled) data for NaNs (using the isnan-MATLAB function) and there were none to be found (I also checked visually in one dataset).
Has anyone encountered this problem and found a solution?
Of course, I considered just doing the downsampling after the automatic and visual artifact rejection, but I would like to be sure that the downsampling will work correctly at any point of the preprocessing and right now I am a little flummoxed at “what is happening” with the data in that function.
Down below you can find code excerpts for both the artifact rejection and the downsampling. Both were looped over participants but the error appears regardless of that.
Downsampling:
cfg = [];
cfg.dataset = ['tfdata_filtfilt_' num2str(subj(s)) '.mat']; %tfdata_filtfilt_ is the epoched and filtered data
cfg.resamplefs = 250;
cfg.detrend = 'no';
cfg.inputfile = ['tfdata_filtfilt_' num2str(subj(s)) '.mat'];
cfg.outputfile = ['tfdata_filt_rs_' num2str(subj(s)) '.mat'];
datatfrs = ft_resampledata(cfg)
Artifact rejection
cfg = [];
config = load(['tfcfg_' num2str(subj(s)) '.mat']);
cfg.trl = config.cfg.trl;
cfg.continuous = 'no' ;
cfg.artfctdef.threshold.channel = [1:28 33:63]; %exclude eye channels 'VEOG1' 'VEOG2' 'HEOG1' 'HEOG2'
cfg.artfctdef.threshold.max = 75;
cfg.artfctdef.threshold.min = -75;
cfg.artfctdef.threshold.bpfilter = 'no';
cfg.inputfile = ['tfdata_filt_rs_' num2str(subj(s)) '.mat'];
cfg.outputfile = ['tfdata_artif_' num2str(subj(s)) '.mat'];
cfg = ft_artifact_threshold(cfg);
save (cfg.outputfile, 'cfg')
Since I am new to FieldTrip, I can imagine it to be a “simple/stupid” error having to do with the cfg.
Thank you for reading this and trying to help ☺
Best regards
Alexandrina
--
C.-N. Alexandrina Guran, M.Sc.
PhD student
Institute of Psychology I
University of Lübeck
Maria-Goeppert-Straße 9a
23562 Lübeck
Germany
Building MFC 8, 1st Floor, Room 1
Phone: +49 451 3101 3635
Fax: +49 451 3101 3604
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170327/ec4f433c/attachment-0001.html>
More information about the fieldtrip
mailing list