[Mne_analysis] help with mne.event.define_target_events

Aaron Newman Aaron.Newman at dal.ca
Tue Feb 7 17:31:37 EST 2017
Search archives:

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 | fax: +1.902.494.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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170207/d413546d/attachment.html 


More information about the Mne_analysis mailing list