[Eeglablist] Resampling "artefacts" 512-500 Hz
Andreas Widmann
widmann at uni-leipzig.de
Mon Jul 15 06:35:07 PDT 2019
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