Getting median RTs in real-time

Brady Anderson bradyjanderson at gmail.com
Thu Jan 9 05:20:04 UTC 2014


As E-Prime (to my knowledge as of posting) doesn't currently have a median 
summation ability, like it does for min,max,mean,etc. I had to come up with 
code to get E-Prime to return median reaction times for doing an FRN 
experiment. The paradigm was to use the median of the subject RTs for the 
first block of a task rest of the task to use as criteria for showing RT 
error feedback. I thought I would share the code I came up with to assist 
those (like in these E-Prime forum threads:http://www.pstnet.com/forum/Topic3559-5-1.aspx?Highlight=median 
and http://www.pstnet.com/forum/Topic3559-5-1.aspx?Highlight=median) who 
want E-Prime to return medians in real-time in a general fashion that can 
be otherwise adapted or referenced.

First for the user script global variables:

'placed in user script tab
dim mediancount as integer
public medianrt() as integer
dim median as integer

"mediancount" is just the counter for populating the array of medianrt(). 
Though the task I did had 40 trials, I'll keep the dimensions undefined in 
case there are non-responses (so it doesn't skew the median, since E-Prime 
records non-responses as 0), and use the redim command to keep the array 
flexible with the following algorithm:

'placed in inline object after stimulus object which recorded response
IF Stimulus.RT <> 0 then
mediancount = mediancount + 1
redim preserve medianrt (mediancount)
medianrt(mediancount) = Stimulus.RT
END IF 

Obviously you can change the criteria after IF to anything you want to be 
included in the array, which gets redefined after each addition. Then I had 
another inline placed after the block but before the rest of the blocks for 
the rest of the trial which actually gets us the median, like so:

'placed in inline object after block of trials that would have the median RT
ArraySort medianrt
IF mediancount mod 2 = 0 then
median = (medianrt(mediancount/2) + medianrt((mediancount/2) + 1))/2
ELSE
median = medianrt((mediancount/2) + .5)
END IF 

'if you want to confirm the median, testing it against the EDAT file if you 
find the median by yourself in an Excel spreadsheet or something to double 
check it
debug.print median

This puts the whole array (which has the stimulus RTs) into numerical order 
with the command ArraySort (which turns gray, by the way), then I use the 
mod (which turns blue) operation algorithim to determine the median. The 
mod, short for modulation, is the remainder after division, so if there's 
all 40 trials, an even number, 40/2 goes into 10 with 0 left over, so 
E-Prime will take the mean between the 20th and 21st members to return the 
median, which here is the integer "median". If there's odd, that's easy, we 
know that since integers can only be even numbers there will be .5 left 
over, and the algorithm will just make E-Prime find the middle number and 
return that value labeled in the array to be our median, which we can then 
reference and manipulate all we want, so to complete the goal I had for the 
experimental paradigm, using the median RT to lower stimulus duration I 
could just do:

'placed in an inline object before the rest of the task hierarchy procedure
c.SetAttrib "StimulusDur", .9*median

and then I could just use [StimulusDur] in the duration field for the next 
stimulus slides, or use it in the recording responses field. This attribute 
and all the variables can of course be changed to anything that makes sense 
to you and works within your experiment. For mine I actually had 
"practrialcount" and "stimdur" instead of "mediancount" and "median", but 
it should work all the same.

Hope this helps anyone out who needs the median like I did. I haven't done 
a time-audit to see how intensive this is on the computer, since for my 
task construction that wasn't really necessary, but I anticipate that this 
would be pretty negligible on most hardware. Let me know if I should post 
my task so it makes more sense in context. 

-- 
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 at googlegroups.com.
To post to this group, send email to e-prime at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/3713ee0b-b9df-4005-8075-176a6eb41b4d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20140108/1bf464bc/attachment.htm>


More information about the Eprime mailing list