[Mne_analysis] Time-frequency PSD with CWT (morlet wavelet) in a single trial

Denis A. Engemann denis.engemann at gmail.com
Wed Apr 23 12:17:45 EDT 2014
Search archives:

I was playing a bit with you example and got reasonable results with a clear 10 hz modulation using the  single trial tfr function.
I can share my edits later with you. Btw. why don't we meet at Neurospin at some point for lunch or a coffee --- maybe things are easier to tackle then.
For raw and epochs and evoked API take a look here:

http://martinos.org/mne/stable/auto_examples/plot_from_raw_to_epochs_to_evoked.html


Best,
Denis

> On Apr 23, 2014, at 4:58 PM, Arnaud Ferre <arnaud.ferre.pro at gmail.com> wrote:
> 
> Hi Denis,
> 
> 
> I have tested with single_trial_power() but I obtain exactly the same results that my use with _time_frequency(). Here is my code: https://gist.github.com/arnaudferre/11215335. I don’t understand what the problem is. With a sinusoid, I must have a band of high power around the fundamental frequency of the sinusoid, right?
> 
> 
> For the GUI, I don’t find documentation on the use with Windows. But ok, I must compile the sources with the makefile. It’s been a long time that I didn’t play with C! But I will try (I believe that I must download the software Make to begin). But in fact, I don’t know why I spoke of GUI, sorry. I think that I thought at a possibility to play with data directly with a GUI in the way that I want.
> 
> 
> I’m not sure to understand what you name “Raw object”. Is it the name of an existing object from MNE? But, with the knowledge of this object, I can write a function which return this directly. My problem is that I’m not an expert on the data and her format. But if it’s substantially a problem of parsing, I can step in the discussion.
> 
> 
> I read your link on the S-transform. Yes, it could be very interesting to test my data with this method. But I must already test older results from a study with Fourier Transform. In literature, the wavelet transform with morlet wavelet seems to be adequate to my project (Phase-Amplitude coupling then cross-frequency coupling). So, I want finish with this method to have my first result. But thank you, I keep it in a corner for later.
> 
> Best,
> Arnaud  
> 
> 
> 
> 2014-04-23 11:22 GMT+02:00 Denis-Alexander Engemann <denis.engemann at gmail.com>:
>> Hi Arnaud,
>> 
>> 
>>> On Wed, Apr 23, 2014 at 10:54 AM, Arnaud Ferre <arnaud.ferre.pro at gmail.com> wrote:
>>> Hi Denis,
>>> Thanks for the fast reply.
>>> 
>>> Yes I can share my test. Here: https://gist.github.com/arnaudferre/11206945.
>>> 
>> 
>> Thanks, will have a look later.
>>  
>>> Ok, I will try to use single_trial_power() function now.
>>> 
>>> For the GUI, unfortunately, I must develop a ‘biologists-friendly’ software. In consequence (and with others constraints), I must develop on Windows and the GUI doesn’t work on Windows if I have correctly understood.
>>> 
>> 
>> Which GUI? The MNE C GUI indeed compile on Windows. However, `mne.gui.coregistration` in Python is supposed to work on Windows.
>> 
>>  
>>> For my file format, I have already develop my own functions to parse the original data (my goal: adapt raw signal to can use just the useful data). This format can be ‘CED Spike2 SMR files’ or an alternative in TXT from Local Field Potential acquisition. So, I store the data of a single trial in a dictionary, then in a pickle file (maybe not a good idea…).
>>> 
>> 
>> I agree. I would strongly encourage you to write a custom constructor function that returns a Raw object from your data. We're happy assist you with that Also it would be a great test case for new tools we're about to develop that aim at making exactly this task easier. In fact I need to write a couple of functions very soon that allow me to read in data stored in Mat files. Sounds like that would follow the same logic. 
>>  
>>> I do this certainly with my personal way. For these reasons, I tried to adapt the MNE-Python script to read my data. It seems not far yet! But I don’t know if I can really add idea in your conversation due to these specific data.
>>> 
>> 
>> I think you can. See above. Also we're happy to add support to additional EEG / electrophysiology formats. 
>> 
>>> Anyway, it seems that MNE contains all the tools what we need here. It’s very encouraging yeah. But, I think we need time to know to use these tools.
>>> 
>>> Arnaud
>> 
>> FYI something I'm working on at the moment that might also be of interest to you:
>> 
>> https://github.com/mne-tools/mne-python/pull/1233
>> 
>> Best,
>> Denis
>>  
>>> 
>>> 
>>> 2014-04-19 12:34 GMT+02:00 Denis-Alexander Engemann <denis.engemann at gmail.com>:
>>> 
>>>> Hi Arno,
>>>> 
>>>> let my reply inline,
>>>> 
>>>>> On Fri, Apr 18, 2014 at 6:55 PM, Arnaud Ferre <arnaud.ferre.pro at gmail.com> wrote:
>>>>> Hi all,
>>>>> I work on EEG data in behavioral field. I understand the basics of signal processing and I’m not so bad in Python. But for a beginner like me, MNE-Python is pretty huge. I was advised to use MNE knowing my constraints, but I’m starting to think that it’s maybe too evolved for a non-expert scientist in this field like me.  
>>>>> 
>>>>> I’m just trying to draw a time-frequency PSD from a single trial with a CWT (with morlet wavelets). I thought to have found what functions used, but in testing my script, I don’t obtain correct result. 
>>>>> 
>>>>> 
>>>>> In fact, I tested with a simple sinusoid function with a frequency of 10Hz on 1sec (1000points). I expected to see a lot of "red blobs" aligned on the 10Hz in y-axis but not. I have a continuous and very thin band around 1.5 Hz and a residual band around the 90Hz. I looked the wavelets and it seems fine. What is strange is that I see the correct number of blob, so I think it’s not so far of correct result. In first, I thought of a problem in adjusting my display, but it seems not.
>>>>> 
>>>> 
>>>> Could you share an example script, e.g. using https://gist.github.com/
>>>> That would be very helpful.
>>>>  
>>>>> 
>>>>> I use mainly the function _time_frequency(data, Ws), one of the functions in tfr.py in mne.time_frequency where data is a 2D-array containing only my signal in data[0].
>>>>> 
>>>>> I read this link: http://martinos.org/mne/stable/auto_examples/stats/plot_cluster_1samp_test_time_frequency.html, but as I don’t use data with the standard format, it seemed to me complicated. Moreover, I think that _time_frequency(data, Ws) is just needed to do what I want. And yet, maybe that the specificities of the function single_trial_power in tfr.py is the solution…
>>>>> 
>>>>> 
>>>> 
>>>> In fact `single_trial_power` would be the way to go. (http://martinos.org/mne/dev/generated/mne.time_frequency.single_trial_power.html#mne.time_frequency.single_trial_power)
>>>> In general it's not recommended not use functions starting with underscores unless you know exactly what you do. Things are much easier once you use the top-level API. Is your file format that prevents you from doing this? What kind of EEG  data do you use? We're currently working on improving support for custom data: 
>>>> 
>>>> https://github.com/mne-tools/mne-python/issues/1229 
>>>> 
>>>> Please feel free to participate in the discussion on Github and tell us more about your use case.
>>>>  
>>>>> Thanks in advance
>>>>> Arnaud
>>>>> 
>>>>  
>>>> I hope we can encourage you to keep exploring the new terrain ;-)
>>>> 
>>>> Denis 
>>>> 
>>>>> _______________________________________________
>>>>> 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
>>>> 
>>>> 
>>>> 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
>>> 
>>> 
>>> 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
>> 
>> 
>> 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
> 
> 
> 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/20140423/0b0f2e97/attachment.html 


More information about the Mne_analysis mailing list