[Mne_analysis] Defining Epochs according to event order

Dan McCloy dan at mccloy.info
Fri Jan 29 20:55:38 EST 2021
Search archives:

        External Email - Use Caution        

I don't think there's an easy / built-in way to do this in MNE-Python. Do the 3 events always occur in a predictable order? If so, I would write a function that takes in the original event array, finds occurrences of the "middle" event, looks before and after for the other events, and uses the sample numbers (in the first column of the events array) to determine how long before/after the middle event the epoch needs to be in order to include all 3. Then look across all epochs and pick the minimum "before time" and maximum "after time" to yield an epoch duration that is guaranteed to include all 3 events for *all* epochs (add some extra "padding" time if you want to prevent the events from ending up at the edges of the epoch). With those 2 numbers in hand as your `tmin` and `tmax`, you can epoch around the middle event and be sure that you'll always have the earlier and later event included.

-- dan
Daniel McCloy
https://secure-web.cisco.com/1xy7_y1owFF9BI53hSPaCLPo6J9PCFvaQUJmvdW9O5AOH83rcGU6LNaZOQgGCCAc6v851U8FXMKiBDJNvKUV3FZu_QxHLOwsWjBaNodv-BX8uwMkGxY3KcPppdckrXuX3OJfXfZnamINvF3pth8kC1NJNRHnO_67KvY-GpJJkzySMWoG6PSDvU7RMwQxzUiO78TeIM5yi_ExQ00I5yLosQxA7th0EWQ6lYaIVNZFtPBRPRKmNmiOjlaZ9iS1zJ_SWtRw4t6OO1WkBCtM0pU6FTA/https%3A%2F%2Fdan.mccloy.info
Research Scientist
Institute for Learning and Brain Sciences
University of Washington

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, January 28, 2021 7:21 PM, Bruno Mansur <brunommansur at gmail.com> wrote:

> External Email - Use Caution
>
> Dear list members,
>
> I have the following event dictionary:
>
> event_dict = {
>
> 'False'
>
> :
>
> 1
>
> ,
>
> 'Hit'
>
> :
>
> 2
>
> ,
>
> 'MP1'
>
> :
>
> 3
>
> ,
>
> 'MP2'
>
> :
>
> 4
>
> ,
>
> 'MP3'
>
> :
>
> 5
>
> ,
>
> 'M_False'
>
> :
>
> 6
>
> ,
>
> 'M_Hit'
>
> :
>
> 7
>
> ,
>
> 'OGT'
>
> :
>
> 8
>
> ,
>
> 'PMC'
>
> :
>
> 9
>
> ,
>
> 'S  4'
>
> :
>
> 10
>
> ,
>
> 'actiCAP Data On'
>
> :
>
> 11
>
> ,
>
> 'boundary'
>
> :
>
> 12
>
> }
>
> and I want to create epochs that contain three events (‘Hit’: 2, '‘M_Hit’: 7, ‘OGT’: 8). All three events should be contained in the same Epoch.
>
> So I first epoch my data passing the entire event_dict:
>
> epochs = mne.Epochs(raw_bandpass_ica, events, event_id=event_dict,
>                     tmin=
>
> -0.2
>
> , tmax=
>
> 6
>
> , reject=reject_criteria, preload=
>
> True
>
> )
>
> And then, in order to create my desired epoch, I tried this:
>
> OGT = mne.pick_events(events, include=[
>
> 8
>
> ,
>
> 2
>
> ,
>
> 7
>
> ])
> epochs[
>
> 'OGT'
>
> ].plot(events=OGT, event_id=event_dict,
>                    event_color=dict(OGT=
>
> 'red'
>
> , Hit=
>
> 'blue'
>
> , M_Hit=
>
> 'green'
>
> ))
>
> However, the output I got was Epochs containing some of the three events and not all at the same time.
>
> Do you know how could I define Epochs containing concomitant events?
>
> I would appreciate any help
>
> Best regards,
>
> Bruno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20210130/2735a7b5/attachment.html 


More information about the Mne_analysis mailing list