[Mne_analysis] help with mne.event.define_target_events

Jaakko Leppakangas jaeilepp at gmail.com
Wed Feb 8 01:59:38 EST 2017
Search archives:

Hi,

numpy.concatenate should do what you want.

import numpy as np
fixed_events = list()
for key, value in event_id.items():
     events_tmp, lag_tmp = mne.event.define_target_events(events,
sound_onset, value, raw.info['sfreq'], code_tmin, code_tmax,
new_id=new_event_id[key], fill_na=None)
     fixed_events.append(events_tmp)
fixed_events = np.concatenate(fixed_events)

The order shouldn't matter, but that can also be done:

order = np.argsort(fixed_events[:, 0])
fixed_events = fixed_events[order]

Hope this helps.

-Jaakko


On Tue, Feb 7, 2017 at 11:31 PM, Aaron Newman <Aaron.Newman at dal.ca> wrote:

> Hi all
>
> We're running a study using auditory stimuli. The latency between the
> trigger code and actual auditory onset is rather long and somewhat
> variable, so we have a device that sends a '1' trigger when the sound is
> actually played. Thus in our event log file we have the unique trigger
> codes for each condition, followed ~100 ms later by the 1 that marks the
> actual stimulus event. I would like to recode each '1' according to the
> condition code that preceded it.
>
> Thus far, I have the following:
>
> # trigger codes in the event log (note there are actually 32 unique
> entries in the dict; have shortened here for brevity)
> event_id = {'Match/Det/F/con':10, 'Match/N/F/con':30,
> 'Match/Det/M/con':20, 'Match/N/M/con':40}
>
> # new trigger codes to replace the 1s
> new_event_id = {'Match/Det/F/con':110, 'Match/N/F/con':130,
> 'Match/Det/M/con':120, 'Match/N/M/con':140}
>
> raw = mne.io.read_raw_eeglab(raw_fname, eog=eog_inds, event_id=event_id,
> preload=True)
>
> events = mne.find_events(raw, stim_channel='STI 014')
> code_tmin = -.15
> code_tmax = -.01
> sound_onset = 1  # code for actual sound onset
>
> for key, value in event_id.items():
>      events_tmp, lag_tmp = mne.event.define_target_events(events,
> sound_onset, value, raw.info['sfreq'], code_tmin, code_tmax,
> new_id=new_event_id[key], fill_na=None)
>
>
> ...where I'm stuck is figuring out how to either modify the original
> "events" array to replace the 1s with the new codes after eery call to
> define_target_events in the loop, or alternatively concatenate the
> events_tmp arrays I create inside the for loop as I go. In the latter case,
> I'm not sure if the resulting concatenated array would also need to be
> sorted by column 0 so that it reflects the true temporal sequence of the
> events?
>
> The define_target_events example in the gallery was great as far as it
> goes, but it seems to assume that one would only ever want to do this kind
> of replacement once/for one condition prior to epoching. I need to do it 32
> times.
>
> thanks in advance!
> Aaron
>
>
>
> --
>
> Aaron J Newman, PhD
>
> Professor
>
> Director, RADIANT CREATE Neurotechnology Innovation Training Program
>
> Director, NeuroCognitive Imaging Lab (NCIL)
>
> FACULTY OF SCIENCE
>
> Department of Psychology & Neuroscience
>
> FACULTY OF MEDICINE
>
> Departments of Pediatrics, Psychiatry, and Surgery
>
> Aaron.Newman at dal.ca
>
> +1.902.488.1973 <(902)%20488-1973> | fax: +1.902.494.6585
> <(902)%20494-6585>
>
> Box 15000, Life Sciences Centre, Halifax NS B3H 4R2 Canada
>
> DALHOUSIE UNIVERSITY
>
> NCIL.science <http://ncil.science/>
> dal.ca/RADIANT <http://www.dal.ca/RADIANT>
>
> _______________________________________________
> 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/20170208/7f585513/attachment-0001.html 


More information about the Mne_analysis mailing list