<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Dear Marieke and Jens,<div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">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: <a href="https://sccn.ucsd.edu/bugzilla/show_bug.cgi?id=1017" class="">https://sccn.ucsd.edu/bugzilla/show_bug.cgi?id=1017</a>).</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">Best,</div><div class="">Andreas</div><div class=""><br class=""><blockquote type="cite" class="">Am 29.01.2015 um 13:16 schrieb Jens Klinzing, Universität Tübingen <<a href="mailto:jens.klinzing@uni-tuebingen.de" class="">jens.klinzing@uni-tuebingen.de</a>>:<br class=""><br class="">Hi Marieke,<br class="">I had the impression that you are interested in the automatic low-pass filtering performed by ft_resampledata.<br class=""><br class="">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.<br class=""><br class=""><a href="http://mathworks.com/help/signal/ref/resample.html" class="">mathworks.com/help/signal/ref/resample.html</a><br class=""><br class="">"resample applies an anti-aliasing (lowpass) FIR filter to x during the resampling process. It designs the filter using firls with a Kaiser window."<br class=""><br class="">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.<br class=""><br class="">Can someone help?<br class=""><br class="">All the best,<br class="">Jens<br class=""><br class="">Am 23.01.2015 um 17:56 schrieb Schoffelen, J.M. (Jan Mathijs):<br class=""><blockquote type="cite" class="">Marieke,<br class="">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.<br class=""><br class="">JM<br class=""><br class=""><br class="">On Jan 23, 2015, at 2:39 PM, Eleanor Harding <harding@cbs.mpg.de> wrote:<br class=""><br class=""><blockquote type="cite" class="">Hi Marieke,<br class=""><br class="">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,<br class=""><br class="">Widmann, A., Schröger, E., & Maess, B. (in press). Digital filter design for electrophysiological data - a practical approach. Journal of Neuroscience Methods.<br class=""><br class="">Good luck,<br class="">Ellie Harding<br class=""><br class=""><br class=""><br class="">Message: 5<br class="">Date: Thu, 22 Jan 2015 16:50:26 +0000<br class="">From: "Nieuwenhuijzen, M.E. van de (Marieke)"<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><m.vandenieuwenhuijzen@donders.ru.nl><br class="">To: "fieldtrip@science.ru.nl" <fieldtrip@science.ru.nl><br class="">Subject: [FieldTrip] Low-pass frequency when downsampling using<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>ft_resampledata<br class="">Message-ID:<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><D270731257905445A56ECB1A4502301E395CEE@exprd04.hosting.ru.nl><br class="">Content-Type: text/plain; charset="iso-8859-1"<br class=""><br class="">Hi Fieldtrippers,<br class=""><br class="">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?<br class=""><br class="">Best,<br class="">Marieke<br class="">-------------- next part --------------<br class="">An HTML attachment was scrubbed...<br class="">URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150122/ce459100/attachment-0001.html><br class=""><br class=""><br class="">-- <br class="">------------------------------------------------------------------<br class="">Eleanor Harding<br class="">PhD Student<br class="">Max Planck Institute for Human Cognitive and Brain Sciences<br class="">Stephanstraße 1A, 04103 Leipzig, Germany<br class="">Phone: +49 341 9940-2268<br class="">Fax: +49 341 9940 2260<br class="">http://www.cbs.mpg.de/~harding<br class=""><br class=""><br class="">_______________________________________________<br class="">fieldtrip mailing list<br class="">fieldtrip@donders.ru.nl<br class="">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip<br class=""></blockquote><br class="">_______________________________________________<br class="">fieldtrip mailing list<br class="">fieldtrip@donders.ru.nl<br class="">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip<br class=""></blockquote><br class="">_______________________________________________<br class="">fieldtrip mailing list<br class="">fieldtrip@donders.ru.nl<br class="">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip<br class=""><br class=""></blockquote><img apple-inline="yes" id="96E162AD-453C-4F22-B8D2-7BA3E8748A2A" height="420" width="560" apple-width="yes" apple-height="yes" src="cid:FCDF00A9-E57E-4FEF-952D-46937B8CAEC7@Speedport_W723_V_Typ_A_1_01_009" class=""><img apple-inline="yes" id="144521D3-244A-42D1-B169-7C98A40EA5EB" height="420" width="560" apple-width="yes" apple-height="yes" src="cid:682279FE-5F86-42EA-AAD9-9075806B83BB@Speedport_W723_V_Typ_A_1_01_009" class=""></div></body></html>