sending trigger to other devices locked on to the time of response

1,652 views
Skip to first unread message

Jaeyong Lee

unread,
Sep 1, 2010, 2:38:08 AM9/1/10
to E-Prime
Hi to all.

I was wondering if there is a way to send trigger signals locked on
the response time.

For instance,

Stim.OnsetSignalEnabled = True
Stim.OnsetSignalPort = &H378
Stim.OnsetSignalData = 1


WritePort &h378, 0

the above code send triggers at the onset of the object "Stim".

However, I am trying to figure out a way to send triggers at the time
of response of "Stim".

I would greatly appreciate all tips and advices from you. Thanks.

David McFarlane

unread,
Sep 2, 2010, 3:08:49 PM9/2/10
to E-Prime
Good timing -- It just so happens that I have been working on this
very issue for a lab here. You have to make the proper settings in
your stimulus, and use a bit of inline code following the
stimulus. Here is the fully-commented inline code for my solution:


'/----------------------------------------------------------------------
' We wish to present a stimulus (in this case, StimText), get a
' response during that stimlus, and raise a signal as soon as the
' subject responds.
'
' To do that, we need to run this inline code during StimText. We
' could simply set the Duration of StimText to 0 or so (depending on
' considerations such as leaving some time between stimulus .OnsetSignal
' and .OffsetSignal) and then our code would have to also handle
' further stimulus timing. But with judicious use of Duration and
' PreRelease, E-Prime will automatically take care of stimulus timing
' for us.
'
' So instead we simply set the Duration of StimText as desired (which
' as a result automatically determines the target onset time for the
' next stimulus object), and we set the PreRelease of StimText to a
' suitably large value (preferably >= Duration, but perhaps less due
' to other considerations as mentioned earlier). Now this code will
' start to run soon after the onset of StimText, and handle the
' reaction to the subject response.
'
' Finally, this code simply makes use of .IsPending() to detect the
' response (see the InputMask.IsPending topic in the online E-Basic
' Help). Note that as a result StimText will last at least as long
' its input mask Time Limit, regardless of its Duration (if you just
' keep Time Limit at the default of "(same as duration)" then this
' will not pose a problem).

Const LptDataPort as Integer = &H0378 ' adjust this for your system
Const SignalData as Integer = &HFF ' adjust this for your device
Const LoopDelay as Long = 2 'ms; set as small as possible for your
' system

Do While StimText.InputMasks.IsPending()
' Some slower machines (such as my home laptop) need a delay so that
' EP can detect & handle input:
Sleep LoopDelay
Loop
WritePort LptDataPort, SignalData
'\----------------------------------------------------------------------


This is fine as long as you limit the response to coming during the
stimulus. If you want to present a train of stimuli during the
response period then you must do a little more. I also have a
solution for that, but it is rather intricate and too much trouble to
go into here, so I hope this is good enough for now.

-- David McFarlane, Professional Faultfinder

Jaeyong Lee

unread,
Sep 3, 2010, 1:55:52 AM9/3/10
to E-Prime
Dear Professional Faultfinder,

Thanks for posting your script!
In my experiment the response comes after the offset of the target
stimulus.
If it is not too much of a trouble, I would appreciate to hear about
your
solution to presenting other stimuli during the response period.

Thanks again!

David McFarlane

unread,
Sep 3, 2010, 9:41:06 AM9/3/10
to e-p...@googlegroups.com
Well, here's the deal. That solution is too
involved for me to write out as a post to the
Group. But I have it all arranged in a very nice
demo program. But I cannot let myself become a
curator for a library of demo programs (I have
more than this in my growing collection). So, if
someone can send me instructions for how to
upload my demo program file to a place where
*everyone* can download it from then on, then I
would be very happy to share that and more with the community.

-- David McFarlane, Professional Faultfinder

>Dear Professional Faultfinder,
>
>Thanks for posting your script!
>In my experiment the response comes after the offset of the target
>stimulus.
>If it is not too much of a trouble, I would appreciate to hear about
>your
>solution to presenting other stimuli during the response period.
>
>Thanks again!
>
>

Jaeyong Lee

