[Eeglablist] Resampling "artefacts" 512-500 Hz

Ziereis, Annika Carina annika.ziereis at uni-goettingen.de
Tue Jul 16 01:44:36 PDT 2019


Dear Andreas, 

thank you again for your time and effort spent on this topic! I imagine it to be very time consuming to track these kind of problems down. 
You helped me already with your suggestions to filter first before resampling (although I will try to avoid downsampling in future anyway and align my data streams differently). 
I am not sure whether it is a more general issue for Biosemi data (it would be interesting if this happens with other systems/data, too, but I can't test that). Another eeglab list member reported the same problem (also Biosemi) and your solution helped. 
 If this is the case it might be helpful to implement something like a warning /hint before resampling because it is not in the general pre-processing pipeline (at least not at this stage). 
 Maybe it is too specific, though. 

Thanks again! 
Best
Annika

-----Ursprüngliche Nachricht-----
Von: Andreas Widmann <widmann at uni-leipzig.de> 
Gesendet: Montag, 15. Juli 2019 15:35
An: Ziereis, Annika Carina <annika.ziereis at uni-goettingen.de>
Cc: eeglablist at sccn.ucsd.edu; Kulke, Louisa <louisa.kulke at psych.uni-goettingen.de>
Betreff: Re: [Eeglablist] Resampling "artefacts" 512-500 Hz

Hi Annika,

the problem is somewhere else than I initially expected (leakage effects when computing the spectrum due to strong DC offsets/drifts combined with default hamming window; hamming window is not ending with zero amplitude at the tails).

I could track down the problem to the MATLAB signal processing toolbox included resample function. Unfortunately, I think there is nothing we could do about that. Possibly, I will try to dig in the source code sometime later this year and report to Mathworks but I cannot promise. Using our own non-signal processing toolbox codepath in the EEGLAB pop_resample function (by hardcoding usesigproc = 0) applying piecewise polynomial interpolation does not show the problem. This is, however, an order of magnitude slower and might show other problems.

Anyway, by accident I already suggested a workaround that appears to solve the problem :) The MATLAB resample function appears to have problems with large DC offsets as occurring in Biosemi files. These should be removed anyway as they are not informative and potentially might reduce numerical precision in worst case (but orders of magnitude smaller than the effects you observed). In case of large drifts as also present in your sample data (for example plot channel 58 after import) removing the channel mean is not sufficient (as you noticed). In case of large drifts you also have to detrend the continuous data or better high-pass filter them to also remove local very slow drifts. A low cutoff (<= 0.1 Hz) as already used in your example code is sufficient and recommended.

Hope this helps! Best,
Andreas

> Am 15.07.2019 um 12:20 schrieb Ziereis, Annika Carina <annika.ziereis at uni-goettingen.de>:
> 
> Dear all,
> 
> I received some answers to my post about the artefacts after 
> downsampling from 512 to 500 Hz (see message below)- thank you for that! Especially to Andreas Widmann who suggested to remove the DC offset (remove baseline) and/or highpass filtering before resampling.
> Indeed, both methods reduced the artefacts so I am very thankful for that recommendation!
> 
> I'd still be interested what happens during resampling and produces these harmonic peaks - so if somebody has an explanation for it, I'd be more than happy to learn about it!
> In general it was recommended to avoid downsampling if not needed, especially for non- integer ratios (like I did).
> I provided examples (plots)  for three different datasets and different preprocessing steps:
> 
> -          Version 1: Resampling
> 
> -          Version 2: Removing the baseline and then resampling
> 
> -          Version 3: High-pass filtering and then resampling
> They can be found here (incl. script):
> https://github.com/aziereis/eegquestions/blob/master
> Additionally I provide one raw data file (03.bdf; size= 455 MB) here: 
> https://osf.io/4cn7j/
> 
> General information:
> EEG was recorded from 64 Electrodes (Biosemi). Signals were recorded 
> at a sampling rate of 512 Hz and a bandwidth of
> 102.4 Hz.  I rereferenced  to average reference.
> I did not start/stop the recording in between - so the whole time range of the experiment is recorded.
> 
> Thank you!
> Best
> Annika
> 
> 
> Von: Ziereis, Annika Carina
> Gesendet: Donnerstag, 4. Juli 2019 18:06
> An: 'eeglablist at sccn.ucsd.edu' <eeglablist at sccn.ucsd.edu>
> Betreff: Resampling "artefacts" 512-500 Hz
> 
> Dear all,
> 
> (I'd like to say beforehand that I am a total beginner in signal 
> processing... so if you have an idea why this happened I'd be very 
> happy if you'd consider it in your explanation)
> 
> For the EEG recording we use a sampling rate of 512 Hz which we want to down-sample to 500 Hz (we do simultaneous eye-tracking which records with 500 Hz and we want to do a co-registration).
> 
> During the pre-processing I looked at the power spectral density and found a power increase for the harmonics of 12 Hz (so peaks at 12, 24, 36 ... Hz) after resampling to 500 Hz. These peaks were not visible in the  power spectral density plot of the raw data.
> It was especially pronounced for participants with a higher alpha power  and not so much for those with low alpha power.
> I played with some resampling frequencies to check how it looks like for 499 Hz, 501 Hz 497 Hz... and 256 Hz (to compare to a integer ratio).
> The "artefacts" only occur  for 499, 500 and 501 Hz-showing each the 
> harmonics of the difference in Hz e.g. for 499 Hz (which would be 13Hz less than the original sampling rate) I get the harmonic peaks for 13, 26 and so on.
> It disappears for Frequencies that are not in the alpha range (e.g. 15 Hz, for resampling to 497 Hz).
> 
> Then I read that one could do low-pass filtering to avoid aliasing effects (which I have to admit- I don' t understand very well). So I tried to low-pass filtering of 40 Hz  (I just used 40 Hz because we did so in another study) and do the resampling again. This resulted in the same harmonics and super strange peaks in the filtered out frequencies.
> I uploaded a pdf with pictures here (hopefully, it makes it more clear 
> what I mean): 
> https://github.com/aziereis/eegquestions/blob/master/downsampling.pdf
> 
> 
> Has anybody encountered this problem before?
> Is this artefact problematic?
> Thank you very much for your help!!
> 
> Best
> Annika
> 
> 
> 
> ---
> Annika Carina Ziereis
> 
> Georg-Elias-Müller Institute for Psychology
> - Affective Neuroscience and Psychophysiology - University Göttingen 
> Goßlerstr. 14
> 37073 Göttingen
> 
> Phone +49 551 39 20623
> 
> Email: 
> annika.ziereis at uni-goettingen.de<mailto:annika.ziereis at uni-goettingen.
> de>
> 
> 
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to 
> eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to 
> eeglablist-request at sccn.ucsd.edu
> 



More information about the eeglablist mailing list