[Mne_analysis] n_fft option for tfr_array_stockwell {Disarmed}

Alexandre Gramfort alexandre.gramfort at inria.fr
Mon Dec 21 09:42:03 EST 2020
Search archives:

        External Email - Use Caution        

hi,

here are the lines that generate this behavior.

https://secure-web.cisco.com/19bmNMoYnXLOkU_iFnakp_XeteNEgsBBxfAGwS0rF2CpZNdLrEeQ2Q7gkaBm6CPlzSZf0ojCFXZ9hmC1DsZAEgb0US11kbgMbsLoCOjXYEOf-NN97XCe29r1vUCh20gEOZLm2BIVUjGq3PJnp4npGEOWbrB5lG3fytl7LKURPdRZnu695xfBaNgSLPXjQqDRJ6MW6-NU8lSF9eSsZErLm6Xs_wM9LU9iGRhhtFMZfRgwj_W4Z4Ug6Ds8xnaQsostgCuEzh10kChT37jmHmXJKlQ/https%3A%2F%2Fgithub.com%2Fmne-tools%2Fmne-python%2Fblob%2Fmaster%2Fmne%2Ftime_frequency%2F_stockwell.py%23L26

I read that "n_fft cannot be smaller than signal size".

maybe simply the doc needs to be updated?

HTH
Alex


On Sun, Dec 20, 2020 at 6:32 PM Paul Fishback <fishbacp at mail.gvsu.edu>
wrote:

