[FieldTrip] Low-pass frequency when downsampling using ft_resampledata (Nieuwenhuijzen, M.E. van de (Marieke))

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Thu Jan 29 19:37:20 CET 2015


Dear Andreas,

Note that ft_resampledata supports the options demean and detrend. Also, as of release 9829 FT always explicitly removes the epoch-wise DC-offset prior to resampling (and adds it back if cfg.demean is ‘no’), which means that users that are not aware of the potential problem are partly protected against strong DC offsets. Our recommendation is furthermore not to detrend, because this may distort slow event-related components in a non-trivial way. Also, it may falsely introduce experimental effects at unexpected time points, e.g. in the baseline.
If the user suspects that low-frequency energy in the signals may lead to funny edge behavior in the resampling step, I’d recommend either to highpassfilter the data prior to resampling, or to read in more data than needed, so that the edge effects end up in non-interesting parts of the data.
I think that a more aggressive lowpassfilter will be a useful option to build in.

Best,
Jan-Mathijs


On Jan 29, 2015, at 5:19 PM, Andreas Widmann <widmann at uni-leipzig.de<mailto:widmann at uni-leipzig.de>> wrote:

Dear Marieke and Jens,

MATLAB resample sets the -6dB half-amplitude cutoff of the anti-aliasing filter to the new Nyquist frequency. This is quite common practice, however, for EEG/MEG data this is not recommended, as the remaining energy in the transition band above the cutoff/new Nyquist frequency can still introduce considerable aliasing artifacts. So indeed the current Fieldtrip implementation is problematic. In the attached Fig. 1 a frequency response plot as it would be applied when downsampling from 500 to 250 Hz.

Even worse is that resample (and Fieldtrip) does not apply any padding of the signal before filtering (doc resample: "In its filtering process, resample assumes that the input sequence, x, is zero before and after the samples it is given. Thus, large deviations from zero at the endpoints of x can cause inaccuracies in y at its endpoints.“). This will introduce DC artifacts at the beginning and end of the data. In particular for epoched data this can result in quite massive distortions (see Fig. 2 in the attachment; filtered and downsampled series of ones; same filter as above; same problem as it was formerly observed in EEGLAB: https://sccn.ucsd.edu/bugzilla/show_bug.cgi?id=1017).

I suggest submitting a bug report (please put me into cc). I think I can fix both problems but this will take some days. I would recommend not using the current implementation.

Best,
Andreas

Am 29.01.2015 um 13:16 schrieb Jens Klinzing, Universität Tübingen <jens.klinzing at uni-tuebingen.de<mailto:jens.klinzing at uni-tuebingen.de>>:

Hi Marieke,
I had the impression that you are interested in the automatic low-pass filtering performed by ft_resampledata.

If you don't specify cfg.resamplemethod = 'downsample', ft_resampledata will call the built-in matlab function 'resample' to do the job. This function automatically applies a low-pass filter before resampling.

mathworks.com/help/signal/ref/resample.html<http://mathworks.com/help/signal/ref/resample.html>

"resample applies an anti-aliasing (lowpass) FIR filter to x during the resampling process. It designs the filter using firls with a Kaiser window."

I couldn't find an explicit statement what the cutoff frequency of that filter would be, though. There are some forum entries on the web, but they don't give the answer either.

Can someone help?

All the best,
Jens

Am 23.01.2015 um 17:56 schrieb Schoffelen, J.M. (Jan Mathijs):
Marieke,
Have you considered to generate a spectrum of your downsampled signal (up to Nyquist frequency) and check the low-pass cutoff there? I guess it will be easily visible.

JM


On Jan 23, 2015, at 2:39 PM, Eleanor Harding <harding at cbs.mpg.de<mailto:harding at cbs.mpg.de>> wrote:

Hi Marieke,

A rule of thumb for downsampling is to low-pass filter at 1/3 of your desired sampling rate, so, for you that would be 100 Hz. But of course you shouldn't make the filter cutoff too close to what you are looking for in your data. Below is a helpful publication,

Widmann, A., Schröger, E., & Maess, B. (in press). Digital filter design for electrophysiological data - a practical approach. Journal of Neuroscience Methods.

Good luck,
Ellie Harding



Message: 5
Date: Thu, 22 Jan 2015 16:50:26 +0000
From: "Nieuwenhuijzen, M.E. van de (Marieke)"
<m.vandenieuwenhuijzen at donders.ru.nl<mailto:m.vandenieuwenhuijzen at donders.ru.nl>>
To: "fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>" <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Subject: [FieldTrip] Low-pass frequency when downsampling using
ft_resampledata
Message-ID:
<D270731257905445A56ECB1A4502301E395CEE at exprd04.hosting.ru.nl<mailto:D270731257905445A56ECB1A4502301E395CEE at exprd04.hosting.ru.nl>>
Content-Type: text/plain; charset="iso-8859-1"

Hi Fieldtrippers,

I have a small question about ft_resampledata. I have ECoG data that was measured with a sampling frequency of 1000 Hz, which I downsample to 300 Hz. >From what I understand, to avoid aliasing, this function applies a low-pass filter to the data before downsampling. How can I determine what the low-pass frequency of that filter would be?

Best,
Marieke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150122/ce459100/attachment-0001.html>


--
------------------------------------------------------------------
Eleanor Harding
PhD Student
Max Planck Institute for Human Cognitive and Brain Sciences
Stephanstraße 1A, 04103 Leipzig, Germany
Phone: +49 341 9940-2268
Fax: +49 341 9940 2260
http://www.cbs.mpg.de/~harding


_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

<fig1_fresp.jpg><fig2_dcartifact.jpg>
_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150129/baa131bf/attachment-0002.html>


More information about the fieldtrip mailing list