Timing out Experiment after specified time.
Hi everyone,
I'm trying to run a switft Letter Comparison Test where participants are asked to judge whether two character strings on screen are the same or different. Their score is determined as the amount of correctly-answered trials in a thirty-second period.
Trouble is, I'm not sure how to terminate my trial sequence after the 30-second time limit. So far, I've built my experiment as normal with a practice and an experimental block (see image below).
I've tried ending the experiment with an inline script at the start of the experiment, as below. I first define a maximum time of 30 seconds (30000 ms) in the Prepare phase, and call time values from the start of my sequence and block. In the Run phase, I have tried setting an "option" variable as 'timeOut' when the counter exceeds the maximum time of 30000ms, and this "option" is then called in the trialSequence to prevent stimuli from running if it is valid.
However, when attempting to run this, OpenSesame returns a
The variable 'time_trialSequence' does not exist.
error. What am I doing wrong here? Am I calling "time_trialSequence" before it is 'created' when trialSequence is run? If so, how do I script this 30-second timeout such that I can call all the variables I need and still initialise the timeout effectively?
I'm running OpenSesame 3.3.9b1 on Ubuntu Linux 20.04. Any help would be very appreciated!
Comments
Hi @Artabanos,
This is happening because at the time you define trialTime (
trialTime = self.get("time_trialSequence")
), the trialSequence object has not started, hence it's time of onset has not been defined.You could try is the following:
(1) define the
maxtime
as you currently, remove everything else from yourtimer
script.(2) at the beginning of your
expSequence
, defineblockTime
(3) at the beginning of your
trialSequence
, define yourtrialTime
(4) in the settings of your
expLoop
, use the "break if" option and set it to([trialTime]-[blockTime] >= [maxtime]
. Now, whenever that condition is met, theexpLoop
will be interrupted and the task will move to whether comes after that loop. If the Break if condition can't include operations, go back to step 3 and add a variable measuring the difference betweentrialTime
andblockTime
(let's say you call ittimeElapsed
), and set the break if condition to[timeElapsed] >= [maxTime]
.Haven't tried implementing this myself but I think it should work.
Good luck!
Fabrice.
Hi Fabrice,
Thank you for your extensive and helpful reply! I didn't actually manage to get your solution to work, but your suggestions did lead me to a solution that ended up doing what I wanted it to do.
1) Before any loops began, I defined
maxTime
as 30000 ms well aselapsedTime
as an empty integer (using theint()
function). This allows the trial loop later to callelapsedTime
even though there is no value to this yet. I also allowed both of these values to be called by OpenSesame using theself.experiment.set()
function.2) Then, I added another inline script as the final step in my trialSequence. This script defines:
timeStart = self.get("time_trialBlock")
as well astimeOut = self.get("time_LCTstring")
.timeStart
, in this case, is the time at which the trial block started, andtimeOut
calls the time at which the last stimulus was presented.timeStart
is a static value, whereastimeOut
updates every time a stimulus appears on screen.3) In the same script, I defined another variable as the difference between these two points in time:
elapsedTime = timeOut - timeStart
(and, again, set this variable to be used withself.experiment.set()
)4) Finally, in my trialBlock loop, I used the 'break if' function and set this to [elapsedTime]>=[maxTime].
In this way,
trialBlock
calls only values already initialised and therefore won't terminate the experiment, and it neatly times out 30000ms (30 seconds) after the start of the trial block.Thanks again for your help @Fab , much appreciated!
Willem
Hi Willem @Artabanos,
Great stuff! Glad you got it to work and solved the problem! 👍️
Good luck with your experiment!
Fabrice.