event code during object

Paul Gr pauls_postbus at hotmail.com
Sat May 27 13:17:49 UTC 2006


Dear Heleen,

The most reliable procedure for relaying responses to event codes in real 
time is to use the Terminate or JumpTo options for the ‘end action’ in the 
input mask in combination with some inline scripting. A rather simple 
construction is possible when the input can only be given during the 
lifetime of a single EPrime object. In this case you can specify Terminate 
as ‘end action’ and use some inline script immediately after this input 
object to generate the event. When you would still like have the initial 
object (i.e. the stimulus) to stay visible for the specified duration, then 
you would also have to add an additional delay for the leftover time 
(=duration-RT). This would look something like this:

WritePort &H378, code ‘ send event code to LPT1
dim tLeftover as long
tLeftover = Stimulus.Duration – (Clock.ReadMillisec- Stimulus.OnsetTime)
if tLeftover>0 then Sleep(tLeftover) ‘ and keep stimulus visible

However, the situation is more complex if the response can occur during two 
or more objects in a sequence. To start with, you should configure only the 
input mask for the first object and increase the time limit from ‘(same as 
duration)’ to the total time required. (Or even to ‘infinite’ if the total 
time for the input window is not fixed.) This way EPrime will also detect 
responses in the additional object(s). When the end action is set to 
‘Terminate’ then you will have to insert some inline script after each 
object of this sequence to handle the response. Each inline script object 
will have the same kind of code as shown above, but with an additional test 
to figure out if the response was given during the previous object. Assuming 
that you have two objects (Stimulus and Fixation), and have the input mask 
of the Stimulus object configured for accepting responses during both the 
Stimulus and the Fixation object, then the inline scripts would look like:

‘ inline after Stimulus:
if Stimulus.RtTime>= Stimulus.OnsetTime then
   WritePort &H378, code ‘ send event code to LPT1
   tLeftover = Stimulus.Duration – (Clock.ReadMillisec- Stimulus.OnsetTime)
   if tLeftover>0 then Sleep(tLeftover) ‘ and keep stimulus visible
end if

‘ inline after Fixation:
if Stimulus.RtTime>= Fixation.OnsetTime then
   WritePort &H378, code ‘ send event code to LPT1
   tLeftover = Fixation.Duration – (Clock.ReadMillisec- Fixation.OnsetTime)
   if tLeftover>0 then Sleep(tLeftover) ‘ and keep fixation visible
end if


However, with this code there is a small risk of ‘missing’ responses that 
fall between the execution of first inline script and the onset of the 
fixation. Therefore, it is better to use the following code:

‘ inline after Stimulus:
Dim bReponseHandled as Boolean
if Stimulus.RtTime>= Stimulus.OnsetTime then
   bReponseHandled = true
   WritePort &H378, code ‘ send event code to LPT1
   tLeftover = Stimulus.Duration – (Clock.ReadMillisec- Stimulus.OnsetTime)
   if tLeftover>0 then Sleep(tLeftover) ‘ and keep stimulus visible
end if

‘ inline after Fixation:
if Stimulus.RtTime>= Stimulus.OnsetTime And Not bReponseHandled then
   bReponseHandled = true
   WritePort &H378, code ‘ send event code to LPT1
   tLeftover = Fixation.Duration – (Clock.ReadMillisec- Fixation.OnsetTime)
   if tLeftover>0 then Sleep(tLeftover) ‘ and keep fixation visible
end if

Note that using PreRelease times might be very tricky in this case. 
(Although I think the latter code example is safe to use in conjunction with 
PreRelease times. Be careful though!)

Hope this helps.

Paul Groot
Vrije Universiteit van Amsterdam
The Netherlands


>From: Heleen Slagter <slagter at wisc.edu>
>To: eprime at mail.talkbank.org
>Subject: event code during object
>Date: Thu, 25 May 2006 09:20:03 -0500
>
>Hi all,
>
>I was hoping to get some advice on the following:
>
>In my EEG experiment, I would like to send out an event code right when
>a response is given to a particular object, even though this response
>might be given *before the offset* of this object (e.g., a face) or
>*after the offset* of this object (during the presentation of the next
>object (e.g., a fixation cross)). The response is made with a keyboard.
>One possibility may be to use a loop to check input from the keyboard,
>but I am afraid that this will result in timing error across the
>experiment.
>
>Any advice on this matter would be greatly appreciated!
>Best wishes,
>
>Heleen Slagter
>-------------------------------------------------
>University of Wisconsin, Madison
>Waisman Laboratory for Brain Imaging & Behavior
>Laboratory for Affective Neuroscience
>
>Email: slagter at wisc.edu
>www (Lab for Affective Neuroscience): http://psyphz.psych.wisc.edu
>www www (Waisman Lab): http://brainimaging.waisman.wisc.edu
>-------------------------------------------------
>



More information about the Eprime mailing list