>         External Email - Use Caution
>
> Alex,
>
> I'm so sorry I left that out. Here's a snippet that includes that info as
> well as plots the results. I set n_fft=500, but still received the warning,
> RuntimeWarning: The input signal is shorter (5001) than "n_fft" (8192).
> Applying zero padding..
>
> import numpy as np
> from scipy.signal import chirp
> import matplotlib.pyplot as plt
> from mne.time_frequency import tfr_array_stockwell
>
> Nt=5000
> time_length=10
>
> t = np.linspace(0, time_length, Nt+1)
> w = chirp(t, f0=12.5, f1=2.5, t1=10, method='linear')
> y = np.expand_dims(w, axis=[0,1])
>
> fmin = 0  # Hz
> fmax = 25  # Hz
> Fs = int(np.ceil(Nt/time_length))
>
> st_power, itc,
> freqs=tfr_array_stockwell(y,sfreq=Fs,fmin=fmin,fmax=fmax,n_fft=500)
>
> extent = (t[0], t[-1], fmin, fmax)
> fig, ax = plt.subplots(2, 1, sharex=True)
> ax[0].plot(t, w)
> ax[0].set(ylabel='amplitude')
> ax[1].imshow(np.abs(st_power[0,:,:]), origin='lower', extent=extent)
> ax[1].axis('tight')
> ax[1].set(xlabel='time (s)', ylabel='frequency (Hz)')
> plt.show()
>
> On Sun, Dec 20, 2020 at 12:06 PM Alexandre Gramfort <
> alexandre.gramfort at inria.fr> wrote:
>
>>         External Email - Use Caution
>>
>> hi Paul,
>>
>> can you share a full code snippet?
>>
>> Nt  and time_length not defined
>>
>> Alex
>>
>>
>> On Sat, Dec 19, 2020 at 9:42 PM Paul Fishback <fishbacp at mail.gvsu.edu>
>> wrote:
>>
>>>         External Email - Use Caution
>>>
>>> Hello,
>>>
>>> I'm interested in computing the Stockwell Transform of a simple
>>> univariate time series. Because I already use MNE, I thought I'd
>>> perform this task with the aid of the
>>> tfr_array_stockwell command. However, I'm having a problem changing the
>>> window length, n_fft.
>>>
>>> As a simple "toy example," here's a chirp signal, where the frequency
>>> decreases linearly from 12.5 to 2.5 Hz over a 10 second period:
>>>
>>> from scipy.signal import chirp
>>> from mne.time_frequency import tfr_array_stockwell
>>>
>>> t = np.linspace(0, 10, 5001)
>>> w = chirp(t, f0=12.5, f1=2.5, t1=10, method='linear')
>>> y = np.expand_dims(w, axis=[0,1])  # Add dimensions to signal in order
>>> to make a valid input for tfr_array_stockwell
>>>
>>> fmin = 0
>>> fmax = 25
>>> Fs = int(np.ceil(Nt/time_length))
>>> st_power, itc, freqs=tfr_array_stockwell(y,sfreq=Fs,fmin=fmin,fmax=fmax)
>>>
>>> This works fine and the plotted results look great, but I do receive a
>>> warning message indicating zero padding is being used. This is because the
>>> signal length (5001)
>>> is less than the default n_fft, which is 8192 in my case.   (Since
>>> 2^(12)=4096 < 5001 < 2^(13)=8192 )
>>>
>>> However, if I change the default n_fft to something else, e.g. insert
>>> n_fft=500 above, I still receive the same warning message.
>>>
>>> Perhaps I'm missing something simple?
>>>
>>> Thanks
>>>
>>> Paul Fishback
>>> --
>>> Professor of Mathematics, Grand Valley State University
>>> Past-President, Pi Mu Epsilon National Honorary Mathematics Society, Inc.
>>>
>>> Department of Mathematics (MAK C-2-408)
>>> Grand Valley State University
>>> 1 Campus Dr.
>>> Allendale, MI 49401
>>> fishbacp at mail.gvsu.edu
>>> 616.331.2040
>>> 616.331.3120 (fax)
>>> _______________________________________________
>>> Mne_analysis mailing list
>>> Mne_analysis at nmr.mgh.harvard.edu
>>> *MailScanner has detected a possible fraud attempt from
>>> "secure-web.cisco.com" claiming to be*
>>> https://secure-web.cisco.com/1V2HoZGdNLp0IFtAYTXTEdVFL6qTpGgJRm2OCrOWu-BPKeW0GOZYTT50BA5CqqaLL4F7Cia6pZ1bgXjpEBbPf4tQcDUwPRFmQ4SO76LkQweDD5ZEX6rWY--QfBPCCK2oKkxrMznXqgSplhMudB93vKc_c1flqMbs5HYUoQlnqldVFc9weJ4urtRK4Jv-1lKttxMvCWdmSfTdYS5kYG3y7QI_RsxsiBBzL28XDuNDaMaRP8qaIuEpabwfeoA7Qspj65b9UzXKBiPlHdjeSGHbgWA/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis
>>> <https://secure-web.cisco.com/1M4CbzTtCaJem1lx1U0buS9f1c2izKtbTjVFnrbjB0yPGi90XuU1Z5zbH7fAswJDcFljz4nDFhhWdKbqEcuR5SoCem1UyfXaKE-shx-JV4-lWrS1HL6eh8opMdufAMu0eO3z895xxr9vmgvNQClV-Rsi0DHYSf5fpW22GZbfJLPXPzfJjpHZB0JXycCZwjO4lHoIoqa-TwctE2IbhjzWXmpQZpxM2Yq3Ur1j_cifW1UHMNXxoIbVqgFtXv07-6Nd2_shMG3tHtbjFhbzfyYuLxA/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis>
>>
>> _______________________________________________
>> Mne_analysis mailing list
>> Mne_analysis at nmr.mgh.harvard.edu
>> *MailScanner has detected a possible fraud attempt from
>> "secure-web.cisco.com" claiming to be*
>> https://secure-web.cisco.com/1V2HoZGdNLp0IFtAYTXTEdVFL6qTpGgJRm2OCrOWu-BPKeW0GOZYTT50BA5CqqaLL4F7Cia6pZ1bgXjpEBbPf4tQcDUwPRFmQ4SO76LkQweDD5ZEX6rWY--QfBPCCK2oKkxrMznXqgSplhMudB93vKc_c1flqMbs5HYUoQlnqldVFc9weJ4urtRK4Jv-1lKttxMvCWdmSfTdYS5kYG3y7QI_RsxsiBBzL28XDuNDaMaRP8qaIuEpabwfeoA7Qspj65b9UzXKBiPlHdjeSGHbgWA/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis
>> <https://secure-web.cisco.com/1ctCQ2zsYnftewzKaPfkHy8euSz0Z_C9qeWYG9Vwvew04AcXo9LLpUkkieMGqt1MCu4FTZbv3dDBHdWMVCUYTWPRazAgJVP7pTD1ohCnZATpUNE83BYx3f3sX5WnGVrIDidqjndItRhUBtzXxKVVqghi8ZBZv2VbeKb3z5tCxIOCXBxM2qI_dyxZm9CP08QmgRXVcLePiwX8MPWmFP_bb024AGt5RxjY9LRXWVmEec350uCGrnjOr4MfyAHK5n0O3LC9isssbFfny5JO6oFwchA/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis>
>
>
>
> --
> Professor of Mathematics, Grand Valley State University
> Past-President, Pi Mu Epsilon National Honorary Mathematics Society, Inc.
>
> Department of Mathematics (MAK C-2-408)
> Grand Valley State University
> 1 Campus Dr.
> Allendale, MI 49401
> fishbacp at mail.gvsu.edu
> 616.331.2040
> 616.331.3120 (fax)
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://secure-web.cisco.com/1V2HoZGdNLp0IFtAYTXTEdVFL6qTpGgJRm2OCrOWu-BPKeW0GOZYTT50BA5CqqaLL4F7Cia6pZ1bgXjpEBbPf4tQcDUwPRFmQ4SO76LkQweDD5ZEX6rWY--QfBPCCK2oKkxrMznXqgSplhMudB93vKc_c1flqMbs5HYUoQlnqldVFc9weJ4urtRK4Jv-1lKttxMvCWdmSfTdYS5kYG3y7QI_RsxsiBBzL28XDuNDaMaRP8qaIuEpabwfeoA7Qspj65b9UzXKBiPlHdjeSGHbgWA/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Fmne_analysis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20201221/d7abf8cf/attachment-0001.html 


More information about the Mne_analysis mailing list