[Mne_analysis] merge/combine events MNE Python

Cushing, Cody CCUSHING1 at mgh.harvard.edu
Thu Mar 17 10:57:09 EDT 2016
Search archives:

Ah, thank you!
________________________________
From: mne_analysis-bounces at nmr.mgh.harvard.edu [mne_analysis-bounces at nmr.mgh.harvard.edu] on behalf of Teon Brooks [teon.brooks at gmail.com]
Sent: Thursday, March 17, 2016 10:54 AM
To: Discussion and support forum for the users of MNE Software
Subject: Re: [Mne_analysis] merge/combine events MNE Python

Sorry I followed up directly but forgot to relay it back here. I made pull request to fix this behavior. If you would like to follow along the process, you can do so here: https://github.com/mne-tools/mne-python/pull/3015
On Thu, Mar 17, 2016 at 10:50 Cushing, Cody <CCUSHING1 at mgh.harvard.edu<mailto:CCUSHING1 at mgh.harvard.edu>> wrote:
Hi all,

Was any resolution ever found on this?  I'm now experiencing the same thing where trying to multiple merge_events before epoching results in an obscene amount of trial counts per condition (e.g. my condition 1 nave goes from 69 > 228), so I believe my problem to identical to Lucy's below.  Thanks for any help or input.

Cheers,
Cody
________________________________
From: mne_analysis-bounces at nmr.mgh.harvard.edu<mailto:mne_analysis-bounces at nmr.mgh.harvard.edu> [mne_analysis-bounces at nmr.mgh.harvard.edu<mailto:mne_analysis-bounces at nmr.mgh.harvard.edu>] on behalf of Teon Brooks [teon.brooks at gmail.com<mailto:teon.brooks at gmail.com>]
Sent: Wednesday, February 24, 2016 8:00 PM

To: Discussion and support forum for the users of MNE Software
Subject: Re: [Mne_analysis] merge/combine events MNE Python
Could you send directly me the code you used and a sample file to reproduce this problem? From what I read, I can't reproduce it with the sample data.
On Thu, Feb 18, 2016 at 11:51 Lucy MacGregor <Lucy.MacGregor at mrc-cbu.cam.ac.uk<mailto:Lucy.MacGregor at mrc-cbu.cam.ac.uk>> wrote:
Hi Teon,

Thank you. Your suggestion is what I’d originally hoped to do but I would like *multiple* new combinations (e.g., condE(11,12) *and* condF(13,14)) and I couldn’t figure out how I could use the function to do this to create a list of the events.

Initially I did:
events=mne.event.merge_events(events, [11,12], 1112, replace_events=False)
events=mne.event.merge_events(events, [13,14], 1314 replace_events=False)
In doing mne.event.merge_events the second time, at a given sample point the original and new event codes are repeated twice (event codes not included in recombinations are repeated 4 times).

Best,
Lucy

From: mne_analysis-bounces at nmr.mgh.harvard.edu<mailto:mne_analysis-bounces at nmr.mgh.harvard.edu> [mailto:mne_analysis-bounces at nmr.mgh.harvard.edu<mailto:mne_analysis-bounces at nmr.mgh.harvard.edu>] On Behalf Of Teon Brooks
Sent: 18 February 2016 16:11

To: Discussion and support forum for the users of MNE Software
Subject: Re: [Mne_analysis] merge/combine events MNE Python

Hi Lucy,

This might help, there's a argument with merge_events named 'replace_events' that allows you to retain the original values when set to False. In your example, you could combine 11 and 12 and assign to a value like 99. In your event_id dict, you could then assign CondE to 99.

HTH,

On Thu, Feb 18, 2016 at 09:52 Lucy MacGregor <Lucy.MacGregor at mrc-cbu.cam.ac.uk<mailto:Lucy.MacGregor at mrc-cbu.cam.ac.uk>> wrote:
Dear Natalie,

Thank you for the suggestion. My understanding of mne.epochs.combine_event_ids is that it replaces the original events with new ones whereas I would like to retain the original events which is why I initially tried mne.event.merge_events.

I can now do what I want to do using Mainak’s suggestion to use the hierarchical feature of epoch selection. I created multiple evoked files corresponding to my various event combinations then saved the combinations into one file using mne.write_evokeds.


Thank you both!

Best,

Lucy


