[Mne_analysis] cwt and visualization

Nico Adelhöfer nico.adelhoefer at st.ovgu.de
Fri Jul 15 14:28:17 EDT 2016
Search archives:

Thank you. And sorry for this question, my bad.

Nico




Quoting JR KING <jeanremi.king at gmail.com>:

> This is a matplotlib issue not an MNE one.
>
> Look for the 'extent' parameter in plt.imshow or plt.matshow(), and set the
> ticks with axis.set_xticks() axis.set_ticklabels()
>
> HTH
>
> JR
>
> On 15 July 2016 at 14:04, Nico Adelhöfer <nico.adelhoefer at st.ovgu.de> wrote:
>
>> Hello Jean-Rémi,
>>
>> thanks a lot! The code for cwt_morlet you provided worked. However,
>> the y-axis labeling doesn't show the frequencies but the position of
>> the analyzed frequency in the array. For example:
>>
>> when freqs = [0, 20, 60], then the y-axis will be labeled 0, 1, 2
>> instead of 0, 20, 60.
>>
>> Is there a way around it? While at this issue, the x-axis shows
>> seconds*sfreq, but I'd like to be labeled as seconds.
>>
>> In other words: Is there a way to change the axis labeling without
>> changing the content?
>>
>> I hope you can help me with this one.
>>
>> Thanks,
>> Nico
>>
>>
>>
>> Quoting JR KING <jeanremi.king at gmail.com>:
>>
>> > 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.
>> >>
>> >>
>>
>>
>>
>> _______________________________________________
>> 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