[Mne_analysis] cwt and visualization

JR KING jeanremi.king at gmail.com
Wed Jul 13 14:25:33 EDT 2016
Search archives:

Hi Nico,

You can check how to apply and plot time frequency analyses in this example:
http://martinos.org/mne/stable/auto_examples/time_frequency/plot_time_frequency_simulated.html

The main function boils down to:

import numpy as np
from mne.time_frequency import tfr_morlet
freqs = np.linspace(5, 45, 20)  # an array of floats
power = tfr_morlet(epochs, freqs=freqs, n_cycles=5, return_itc=False)
power.plot([0])


If you wish to use arrays directly, instead of mne `Epochs` objects as
above, you can indeed use cwt_morlet:

import numpy as np
import matplotlib.pyplot as plt
from mne.time_frequency import cwt_morlet
n_signal, n_time = 10, 10000
X = np.random.rand(n_signal, n_time)
tfr = cwt_morlet(X, sfreq=1000, freqs = np.linspace(5, 45, 20), decim=10)
power = np.abs(tfr)
channel = 5
plt.matshow(power[channel], origin='lower', cmap='viridis', aspect='auto')
plt.show()

Hope that helps,

Best,

Jean-Rémi


On 13 July 2016 at 13:36, Nico Adelhöfer <nico.adelhoefer at st.ovgu.de> wrote:

> Hello,
>
> I'm new to this mailing list and to MNE. I think so far it is really great!
>
> I have a few questions concerning the usage of the cwt_morlet
> function; I want to plot a continuous wavelet transform from a single
> EEG channel. I have a raw multi-channel .fif file, approximately 300s
> long with a sampling frequency of 512 Hz. I'm interested in a
> frequency range of approximately 0-45 Hz. How can I achieve this in
> the simplest way possible? Specifically,
>
> 1. what datatype is the first parameter (X)? I tried the variable from
> read_raw_fif, but that gives me "'tuple' object has no attribute
> 'shape'". I also tried raw[4][0], which seems to work. But is this
> really the correct approach?
> 2. is freqs simply a list of integers with the frequencies of
> interest? If the length is > 1, I get a Value Error ("Maximum allowed
> size exceeded"). Does this mean I have to resample my raw data until
> it works?
> 3. when it worked, it created an np.ndarray with numbers with complex
> parts. Do I see it correctly that the complex parts show the phase
> while the real part shows the power value?
> 4. how can I visualize the result?
>
> Sorry for these basic questions. Help would be much appreciated!
>
> Nico
>
> _______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
>
>
> The information in this e-mail is intended only for the person to whom it
> is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160713/30b37ed3/attachment-0001.html 


More information about the Mne_analysis mailing list