unread,
Sep 7, 2010, 1:32:53 AM9/7/10
to E-Prime
I suggest couple of ways to upload e-prime related files.

One way is to open a ftp. I can personally run a server computer for
it.
The advantage of it is that files can be uploaded at unlimited numbers
and capacity.
Also, access to the file is comparatively simple. The downside is
that the server computer
can be unstable. I can guarantee you that I will run it 24/7 for at
least a year.

Another solution is to simply use a file-hosting site. As most of you
know
the 'RapidShare' provides 200 mb of space for each upload. It does
not require any
personal information other that the email address. Simply uploading
the file
on rapidshare and distributing the URL will probably let the people in
this
forum share the source file.

David McFarlane

unread,
Jun 28, 2011, 12:15:45 PM6/28/11
to e-p...@googlegroups.com
Gosh, looking over this old thread, I see that I overinterpreted the
question and answered one more complex than the question asked. I
addressed the question of how to send an output signal following a
response that did *not* terminate the stimulus (i.e., End Action =
(none), so stimulus finishes its Duration after the response).

More likely the questioner had a simpler case in mind, i.e., a
self-paced stimulus where the response terminates the stimulus, and
then E-Prime sends an output signal. For that simpler case, please
see discussion at
http://groups.google.com/group/e-prime/browse_thread/thread/ef0e5a8d8b87aa0c .

-- David McFarlane, Professional Faultfinder

David McFarlane

unread,
Jul 11, 2011, 2:53:01 PM7/11/11
to e-p...@googlegroups.com
Hmm, another correction to this old thread. As a result of an
off-list discussion with Kenneth Campbell (School of Psychology,
University of Ottawa, Canada), I see that in my post of 2 Sep 2010 I
took some things for granted and left out some needed
explanation. So to clarify, that solution assumes two other things:

- Set the response Time Limit of the stimlus (e.g., StimText) to
match how long you want to allow for a response (i.e., use "extended
input" (see Appendix C of the E-Prime User's Guide)). (This is
implied in one of the later comments in the code excerpt, but is
worth making more explicit.)

- If you want to allow the stimulus to complete its Duration after a
receiving a response, then set the End Action of its input masks to (none).

Also, I now notice that the comment "... StimText will last at least
as long its input mask Time Limit" is not quite correct, but at the
moment I don't know quite how to accurately express the resulting
interactions between Duration, Time Limit, End Action, and response,
so I will leave that as an exercise for others.

Hope that helps,


-- David McFarlane, Professional Faultfinder

Tobias

unread,
May 24, 2012, 10:54:57 AM5/24/12
to e-p...@googlegroups.com
Hi David,

thanks for your solution. You might have seen my other recent posting (https://groups.google.com/forum/?fromgroups#!topic/e-prime/GkQSKYep2so) where I have the following paradigm:

1) 200 ms search slide (fixed duration)
2) up to 5000 ms response slide (terminated by response to 1))

I managed to have a fixed duration for 1) and a terminating presentation for 2) but I don't seem to being able to manage that a trigger will be sent during 1)

Any ideas how to implement your solution to my example?

Best,
Tobias

David McFarlane

unread,
May 24, 2012, 12:04:56 PM5/24/12
to e-p...@googlegroups.com
Tobias,

I cannot go into detail here, but in broad scope, we achieved this by
using inline code much like the example posted earlier in this
thread, but using it after each of the stimulus objects that might
receive a response. We of course also used extended input through
the entire response period. We also had to add a "flag" variable to
carry some information between the InLines. This approach does get
rather tedious and intricate. (I do point out, however, that at
least EP provides all the elements for any reasonably skilled
programmer to achieve the desired effect, which I would not say for
all psychology programming platforms.)

The new Task Events feature introduced in EP2.0.10.182 may give us a
better way to do this, but that also has limitations, see
http://groups.google.com/group/e-prime/browse_thread/thread/f6fa4b793264fa5c .

-- David McFarlane

Tobias

unread,
May 25, 2012, 7:07:55 AM5/25/12
to e-p...@googlegroups.com
David,

I had the following idea to resolve the problem: I will set duration of the slide called "search" to 200 ms with "terminate" as end action. I will then present the same slide for the residual time (i.e. 200 ms - RT).

