Stimuli/ Triggers/ Timing difficulties

1,450 views
Skip to first unread message

Douglas

unread,
Apr 19, 2012, 1:44:52 PM4/19/12
to E-Prime, ep...@msu.edu
Hello E-Prime experts,

We are Working in our lab with Iwave and E-prime;

There's a problem that bothers us.

The triggers stay for 500 msec, exactly the same duration as the
Stimuli. We want to write a code that makes the trigger and stimulus
onset at the same time exactly( which is the case now with the new
line: Stimulus.OnsetSignalData = c.getattrib(`"Cond") ) AND the
trigger to offset as quickly as possible while the stimulus stays on
the screen for 500 msec.

Looking forward to any solutions

Many thanks in advance.

David McFarlane

unread,
Apr 19, 2012, 2:09:57 PM4/19/12
to e-p...@googlegroups.com
We do this all the time for our EEG programs, but it requires a
little finesse. In short, we use a PreRelease value of 1-20 ms less
than the Duration of the stimulus object. E.g., for your object with
a Duration of 500, set PreRelease to 490. Now your trigger will
coincide exactly with the onset of your stimulus, and will last for
10 ms, when the "offset" of the stimulus occurs.

Note that, in E-Prime parlance, stimulus "offset" does not mean
either the end of stimulus presentation, nor the onset of the
following stimulus; "offset" actually refers to when E-Prime stops
executing code for that object and moves on to executing further
instructions. Someday I need to write this all up, but it's tricky
to describe this all correctly.

-----
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (twitter.com/EPrimeMaster)

David McFarlane

unread,
Apr 19, 2012, 2:17:59 PM4/19/12
to e-p...@googlegroups.com
Sorry, I forgot to elaborate on the "finesse" part. The shortcoming
of this solution is that you *must* remember to adjust the PreRelease
value any time that you change Duration, and it is *very* easy for
most users to overlook that, as I can tell you from experience!

-- David McFarlane

Douglas

unread,
Apr 19, 2012, 2:41:31 PM4/19/12
to E-Prime
Hi again

Thanks a lot for your prompt reply
We just did what you said, a new problem occurred!

Th first time after running the experiment, a new unknown trigger
showed up as "50"! and the second time there were no triggers shown on
IWave ar all!

Do you have any ideas, why this is happening?

David McFarlane

unread,
Apr 19, 2012, 3:28:55 PM4/19/12
to e-p...@googlegroups.com
Ah. Did you make sure to use a PreRelease suitably shorter than
Duration? It is tempting to just set PreRelease to Duration, but
that will often create problems like the ones you mention. First,
too short a trigger and your equipment may simply fail to detect
it. In other cases, you get a much stranger effect. I do not know
if this is due to the hardware or to E-Prime, but we have found that,
when outputting a signal from E-Prime, it generates the output in two
stages: First it sets all the requested "1" bits from the specified
signal value, then it resets all the "0" bits from the specified
signal value. This works fine as long as your new signal only sets
some bits from 0 to 1, or resets some bits from 1 to 0, but not
both. E.g., outputting a decimal 5 (binary 0101) following a decimal
4 (binary 0100), or vice versa, works OK. But trouble ensues when
you both change some bits from 0 to 1 and others from 1 to 0. E.g.,
if you change decimal 1 (binary 0001) to decimal 4 (binary 0100),
your output will actually go from 1 (0001) to *5* (0101) then to 4
(0100)! So under some circumstances you will get some odd behavior
(you wouldn't believe how much trouble it took us to figure this out!).

So, as I explain in more detail in my online course (but without
going into all these specific I/O intricacies), as a general rule you
must make sure to set your output to a known base value well before
you output each signal (including the first one!), and you must make
each signal remain long enough for your equipment to detect it.

So, for practice, for your 500 ms stimulus, try setting PreRelease to
400, and see how that works. Then try shorter values, and titrate it
until you get suitable results.

And take my online course!


-----
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (twitter.com/EPrimeMaster)

Douglas

unread,
Apr 20, 2012, 11:52:41 AM4/20/12
to E-Prime
Hello David,

Thanks a lot for your help.
We made the PreRelease 400 and it seems like a miracles happened. Many
thanks to you.

Now, As our first problem was the delay of appearing the stimuli and
triggers. We realized we still have that Delay and that the delay is
not the same during the whole experiment among all Stimuli. As we read
your posts regarding the timings and delay. We have realized we might
have been measuring the delay in a wrong way. I am quoting what I read
with your signature and then I will ask you my new question!

"- OnsetTime: Time when E-Prime actually submitted the stimulus data
for
presentation (e.g., proceeded to copy data to display memory or
load
sound buffer). This may not coincide with when the stimulus
actually
got presented, e.g., if data are submitted in the middle of a
display
refresh cycle then they may not get presented until the next
refresh."

So, We have been trying to make the delay between the time stimulus is
Presented by E-Prime on the screen and the time Trigger appears,, as
least as possible and we wanted that delay to be fixes or within the
least range possible. But As we read your post, we realized that what
we were measuring which was the difference between Stimulus OnsetTime
and Trigger OnsetTime, is the wrong way to measure that delay.

Do you have any ideas that what can we add in out inline to measure
this delay or where we should look if we want to see the time of
presentation of the stimulus and trigger?

Looking forward to hearing from you.

David McFarlane

unread,
Apr 20, 2012, 12:12:07 PM4/20/12
to e-p...@googlegroups.com
First, I must ask how exactly you measure "Stimulus OnsetTime" and
"Trigger OnsetTime", please provide details. AFAIK EP does not log
those separately, so you seem to know something that I do not.

But ultimately, if you really want to know the relationship between
the time of a visual stimulus and the time of a trigger output, then
you must get out a dual-channel oscilloscope, aim a high-speed
photodetector (e.g., photodiode or phototransistor) at your display
screen, tap a line into your trigger output, and then look at those
signals on the oscilloscope. You might need to find someone local
with some electrical engineering experience to help with this.

And then, to get the best timing performance, you *must*, MUST
thoroughly study Chapter 3 of the User's Guide that came with
E-Prime!!! I cannot stress that enough! Until you do that, you
might as well be using a handheld stopwatch.

-----
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (twitter.com/EPrimeMaster)

Douglas

unread,
Apr 20, 2012, 12:45:30 PM4/20/12
to E-Prime
Hi Again!

Stimulus OnsetTime is given by E-Prime in the Spreadsheet at the end
of the experiment (*.edat2).
And as for the Trigger OnsetTime, we are using c.setattrib "condtime",
Clock.ReadMillisec (we placed this in the same inline that send the
triggers)

Now, Do you think there is a way to know the exact time E-Prime
presents the stimulus on the screen?
How much do you think the difference is between the Stimulus OnsetTime
and the exact time the Stimulus is actually presented?

Thanks again

David McFarlane

unread,
Apr 20, 2012, 12:55:03 PM4/20/12
to E-Prime
At 4/20/2012 12:45 PM Friday, Douglas wrote:
>Stimulus OnsetTime is given by E-Prime in the Spreadsheet at the end
>of the experiment (*.edat2).
>And as for the Trigger OnsetTime, we are using c.setattrib
>"condtime", Clock.ReadMillisec (we placed this in the same inline
>that send the triggers)

I would not completely trust your Clock.ReadMillisec here, as there
may be delays in program execution between Stimulus.OnsetTime and
execution of your c.SetAttrib command.

Now, I hate to repeat myself, but...

>Now, Do you think there is a way to know the exact time E-Prime
>presents the stimulus on the screen?

Again, you need an oscilloscope and a local electrical engineer to
help you with that.

>How much do you think the difference is between the Stimulus
>OnsetTime and the exact time the Stimulus is actually presented?

And again, YOU MUST STUDY CHAPTER 3 OF THE USER'S GUIDE BEFORE
PURSUING THIS FURTHER!!!!!!!!!!

-- David McFarlane

Douglas

unread,
May 3, 2012, 1:36:59 PM5/3/12
to E-Prime
Hi,

1-I have to Synchronize Trigger with Stimulus with. What we have is:
Stimulus.OnsetSignalData=c.getattrib ("cond")
But I have been told I have to add "SynchTrigger" somewhere! Does
anyone know how I can Synchronize Trigger time and Stimulus time like
they start at 0 millisec?

2-I have asked other researchers who work with e-prime on Windows7 and
one told me eprime doesn't work well( in matters of time) with
Windows7. Is that true?

3-I came across one line which I don't know what exactly it is doing!
c.SetAttrib"CondTime",clock.ReadMillisec
Do you have any ideas?

4- would you please tell me what is called the time the computer shows
the picture and the time it shows the trigger? are they start times?

5- If I want triggers and stimuli to show up on monitors at the exact
same time( Millisec), How do I have to write the command codes?

6- Why are we having Triggers much sooner than Stimuli? and why it is
variable in different stimuli? we have 200 Stimuli and I can see on
Iwave Triggers come sooner than Stimuli( up to 900millisec)

7- If ever, anyone accepts to look at the exp.es2 to explore and
correct the problem, I will be grateful.


Looking forward to a huge help, desperately!

David McFarlane

unread,
May 3, 2012, 5:23:17 PM5/3/12
to e-p...@googlegroups.com
At 5/3/2012 01:36 PM Thursday, Douglas wrote:
>1-I have to Synchronize Trigger with Stimulus with. What we have is:
>Stimulus.OnsetSignalData=c.getattrib ("cond") But I have been told I
>have to add "SynchTrigger" somewhere! Does anyone know how I can
>Synchronize Trigger time and Stimulus time like
>they start at 0 millisec?

Read Chapter 4, "Using E-Basic", in the User's Guide that came with
E-Prime, and see the "Context.GetAttrib" and Onset/OffsetSignal
topics in the E-Basic Help facility. My online course also has a
lesson that addresses this very topic. PST Web Support
(http://support.pstnet.com/e%2Dprime/support/login.asp ) might also
help you with this.


>2-I have asked other researchers who work with e-prime on Windows7
>and one told me eprime doesn't work well( in matters of time) with
>Windows7. Is that true?

You may find PST's latest statements at their Knowledge Base, e.g.,
http://www.pstnet.com/support/kb.asp?TopicID=4026 and
http://www.pstnet.com/support/kb.asp?TopicID=4347 . We have been
sticking to Windows XP as much as possible, but I don't know that
that's so necessary anymore. In any case, best practice calls for
every lab to verify these matters for themselves rather than to rely
on the proclomations of commercial companies who stand to make a
profit, or random windbags on the internet like me. So devise and
run your own tests (perhaps using an oscilloscope or other trusted
measuring devices).


>3-I came across one line which I don't know what exactly it is doing!
>c.SetAttrib"CondTime",clock.ReadMillisec
>Do you have any ideas?

Read Chapter 4, "Using E-Basic", in the User's Guide that came with
E-Prime, and see the "Context.SetAttrib" topic in the E-Basic Help facility.


>4- would you please tell me what is called the time the computer
>shows the picture and the time it shows the trigger? are they start times?

This has been discussed already.


>5- If I want triggers and stimuli to show up on monitors at the
>exact same time( Millisec), How do I have to write the command codes?

I would use the Onset/OffsetSignal facilities of E-Prime. See, e.g.,
the Slide.OnsetSignalEnabled and related topics in the E-Basic Help
facility. And my online course has a lesson that addresses this very topic.


>6- Why are we having Triggers much sooner than Stimuli? and why it
>is variable in different stimuli? we have 200 Stimuli and I can see
>on Iwave Triggers come sooner than Stimuli( up to 900millisec)
>
>7- If ever, anyone accepts to look at the exp.es2 to explore and
>correct the problem, I will be grateful.

PST Web Support
(http://support.pstnet.com/e%2Dprime/support/login.asp ) may do that
for you, give them a try.


>Looking forward to a huge help, desperately!

Relax, the world does not hinge on your research project. When I was
in graduate school, my advisor told me to slow down, science is a
deliberative enterprise, take time to properly deliberate. Or have
things changed that much since the early 1980s?

David McFarlane

unread,
May 4, 2012, 10:20:44 AM5/4/12
to e-p...@googlegroups.com
I should also mention the following PST Knowledge Base articles:

http://www.pstnet.com/support/kb.asp?TopicID=1316 (WritePort)
http://www.pstnet.com/support/kb.asp?TopicID=1317 (Port device to
receive signal)
http://www.pstnet.com/support/kb.asp?TopicID=1318 (Onset/OffsetSignal)
http://www.pstnet.com/support/kb.asp?TopicID=1320 (general parallel port info)

-----
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (twitter.com/EPrimeMaster)


Douglas

unread,
May 8, 2012, 2:38:28 PM5/8/12
to E-Prime
Dear Mr. McFarlane,

Thanks a lot for your reply, time and effort.
With all my respect and appreciation:

1-...
Chapter 4 "Using E-Basic" wasn't useful much. As the things I had
forgotten wasn't related to our experiment much.

2-...
As for PST's latest statements at their knowledge Base;
4026: I know the facts about windows 7 and E-Prime. I got familiar to
them while trying to install it on my computer. But I have heard "non-
promising" things from other researcher and I just wanted to see if
others have same sad experiences or not.

4347: As we don't have sound files in our experiment, I don't think
this one is related to our experiment. Although we have disabled an
option due to sound in the process! What I don't know is if we have
Start up Latency for images and let's say that's what causes problems
for us why it differ from image to image with exact same sizes. And I
didnt get his part and how it can effect our experiment:

In Windows Vista and Windows 7 (and beyond), the DirectSound API no
longer is a thin layer between E-Prime (or any application) and the
sound hardware, but instead sits on another management layer.
This results in poor performance on the same hardware where lower
latency was achieved on the same hardware using Windows XP. Typically
these results average in the 30ms range for startup.
Therefore, PST does not recommend paradigms requring startup latency
values of less than 30ms under Windows Vista or Windows 7 for E-Prime
1.0, E-Prime 1.1, or E-Prime 1.2.

3-...
Context.SetAttrib or Con.SetAttrib doesn't match our needs, goals or
expectations if I got it right!

4-...
About StartTime and OnsetTime, I remember what you said and what I
looked for was:
OnsetTime>>Timestamp at which the object begins its critical action
(e.g., drawing to the screen).
StartTime>> Timestamp at which execution for the object began
(i.e.,time at which the Run method began to execute).

So, I guess logically OnsetTime should come before StartTime... That's
why I don't get this:
Stimulus.OnsetTime: 33523
Stimulus.PreRelease: 400
Stimulus.Duration: 489
Stimulus.StartTime: 32948

But this is what PST Technical Consultant Told me:
"OnsetTime represents the time the object was actually presented.
StartTime can occur before OnsetTime and should not be used for
measurements."

Now, if we have a huge difference between Stimulus StartTime and
Stimulus OnsetTime, there should be such difference between Trigger
StartTime and Trigger OnsetTime, IF such thing exists at all! And If
it does exist, Which one are we measuring?!

5-...
It is already done.

6-..
I didn't see any replies for that. This is our major concern now.

7-...
I am discussing this matter with them at the same time.

You are right, The world does not hinge on our research but believe it
or not, we are(sort of!)!

So, still, if anyone wishes to help... we are open to suggestions.

With best wishes at what ever you are working on
Message has been deleted

David McFarlane

unread,
May 8, 2012, 5:53:14 PM5/8/12
to E-Prime
Perhaps I can clarify this point a bit further. As discussed at
http://groups.google.com/group/e-prime/browse_thread/thread/39e899d3457d4917
, StartTime indicates the time at which E-Prime started to *execute*
the *code* for the stimulus object. In many cases, that code
includes operations such as waiting for a screen refresh, etc., so
you may find a considerable delay from StartTime to OnsetTime
(although 575 ms does seem excessive). OnsetTime, as stated before,
indicates the time at which E-Prime actually submitted the stimulus
data for *presentation*, and that is the time that interests you in
this case. And your OnsetSignal trigger should occur at the
OnsetTime of your stimulus, but if you really want to verify this
then you need to get out an oscilloscope and measure it.

For future reference, note that the various time audit measures take
place in the order in which I presented them in the thread linked above.

-- David McFarlane

Douglas

unread,
May 18, 2012, 11:46:01 AM5/18/12
to E-Prime
Hello again Mr. McFarlane,

I want to use Photodiodes.
Would you please tell me what kind of photodiodesI have to buy and how
I should install it?!

Thanks

David McFarlane

unread,
May 18, 2012, 11:55:06 AM5/18/12
to E-Prime
Any local electronics expert can handle this for you, you would do
best to find one at your own institution. Also, PST Web Support
might have some advice. One hurdle I will mention -- peak light
output of modern LCD/TFT displays is much less than the old CRT
displays, so if you use an LCD display then you will need a good
sensitive photodetector.

-- David McFarlane

Peter Quain

unread,
May 18, 2012, 8:11:12 PM5/18/12
to e-p...@googlegroups.com

If LCD monitor is being used can you please post back to the list
results of the photodiode tests. It will be interesting to see (a)
whether there is any input lag; and (b) the relationship of this (if
present) to trigger accuracy. Any input lag of the monitor will cause
trigger to occur prior to display onset (on screen, not according to
e-prime which will log when frame sent from display adaptor). If
input lag is there it will most probably differ across trials which
will give a degree of trigger slop - meaning you can't adjust the
trigger position posthoc by a constant.

Peter
>--
>You received this message because you are subscribed to the Google
>Groups "E-Prime" group.
>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.

Reply all
Reply to author
Forward
0 new messages