[Mne_analysis] n_fft option for tfr_array_stockwell {Disarmed}

Paul Fishback fishbacp at mail.gvsu.edu
Sun Dec 20 12:30:04 EST 2020
Search archives:

        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/1ctCQ2zsYnftewzKaPfkHy8euSz0Z_C9qeWYG9Vwvew04AcXo9LLpUkkieMGqt1MCu4FTZbv3dDBHdWMVCUYTWPRazAgJVP7pTD1ohCnZATpUNE83BYx3f3sX5WnGVrIDidqjndItRhUBtzXxKVVqghi8ZBZv2VbeKb3z5tCxIOCXBxM2qI_dyxZm9CP08QmgRXVcLePiwX8MPWmFP_bb024AGt5RxjY9LRXWVmEec350uCGrnjOr4MfyAHK5n0O3LC9isssbFfny5JO6oFwchA/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
> 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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20201220/d425af53/attachment-0001.html 


More information about the Mne_analysis mailing list