From: mne_analysis-bounces at nmr.mgh.harvard.edu<mailto:mne_analysis-bounces at nmr.mgh.harvard.edu> [mailto:mne_analysis-bounces at nmr.mgh.harvard.edu<mailto:mne_analysis-bounces at nmr.mgh.harvard.edu>] On Behalf Of Natalie Klein
Sent: 18 February 2016 13:02

To: Discussion and support forum for the users of MNE Software
Subject: Re: [Mne_analysis] merge/combine events MNE Python

Dear Lucy,

Maybe I misunderstand what you are trying to do, but it seems like mne.epochs.combine_event_ids might be helpful. I'm not sure what you mean about saving them all into one file but you could define new event ids to combine epochs across conditions then create evoked files from those.

On Thu, Feb 18, 2016 at 7:45 AM, Lucy MacGregor <Lucy.MacGregor at mrc-cbu.cam.ac.uk<mailto:Lucy.MacGregor at mrc-cbu.cam.ac.uk>> wrote:
Dear Mainak,

Many thanks for the reply and the pointer. This seems helpful to access different combinations of the events, but is it then possible to create multiple new epoch objects (condE and condF) which can be then saved together in a single evoked file along with the originals? Ideally I would have the event/condition averages for all conditions (new and old) in one file.

Best,

Lucy

From: mne_analysis-bounces at nmr.mgh.harvard.edu<mailto:mne_analysis-bounces at nmr.mgh.harvard.edu> [mailto:mne_analysis-bounces at nmr.mgh.harvard.edu<mailto:mne_analysis-bounces at nmr.mgh.harvard.edu>] On Behalf Of Mainak Jas
Sent: 18 February 2016 10:22
To: Discussion and support forum for the users of MNE Software
Subject: Re: [Mne_analysis] merge/combine events MNE Python

Dear Lucy,
It seems what you want to do is to use the hierarchical epochs selection. If you have an epochs object which contains condA, condB, condC and condD, you can get epochs of condE by simply using epochs['condA', 'condB']. Please take a look at the MNE reference API for the epochs object: http://martinos.org/mne/stable/generated/mne.Epochs.html#mne.Epochs (look at the Notes section). Does this solve your problem?
Best regards,
Mainak

On Thu, Feb 18, 2016 at 10:27 AM, Lucy MacGregor <Lucy.MacGregor at mrc-cbu.cam.ac.uk<mailto:Lucy.MacGregor at mrc-cbu.cam.ac.uk>> wrote:
Dear MNE Python users,


I would like to combine event codes to create a number of new events whilst retaining the originals. E.g.,

CondA = 11
CondB = 12
CondC = 13
CondD = 14
CondE = 11,12
CondF = 13,14


Is there a straightforward way to do this? I have seen this thread

https://mail.nmr.mgh.harvard.edu/pipermail//mne_analysis/2013-April/001498.html<https://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/2013-April/001498.html>


Using mne.event.merge_events works fine when I was just creating one new event (as does the alternative method of combining events at the evoked stage) but I’m unsure of the most sensible way to proceed given I want to create multiple new events. I originally did this:

events=mne.event.merge_events(events, [11,12], 1112, replace_events=False)
events=mne.event.merge_events(events, [13,14], 1314 replace_events=False)

but then, because I’m not replacing events, I end up with multiple copies of all events (even those not included in the merge_events function)  at a given sample point, which isn’t ideal.

As a new MNE Python user (I previously used MNE) I would be grateful for any advice as the best way to do this.


Thank you,

Lucy MacGregor


******************************************************************
Lucy MacGregor
MRC Cognition and Brain Sciences Unit
15 Chaucer Road
Cambridge CB2 7EF
Tel: 01223 355294 Ext 860
http://www.mrc-cbu.cam.ac.uk/people/lucy.macgregor/


This e-mail may have a protective marking.  For an explanation please see
http://www.mrc.ac.uk/About/Informationandstandards/Documentmarking/index.htm


_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu<mailto: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<mailto: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<mailto: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.
--
teon
--
Envoyé de mon iPhone
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu<mailto: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.
--
teon
--
Envoyé de mon iPhone
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu<mailto: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.
--
teon
--
Envoyé de mon iPhone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160317/5f25ff38/attachment-0001.html 


More information about the Mne_analysis mailing list