I used the following inline script:

WritePort &HD030, 0
search.OnsetSignalData = "100"    'Sends marker for search display
search.OffsetSignalData = 0
Search.Run

if Search.OffsetTime - Search.OnsetTime < 1998 then  'I usually set the last digit to an 8 since that rounds up to 10 which is the shortest refresh cycle we can do here
    Search.Duration = 1998 - (Int((Search.OffsetTime - Search.OnsetTime)/10+0.8)*10)  ' this rounds up for all digits except 0 or 1
    search.OnsetSignalData = 0
    search.run   'this runs search again, but with reduced duration this time 
end if

WritePort &HD030, 0
Response.OnsetSignalData = "200"    'Sends marker for response
Response.OffsetSignalData = 0

if search.RESP <> "" then goto Label1

Response.run


There are several problems with this approach that I don't fully understand:

- Search.OffsetTime - Search.OnsetTime turns out to be not the actual duration but the duration minus the pre-release time
- When resetting the duration time, I found out (trial and error) that I should have 1948 - .... instead of 1998 - ...
- in 80% of the cases, the interval between the triggers is exactly 2000 ms (according to the eeg file that is). In 20% of the cases it is 10 ms too short.

What do you think of this approach and do you know why the mentioned problems occur?

Best,
Tobias

David McFarlane

unread,
May 25, 2012, 10:42:45 AM5/25/12
to e-p...@googlegroups.com
Tobias,

Can't go into much detail, but I do not like this approach. Your
resetting of Duration between presentations of your Slide seems
altogether too empirical & ad hoc (not to mention that you use "magic
numbers" throughout your code). Also, this approach will reset the
input mask for each presentation of the Slide, so that the logged
.RT, etc. will be only for the *final* presentation of the
Slide. And, if the subject responds in the interval between Slides,
then you will miss the response (yes it does happen, I speak from
experience). But maybe I'm missing something.

OK, I'm off on break for a week or so, so will not be able to write
back for awhile... Good luck on the rest of this.

-- David McFarlane
><http://groups.google.com/group/e-prime/browse_thread/thread/f6fa4b793264fa5c>http://groups.google.com/group/e-prime/browse_thread/thread/f6fa4b793264fa5c
>.
>
>-- David McFarlane
>
>
>At 5/24/2012 10:54 AM Thursday, you wrote:
> >Hi David,
> >
> >thanks for your solution. You might have seen my other recent
> >posting
> >(<https://groups.google.com/forum/?fromgroups#%21topic/e-prime/GkQS
> KYep2so>https://groups.google.com/forum/?fromgroups#!topic/e-prime/GkQSKYep2so)
>
> >where I have the following paradigm:
> >
> >1) 200 ms search slide (fixed duration)
> >2) up to 5000 ms response slide (terminated by response to 1))
> >
> >I managed to have a fixed duration for 1) and a terminating
> >presentation for 2) but I don't seem to being able to manage that a
> >trigger will be sent during 1)
> >
> >Any ideas how to implement your solution to my example?
> >
> >Best,
> >Tobias
>
>--
>You received this message because you are subscribed to the Google
>Groups "E-Prime" group.
>To view this discussion on the web visit
><https://groups.google.com/d/msg/e-prime/-/HIblLWsQMtwJ>https://groups.google.com/d/msg/e-prime/-/HIblLWsQMtwJ.
>To post to this group, send email to e-p...@googlegroups.com.
>To unsubscribe from this group, send email to
>e-prime+u...@googlegroups.com.
>For more options, visit this group at
>http://groups.google.com/group/e-prime?hl=en.

Tobias

unread,
May 25, 2012, 11:48:02 AM5/25/12
to e-p...@googlegroups.com
I don't like this approach either, but I don't see any other way of handling this.

By using different rounding numbers (+0.7) I was able to have no time errors in 95% of all trials when participants respond before searchslide offset and no time errors in 100% of all trials when particpants respond after that search slide...

That seems fair enough. THe input mask will be reset, that's true. But I just created a new attribute with the information so that nothing gets lost.

Have a nice holiday! ;)
TObias
Reply all
Reply to author
Forward
0 new messages