[Mne_analysis] [mne-python] tfr_morlet to return single epochs

Mads Jensen mje.mads at gmail.com
Sat Aug 30 15:31:38 EDT 2014
Search archives:

Hi Alex,

thanks for the update and fix (I'm using the git version)

best,
mads


On 30/08/14 11:52, Alexandre Gramfort wrote:
> Hi Mads,
>
> there was 2 problems:
>
> - epochs[0] was a bad epoch so you need to preload epochs or call
> epochs.drop_bad_epochs() to make sure epochs[0] is good.
>
> - a bug in mne-python I just fixed
> https://github.com/mne-tools/mne-python/pull/1543
>
> I will be in our bug fix release of 0.8 in the next few weeks. You can
> also use current development version.
>
> thanks for the bug report
>
> Alex
>
> On Fri, Aug 29, 2014 at 8:25 PM, Mads Jensen <mje.mads at gmail.com> wrote:
>> hi Alex,
>>
>> thanks for the reply. I afraid cannot make it work, I get the following
>> error:
>>
>> Traceback (most recent call last):
>>
>>     File "<ipython-input-9-1e05100b604d>", line 30, in <module>
>>       return_itc=True, decim=3, n_jobs=1)
>>
>>     File
>> "/home/mje/Toolboxes/anaconda/lib/python2.7/site-packages/mne-0.9.git-py2.7.egg/mne/time_frequency/tfr.py",
>> line 892, in tfr_morlet
>>       data = data[:, picks, :]
>>
>> IndexError: too many indice
>>
>>
>> I just used to the code from the example
>> "time_frequency/plot_time_frequency_sensors.py" and changed the:
>> power, itc = tfr_morlet(epochs, freqs=freqs, n_cycles=n_cycles,
>> use_fft=False,
>> to:
>> power, itc = tfr_morlet(epochs[0], freqs=freqs, n_cycles=n_cycles,
>> use_fft=False,
>>                           return_itc=True, decim=3, n_jobs=1)
>>              return_itc=True, decim=3, n_jobs=1)
>>
>> the full code is below,
>>
>> any thoughts?
>> best regards,
>> mads
>>
>> ***
>> import numpy as np
>> import mne
>> from mne import io
>> from mne.time_frequency import tfr_morlet
>> from mne.datasets import somato
>>
>> ###############################################################################
>> # Set parameters
>> data_path = somato.data_path()
>> raw_fname = data_path + '/MEG/somato/sef_raw_sss.fif'
>> event_id, tmin, tmax = 1, -1., 3.
>>
>> # Setup for reading the raw data
>> raw = io.Raw(raw_fname)
>> baseline = (None, 0)
>> events = mne.find_events(raw, stim_channel='STI 014')
>>
>> # picks MEG gradiometers
>> picks = mne.pick_types(raw.info, meg='grad', eeg=False, eog=True,
>> stim=False)
>>
>> epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
>>                       baseline=baseline, reject=dict(grad=4000e-13,
>> eog=350e-6))
>>
>> ###############################################################################
>> # Calculate power and intertrial coherence
>>
>> freqs = np.arange(6, 30, 3)  # define frequencies of interest
>> n_cycles = freqs / 2.  # different number of cycle per frequency
>> power, itc = tfr_morlet(epochs[0], freqs=freqs, n_cycles=n_cycles,
>> use_fft=False,
>>                           return_itc=True, decim=3, n_jobs=1)
>> ***
>>
>>
>> On 29/08/14 18:32, Alexandre Gramfort wrote:
>>> hi Mads,
>>>
>>> yes you can. Just call tfr_morlet on epochs[k] to compute it on one epochs.
>>>
>>> You can index epochs like arrays with MNE-Python
>>>
>>> Alex
>>>
>>>
>>>
>>> On Fri, Aug 29, 2014 at 1:41 PM, Mads Jensen <mje.mads at gmail.com> wrote:
>>>> Dear mne-list,
>>>>
>>>> I would like to make a morlet wavelet on single epochs but as I
>>>> understand the tfr_morlet, it returns the average power for all the
>>>> epochs. If this is correct is there a way to make tfr_morlet return the
>>>> single epochs or is there another function that can?
>>>>
>>>> thanks,
>>>> mads
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>
>> _______________________________________________
>> Mne_analysis mailing list
>> Mne_analysis at nmr.mgh.harvard.edu
>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis
> _______________________________________________
> 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