trigger TMS + collect responses during stimulus
Brandon Cernicky
brandon_cernicky at yahoo.com
Thu Jul 26 12:56:11 UTC 2007
Hi Bianca,
Your design looks pretty close. I have a few
suggestions.
1) Only call WritePort when needed
=============================
You are calling WritePort &H378, 0 every time in the
loop. Consider clearing out the port only when
necessary as continually calling WritePort can
introduce problems and reduce timing precision. You
can setup a clear time variable that can be checked
to do this.
2) Allow the runtime to absorb the time for you
======================================
Predict when the last pulse has been fired and then
break out of the loop. Since you are setting up the
Duration of the main object with a full PreRelease,
the runtime will internally call
SetNextTargetOnsetTime MainStimulus.OnsetTime +
MainStimulus.Duration for you. Note that if you have
the Duration set to zero then you will need to
manually call SetNextTargetOnsetTime yourself. In
short, each E-Prime object in its .Run call will spin
in a loop similar to the following
While Clock.Read < GetNextTargetOnsetTime()
Wend
Thus, you could setup two objects TextDisplay1 and
TextDisplay2 in the GUI with duration of 1000. If you
stick an InLine inbetween them with
SetNextTargetOnsetTime TextDisplay1.OnsetTime + 5000,
then TextDisplay2 wont start 1000 after TextDisplay1,
it will start 5000 later. Note that use of this
command in script should be used with caution/care.
In summary, the use of PreRelease on an object is used
to give up time of the currently running object to
allow the next object to prepare. Since you are using
this PreRelease time to loop and port pulse, you may
not be providing enough time for the mask stimulus to
prepare. By calling .Run on the mask after the last
pulse and well prior to when it needs to start will
allow the mask to prepare. As your script was
written, you were allowing for no more than 4ms
(assuming the 8.333 ms refresh duration) to prepare
and that may not have been enough time.
For your specific edit, cut out your middle do loop
that is "loop until clock.read() >= MainStimOnset +
StimDisplayDuration -
(0.5 * RefreshDuration)" and then add a calculation to
see if the next PulseTime would occur >= the onset +
duration and if so break out of the loop.
Note that if your pulse count was not divisible by the
time you wanted to start the next object, then this
method would not work since the amount of time the
mask would be absorbing would be out of the InLine
when another pulse would have been necessary to be
fired.
3) Reduce size of stimulus/mask
===========================
If the mask or stimulus are not taking up the entire
screen, consider reducing the frame size which will
reduce how long it takes for the object to setup and
draw.
4) Calculations
=====================
For the loops, consider assigning the calculation to a
variable. Continually doing the math could reduce
some timing precision. That is, make a variable named
quit time instead of doing the addition,
subtraction, and multiplication as the exit condition
in the loop. The same would apply consider a
HalfDuration variable so that the multiplication is
not needed each time.
-Brandon
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting
More information about the Eprime
mailing list