Terminate list at set time, even if current sample no completed.

1,199 views
Skip to first unread message

Kate Cox

unread,
Nov 10, 2013, 9:39:37 PM11/10/13
to e-p...@googlegroups.com
Hi I'm very new to eprime and have no script background so please be gentle :).

What I'm trying to do: present participants with a series of mathematical equations which they must answer, using the keyboard. They must answer as many equations as they can in 2 minutes. After 2 minutes the task will terminate (and go on to the next task) even if they are part way through giving an answer. The outcomes i'm measuring are accuracy, RT of correct responses and number of correct responses in the 2 minute time window.

What is working and how I have it set up: I have 300 potential equations in a list called "TrialList", which are presented on a TextDisplay. This works perfectly.
Answers typed on the keyboard are echoed on the screen and logged. When an answer is complete the participant presses ENTER and the the next equation in my list is shown. This works perfectly. 
In the TextDisplay properties, under the Duration/Input tab I have duration as infinite, timing mode as Event, the keyboard as the only device, allowable responses is any, time limit is same as duration and End action is terminate.
In the list properties, under the Reset/Exit tab I have set Exit List to "After 120 seconds"

The problem: I can't get the task to terminate at exactly 2 minutes. At the moment it appears to stop when the trial that is running at 2 minute mark is terminated (ie the participant presses enter).  For example if a participant starts an equation at 1:55 then the task won't stop at 2:00 it will wait until they submit their answer and that trial is terminated. As some of my participants aren't particularly fast to provide their responses this may end up being closer to 3 minutes than 2.  

I'm pretty useless with script but I've found the bit that refers to the termination settings and it looks like this:

Set TrialList.TerminateCondition = TimedMSecs(120000)
Set TrialList.ResetCondition = Samples(300)
TrialList.Reset

I've tried searching this group and the Eprime guide for the answers but can't find how to fix it. I know some people have mentioned some script that terminates at a particular clock setting  but my script seems to look different to theirs so I'm not sure how to implement it. Also this maths task is part of a larger battery of tasks so how a participant performs on earlier tasks will determine where the running clock is when they get up to the maths problems (ie a participant who is faster at earlier tasks may start the math task at the 5 minute mark and someone who is slower might start it at the 7 minute mark, so the running clock will be different 2 minutes into the math task).

I hope all this makes sense. Any help would be hugely appreciated.

thank you in advance
Kate 

Paul Groot

unread,
Nov 11, 2013, 3:15:40 AM11/11/13
to e-p...@googlegroups.com
Hi Kate,

Because the 'exit list' condition is tested at the end of each trial, eprime doesn't handle timeout values that occur during the trial itself. Even if the trial only contains a single object. The solution is to limit the duration of the individual object(s). 

This is what I would do (assuming that the TextDisplay object is called Stimulus):

1) Create a global variable in the user section of the script window:

Dim FirstOnset As Long ' onsettime of first stimulus

2) Insert an inline script at the start of the trial procedure that calculates the total time left, and use this value to change the stimulus duration from infinite to the leftover time:

' FirstOnset is a global variable which is declared in the user section of the script window
If FirstOnset=0 Then
FirstOnset = Stimulus.TargetOnsetTime
End If

Dim timeLeft As Long
timeLeft = 120000 - Stimulus.TargetOnsetTime
If timeLeft>0 Then
Stimulus.Duration = timeLeft
Else
Stimulus.Duration = 0
End If

Things can get a bit more complex if the trial contains several objects, though. 

Also also see the attached example.

Best
Paul



--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/45042996-2ab3-49e6-a906-558b31be27f4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

SetTaskDuration.es2

David McFarlane

unread,
Nov 11, 2013, 4:00:26 PM11/11/13
to e-p...@googlegroups.com
I would have said to set stimulus PreRelease to same as Duration and
use inline code after the stimulus to look for the timeout, but I
like Paul's solution much, much better and will add that to my own
bag of tricks (thanks, Paul!).

Just a couple more thoughts on this:

1) Shouldn't the line

timeLeft = 120000 - Stimulus.TargetOnsetTime

instead read

timeLeft = 120000 - (Stimulus.TargetOnsetTime - FirstOnset)

? Also, the first time the initialization line

FirstOnset = Stimulus.TargetOnsetTime

runs, Stimulus.Target is 0, and that may adversely affect the
Duration for the first run of Stimulus. This could be fixed by
instead using GetNextTargetOnset time, thus,

FirstOnset = GetNextTargetOnsetTime

Also, timeLeft is based on the OnsetTime of the previous run of
Stimulus, but I think you need to take into account how long that run
lasted. You could do that by using GetNextTargetOnsetTime
instead. Putting that all together, the inline code might instead read

