[Mne_analysis] Why does MNE resample method does not sample the data point to point?

Phillip Alday phillip.alday at mpi.nl
Thu Jul 23 09:09:44 EDT 2020
Search archives:

        External Email - Use Caution        

I think the up- vs. downsampling distinction is also really important
for expectations here, as is the distinction between decimating and
resampling (I recall there was a thread about that a few years back with
similar confusion, if somebody wants to do the effort of searching for it)

Phillip

On 23/7/20 2:57 pm, Brunner, Clemens (clemens.brunner at uni-graz.at) wrote:
>         External Email - Use Caution        
>
> Also note that the resample example (https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.resample.html) shows upsampling, i.e. the data has a lower sampling rate than the resampled result. However, in the case of downsampling it is usually necessary to avoid aliasing of frequencies above the resampled Nyquist frequency. Therefore, the signal is typically low-pass filtered before the resampling step. As Eric mentioned, this anti-aliasing filter is what actually changes the signal values, but it is necessary to avoid aliasing artifacts.
>
> AFAIK, scipy.signal.resample doesn't include an anti-aliasing filter, but both scipy.signal.resample_poly as well as scipy.signal.decimate apply such a low-pass filter before resampling. That's also what MNE does.
>
> Clemens
>
>
>> On 23.07.2020, at 14:40, Eric Larson <larson.eric.d at gmail.com> wrote:
>>
>>         External Email - Use Caution        
>>
>>
>> My understanding of downsampling is that it is an operation to decrease the sample rate of x by keeping the first sample and then every nth sample after the first.
>>
>> Resampling typically consists of two steps: low-pass filtering to avoid aliasing, then sample rate reduction (subselecting samples from the resulting signal). The low-passing actually changes the values, so the subselection-of-filtered-data step will not necessarily yield points that were "on" the original signal.
>>  
>> May I know whether this issue is due to the ringing artifacts or due to other problems?
>>
>> In this case it's likely due to the (implicit) low-pass filtering in the frequency-domain resampling of the signal. It looks pretty reasonable to me. If you want to play around with it a bit, you can
>>
>> 1. Call scipy.signal.resample directly on your data and see how closely it matches.
>> 2. Pad your signal, call scipy.signal.resample, and remove the (now reduced-length) padding -- this is what MNE does internally.
>> 3. Use scipy.signal.resample_poly directly on your data.
>> 4. Manually low-pass filter and then directly subselect samples from the low-passed signal, which is what resample_poly does internally.
>>
>> Hopefully these all give similar results for your signal(s).
>>
>> Eric
>>
>> _______________________________________________
>> Mne_analysis mailing list
>> Mne_analysis at nmr.mgh.harvard.edu
>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis



More information about the Mne_analysis mailing list