[Mne_analysis] Badly resample signal_ Magnitude clipping

Phillip Alday phillip.alday at mpi.nl
Sat Sep 28 18:07:12 EDT 2019
Search archives:

        External Email - Use Caution        

Yes, this is expected behavior -- downsampling is not decimating.

When you discretely sample a continuous signal, you have your sample
frequency sf (e.g. 1000 Hz) and your sample duration, which is basically
assumed to be just 1/sf. There is no such thing as an instantaneous
sample. So when you resample you try to approximate what would have
happened had your original samples been bigger/slower. This is not the
same as just dropping all the samples in the intervening intervening
interval (which is also why resampling can take a little bit of time).

I think you've been assuming that you're resampling is like decimating.
In decimating, you do just drop all the intervening data points. Many
MNE objects support decimating. So if you want to go from an sf of 1000
Hz to 100Hz, then you decimate by a factor of 10, i.e. take only every
tenth sample. Note that this generally a bad idea because it's very
susceptible to aliasing and all sorts of other artefacts.

https://mne.tools/stable/overview/faq.html?highlight=faq#resampling-and-decimating-data

Best,

Phillip

On 23/08/2019 04:31, RODNEY PETRUS BALANDONG wrote:
>
> Dear Phillip,
>
>  
>
> I resampled a signal that originally sampled at 1000Hz to a different
> frequency (i.e., 1000Hz, 800Hz, 100Hz). The three figures that
> attached with this email showed different sampling rate results in
> different magnitude for the signal at the same time.
>
>  
>
> I understand from your explanation that this is expected where
> resampling will result in lose of temporal resolution, so fast, high
> amplitude deviations are lost. But I notice from my experimentation;
> the amplitude deviation occurs throughout the resampled signal.
> Because of this, I am concern whether I performed the whole procedure
> properly or not. FYI, I would like to resample the signal into 100Hz.
>
>  
>
> The figure can be reproduced using the notebook that accessible from
> this link
> <https://github.com/balandongiv/EyeCloseOpen/blob/master/HelpImportDownsample_EDF.ipynb>
>
>  
>
> Dear Sebastion
>
> Thanks for the reply. Yes, it is about Nyquist Theorem. Thanks for the
> explanation, I really appreciate it.
>
>  
>
>  
>
> Regards
>
> Rodney
>
>  
>
> *From:*Sebastián Castaño-Candamil
> <sebastian.castano at blbt.uni-freiburg.de>
> *Sent:* Thursday, 22 August, 2019 5:13 PM
> *To:* Discussion and support forum for the users of MNE Software
> <mne_analysis at nmr.mgh.harvard.edu>; RODNEY PETRUS BALANDONG
> <rodney.petrus_g03291 at utp.edu.my>
> *Cc:* Phillip Alday <phillip.alday at mpi.nl>;
> mne_analysis at nmr.mgh.harvard.edu
> *Subject:* Re: [Mne_analysis] Badly resample the signal
>
>  
>
> Hi Rodney,
>
>  
>
> there isn't a way around that, i.e., it is a theoretical limitation,
> (I dont know exactly your background, and apologize in advance in case
> you already know this, but:) you cannot represent frequency components
> wit a frequency > Fs/2, where Fs is your sampling frequency. In your
> case, you cannot analysis parts of the signal beyond 50Hz if you
> sample at 100
>
>  
>
> I do not know exactly what is the frequency of those fast variation,
> but I'd think that these are above 50ish Hz.
>
>  
>
> Hope that helps,
>
> Sebastián
>
>  
>
> *Sebastian Castaño-Candamil*
>
> Doctorate student
> Brain state decoding lab
> University of Freiburg
>
> E // sebastian.castano at blbt.uni-freiburg.de
> <mailto:sebastian.castano at blbt.uni-freiburg.de>
>
> On Aug 22 2019, at 10:59 am, RODNEY PETRUS BALANDONG
> <rodney.petrus_g03291 at utp.edu.my
> <mailto:rodney.petrus_g03291 at utp.edu.my>> wrote:
>
>      
>
>             External Email - Use Caution        
>
>      
>
>     I only interested with the signal up to 100Hz, so it redundant and
>     computationally expensive to handle signal with 1000Hz.
>
>      
>
>      
>
>      
>
>     I'm just curious whether ignoring those brief high-frequency peaks
>     will affect the overall analysis later.  So, if  there is a way to
>     these brief high-frequency would be an advantage.
>
>      
>
>      
>
>      
>
>     Anyhow, is it common practice to neglect the brief high-frequency
>     peaks?
>
>      
>
>      
>
>      
>
>     *From:* Phillip Alday <phillip.alday at mpi.nl
>     <mailto:phillip.alday at mpi.nl>>
>
>     *Sent:* Thursday, 22 August, 2019 4:53 PM
>
>     *To:* RODNEY PETRUS BALANDONG <rodney.petrus_g03291 at utp.edu.my
>     <mailto:rodney.petrus_g03291 at utp.edu.my>>
>
>     *Cc:* mne_analysis at nmr.mgh.harvard.edu
>     <mailto:mne_analysis at nmr.mgh.harvard.edu>
>
>     *Subject:* Re: [Mne_analysis] Badly resample signal
>
>      
>
>      
>
>     But why do you need to resample? That's what I meant with an XY
>     problem.
>
>      
>
>     Why do you care about brief high-frequency peaks?
>
>      
>
>     Phillip
>
>      
>
>     On 22/08/2019 11:46, RODNEY PETRUS BALANDONG wrote:
>
>         I need to downsample an original signal that sampled at 1000Hz
>         to 100Hz.
>
>          
>
>          
>
>          
>
>         *From:* Phillip Alday <phillip.alday at mpi.nl>
>         <mailto:phillip.alday at mpi.nl>
>
>         *Sent:* Thursday, 22 August, 2019 4:44 PM
>
>         *To:* RODNEY PETRUS BALANDONG
>         <rodney.petrus_g03291 at utp.edu.my>
>         <mailto:rodney.petrus_g03291 at utp.edu.my>
>
>         *Cc:* mne_analysis at nmr.mgh.harvard.edu
>         <mailto:mne_analysis at nmr.mgh.harvard.edu>
>
>         *Subject:* Re: [Mne_analysis] Badly resample signal
>
>          
>
>          
>
>         Appropriate filtering may help with some things, but .... I
>         think we're heading into XY question territory here
>         (http://xyproblem.info/).
>
>          
>
>         Why do you want to resample? What are you trying to accomplish?
>
>          
>
>         Phillip
>
>          
>
>         On 22/08/2019 11:38, RODNEY PETRUS BALANDONG wrote:
>
>             Dear Phillip,
>
>              
>
>              
>
>              
>
>             Thanks for the response,
>
>              
>
>              
>
>              
>
>             Just wonder whether there exist different technique to
>             address such an issue? For example, rather than using the
>             averaging approach
>
>              
>
>              
>
>              
>
>             Regards
>
>              
>
>             Rodney
>
>              
>
>              
>
>              
>
>             *From:* Phillip Alday <phillip.alday at mpi.nl>
>             <mailto:phillip.alday at mpi.nl>
>
>             *Sent:* Thursday, 22 August, 2019 4:33 PM
>
>             *To:* Discussion and support forum for the users of MNE
>             Software <mne_analysis at nmr.mgh.harvard.edu>
>             <mailto:mne_analysis at nmr.mgh.harvard.edu>; RODNEY PETRUS
>             BALANDONG <rodney.petrus_g03291 at utp.edu.my>
>             <mailto:rodney.petrus_g03291 at utp.edu.my>
>
>             *Subject:* Re: [Mne_analysis] Badly resample signal
>
>              
>
>              
>
>             This is expected behavior for resampling. With resampling,
>             you lose temporal resolution, so fast, high amplitude
>             deviations are lost.  This is what happens at the
>             beginning of your signal. Later in the signal you see that
>             the slower change in the mean of the signal is preserved,
>             but the bumps are list.
>
>              
>
>             Intuitively: you have fewer samples, so you can't capture
>             both the deviations up and the deviations down, so they
>             average out and you get just the mean. So the big peak and
>             big trough early in your example just cancel out when
>             resampled.
>
>              
>
>             Phillip
>
>              
>
>             On 22/08/2019 07:01, RODNEY PETRUS BALANDONG wrote:
>
>                 *        External Email - Use Caution        *
>
>                  
>
>                 Dear All,
>
>                  
>
>                  
>
>                  
>
>                 The issue is about sample badly approximated
>
>                  
>
>                  
>
>                  
>
>                 Given an original signal sampled at 100Hz, the
>                 objective was to downsampled it into 50 Hz
>
>                  
>
>                 The downsampling process was realised using the MNE
>                 resample.
>
>                  
>
>                  
>
>                  
>
>                 However, as can be noticed from the image below, the
>                 sample is badly approximated. Instead of registering
>                 the original signal magnitude, the function RESAMPLE
>                 return an approximated signal magnitude.
>
>                  
>
>                  
>
>                  
>
>                 This rise two question
>
>                  
>
>                  1. Is it common for such badly resample to occur?
>
>                  2. If yes, how to minimize this
>
>                  
>
>                  
>
>                 The problem can be reproduced using the notebook which
>                 is accessible through this link
>                 <https://github.com/balandongiv/EyeCloseOpen/blob/master/HelpImportDownsample_EDF.ipynb>.
>
>                  
>
>                  
>
>                  
>
>                 Thanks in advance for entertaining this request
>
>                  
>
>                  
>
>                  
>
>                  
>
>
>
>                  
>
>                  
>
>                  
>
>                  
>
>                 Regards
>
>                  
>
>                 Rodney
>
>                  
>
>                 DISCLAIMER : This e-mail and any files transmitted
>                 with it ("Message") is intended only for the use of
>                 the recipient(s) named above and may contain
>                 confidential information. You are hereby notified that
>                 the taking of any action in reliance upon, or any
>                 review, retransmission, dissemination, distribution,
>                 printing or copying of this Message or any part
>                 thereof by anyone other than the intended recipient(s)
>                 is strictly prohibited. If you have received this
>                 Message in error, you should delete this Message
>                 immediately and advise the sender by return e-mail.
>                 Opinions, conclusions and other information in this
>                 Message that do not relate to the official business of
>                 Universiti Teknologi PETRONAS (UTP) shall be
>                 understood as neither given nor endorsed by Universiti
>                 Teknologi PETRONAS (UTP).
>
>
>
>
>
>                 ||
>
>                 _______________________________________________
>
>                 Mne_analysis mailing list
>
>                 Mne_analysis at nmr.mgh.harvard.edu <mailto:Mne_analysis at nmr.mgh.harvard.edu>
>
>                 https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
>             DISCLAIMER : This e-mail and any files transmitted with it
>             ("Message") is intended only for the use of the
>             recipient(s) named above and may contain confidential
>             information. You are hereby notified that the taking of
>             any action in reliance upon, or any review,
>             retransmission, dissemination, distribution, printing or
>             copying of this Message or any part thereof by anyone
>             other than the intended recipient(s) is strictly
>             prohibited. If you have received this Message in error,
>             you should delete this Message immediately and advise the
>             sender by return e-mail. Opinions, conclusions and other
>             information in this Message that do not relate to the
>             official business of Universiti Teknologi PETRONAS (UTP)
>             shall be understood as neither given nor endorsed by
>             Universiti Teknologi PETRONAS (UTP).
>
>         DISCLAIMER : This e-mail and any files transmitted with it
>         ("Message") is intended only for the use of the recipient(s)
>         named above and may contain confidential information. You are
>         hereby notified that the taking of any action in reliance
>         upon, or any review, retransmission, dissemination,
>         distribution, printing or copying of this Message or any part
>         thereof by anyone other than the intended recipient(s) is
>         strictly prohibited. If you have received this Message in
>         error, you should delete this Message immediately and advise
>         the sender by return e-mail. Opinions, conclusions and other
>         information in this Message that do not relate to the official
>         business of Universiti Teknologi PETRONAS (UTP) shall be
>         understood as neither given nor endorsed by Universiti
>         Teknologi PETRONAS (UTP).
>
>     DISCLAIMER : This e-mail and any files transmitted with it
>     ("Message") is intended only for the use of the recipient(s) named
>     above and may contain confidential information. You are hereby
>     notified that the taking of any action in reliance upon, or any
>     review, retransmission, dissemination, distribution, printing or
>     copying of this Message or any part thereof by anyone other than
>     the intended recipient(s) is strictly prohibited. If you have
>     received this Message in error, you should delete this Message
>     immediately and advise the sender by return e-mail. Opinions,
>     conclusions and other information in this Message that do not
>     relate to the official business of Universiti Teknologi PETRONAS
>     (UTP) shall be understood as neither given nor endorsed by
>     Universiti Teknologi PETRONAS (UTP).
>     _______________________________________________
>
>     Mne_analysis mailing list
>
>     Mne_analysis at nmr.mgh.harvard.edu
>     <mailto:Mne_analysis at nmr.mgh.harvard.edu>
>
>     https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
> DISCLAIMER : This e-mail and any files transmitted with it ("Message")
> is intended only for the use of the recipient(s) named above and may
> contain confidential information. You are hereby notified that the
> taking of any action in reliance upon, or any review, retransmission,
> dissemination, distribution, printing or copying of this Message or
> any part thereof by anyone other than the intended recipient(s) is
> strictly prohibited. If you have received this Message in error, you
> should delete this Message immediately and advise the sender by return
> e-mail. Opinions, conclusions and other information in this Message
> that do not relate to the official business of Universiti Teknologi
> PETRONAS (UTP) shall be understood as neither given nor endorsed by
> Universiti Teknologi PETRONAS (UTP). 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190929/a072cc80/attachment-0001.html 


More information about the Mne_analysis mailing list