' FirstOnset is a global variable which is declared in the user section of
' the script window
If (FirstOnset = 0) Then FirstOnset = GetNextTargetOnsetTime
Dim timeLeft As Long
timeLeft = 120000 - (GetNextTargetOnsetTime- FirstOnset)
If (timeLeft > 0) Then
Stimulus.Duration = timeLeft
Else
Stimulus.Duration = 0
End If

Finally, instead of a FirstOnset you might instead use a LastOffset,
thus (also using Iif() to suit my own peculiar tastes),

' LastOffset is a global variable which is declared in the user section of
' the script window
If (LastOffset = 0) Then LastOffset = GetNextTargetOnsetTime + 120000
Dim timeLeft as Long
timeLeft = LastOffset - GetNextTargetOnsetTime
Stimulus.Duration = Iif( timeLeft > 0, timeLeft, 0 )
' or set Stimulus.Duration as an attribute reference


2) Alternatively, set your stimulus to use Cumulative timing mode,
and set its Duration to 120000. Define FirstOnset in global User
Script as before. Then in inline code at the start of the Procedure, use

' FirstOnset is a global variable which is declared in the user section of
' the script window
If (FirstOnset = 0) Then FirstOnset = GetNextTargetOnsetTime
SetNextTargetOnsetTime FirstOnset

(see the SetNextTargetOnsetTime topic in the E-Basic Help
facility). Now each run of the stimulus will behave as though it
started at the onset of the first run of the stimulus, and end 12000
ms after the start of the first run.


It just depends on whether you prefer to manipulate stimulus Duration
or NextTargetOnsetTime. In any case, given the general principles,
Kate and others should readily figure out the specifics.

I went ahead and attached a demo program for each solution. Thanks
again, Paul, for the great inspiration!

-- David McFarlane
SetTaskDuration_byDuration.es2
SetTaskDuration_byNextTargetOnset.es2

Paul Groot

unread,
Nov 11, 2013, 4:31:51 PM11/11/13
to e-p...@googlegroups.com
ah, of course. Silly mistake, that could have been prevented by just running the example script once :-)

PG. 


--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe@googlegroups.com.

To post to this group, send email to e-p...@googlegroups.com.

Kate Cox

unread,
Nov 11, 2013, 11:39:23 PM11/11/13
to e-p...@googlegroups.com
Thank you both VERY much.
I'm not going to pretend that I 100% understand the script but it was brilliantly easy to add in and it works perfectly.

Nadia Martin

unread,
May 30, 2014, 11:05:36 AM5/30/14
to e-p...@googlegroups.com
Hi Paul and David, 

Can this solution be implemented even with images being pre-loaded?

Thank you, 
Nadia  

David McFarlane

unread,
Jun 9, 2014, 2:36:48 PM6/9/14
to e-p...@googlegroups.com
Nadia,

I cannot think of any reason that pre-loading
images would affect any of this, so please give it a try!

-- David McFarlane


At 5/30/2014 11:05 AM Friday, Nadia Martin wrote:
>Hi Paul and David,
>
>Can this solution be implemented even with images being pre-loaded?
>
>Thank you,
>Nadia
>
>
>
>Le dimanche 10 novembre 2013 21:39:37 UTC-5, Kate Cox a écrit :
>--
>You received this message because you are
>subscribed to the Google Groups "E-Prime" group.
>To unsubscribe from this group and stop
>receiving emails from it, send an email to
><mailto:e-prime+u...@googlegroups.com>e-prime+u...@googlegroups.com.
>To post to this group, send email to
><mailto:e-p...@googlegroups.com>e-p...@googlegroups.com.
>To view this discussion on the web visit
><https://groups.google.com/d/msgid/e-prime/a8891566-53da-4ffb-9385-aa277d9b47bf%40googlegroups.com?utm_medium=email&utm_source=footer>https://groups.google.com/d/msgid/e-prime/a8891566-53da-4ffb-9385-aa277d9b47bf%40googlegroups.com.
>For more options, visit
><https://groups.google.com/d/optout>https://groups.google.com/d/optout.

Hunter Ball

unread,
Oct 28, 2015, 11:24:35 AM10/28/15
to E-Prime
This program worked great for what I was originally doing. However, now I have multiple text displays within the same procedure. So once they make their first response, there are two more responses that need to be made. It will automatically time out the first display (with the inline script provided), but the subsequent objects will not time out until a response is made (meaning that it will continue beyond the set duration until a response is detected).

As Paul mentioned, with multiple objects it gets more complex. Nevertheless, I thought it would be an easy enough fix, yet I have still not been able to make it work. I was using the SetTaskDuration_byDuration program, as it seemed more intuitive with multiple objects and not having to use cumulative timing mode for all the objects. But perhaps the other program might work better? I'm not too proficient with inline scripts, so it has not been very easy. Is there a simple (or difficult) solution for this?

Thanks,
Hunter
Reply all
Reply to author
Forward
0 new messages