|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 10/25/2007 4:12:06 PM
Posts: 2,
Visits: 10
|
|
| Hi. I am new to e-prime and this is giving me a lot of trouble. heres how my experiment works, its pretty simple; a word is shown for a set amount of time, and if its a living thing, the subject presses any button to respond, and it moves on to the next slide. if the stimulus is not a living thing, he waits until it times out and moves on to the next slide. the challenge is that i need to make it self-paced, meaning that the duration of the current slide should be computed from the response times of the other slides, and above a certain threshold. so if the RT for slide 1 is 4 seconds, is 2 seconds for slide 2, then slide 3 would have a DURATION of 3 seconds, and so on. i know this has to be done via inline code. heres what i have so far: totalTrial = totalTrial+1 Dim theResponseObject As RteRunnableInputObject Set theResponseObject = CRteRunnableInputObject(Rte.GetObject("stimulus")) 'If the assert below fires, then the object named in the line above does not exist Debug.Assert Not theResponseObject Is Nothing 'Enumerate through the response collection 'If any of the responses were made by the keyboard, display 'the statistics to the user. Dim nIndex As Integer nIndex = 1 'Set theKeyboardResponseData equal to the current keyboard response Dim theKeyboardResponseData As KeyboardResponseData Set theKeyboardResponseData = CKeyboardResponseData(theResponseObject.InputMasks.Responses(nIndex))
If Not theKeyboardResponseData Is Nothing Then totalRT = totalRT + theKeyboardResponseData.RT If totalRT / totalTrial > 2000 then duration = totalRT / totalTrial c.SetAttrib "duration", duration End If End If
totalRT, totalTrials, and duration are all global variables. totalRT keeps a running total of each response time, and totalTrials records the number of trials. if totalRT / totalTrial (ie, the average response time) is less than 2000ms a new duration is not set, to keep at least a 2 second presentation time. the math is not important right now. i got most of this code from the examples on this forum, however theres two things that don't work and i can't figure out. 1. Set theKeyboardResponseData = CKeyboardResponseData(theResponseObject.InputMasks.Responses(nIndex)) there is only one input response per trial, i don't need an indexing variable at all. i have tried this with a value of 0, 1, and a few other permutations, but i always get an indexing error. how do i set theKeyboardResponseData for just one run? 2. this is the tricky one. to make the durations variable, i made an attribute called [duration], and in the slide properties, set [duration] = Duration. i also made an extra slide that would print [duration] to the screen so i could debug it. the code above succesfully updates duration with the computed average, and its printed to the screen to verify. however the duration of the actual slide presentation time remains constant as the initial value of [duration]. how can i make this work? thanks in advance for any help.
|
|
|
|
|
Forum Member
      
Group: Forum Members
Last Login: 4/9/2008 3:40:25 AM
Posts: 25,
Visits: 52
|
|
You don’t have to count trials:
Let’s call your response object “target”
Indexing the reaction time of the last trial is not necessary:
Define myVar() as global variable (user script)
myVar(1) = myVar(0)
myVar (0) = c.GetAttrib("target.rt")
myVar(1) is always the reaction time of the last trial.
(It is might useful to set the value of myVar(0) in the user script [2sec or so] otherwise it is 0 for the first trial)
Hth Patrick
Patrick
Randomization: rqube.seifseit.de
Internet: http://eeglab.uni-trier.de
or: http://britz.wordpress.com
|
|
|
|
|
Forum Guru
      
Group: Moderators
Last Login: 10/30/2008 3:23:17 PM
Posts: 127,
Visits: 924
|
|
Hello,
For this type of feature, you can use a Summation object. You can add "observations" to the Summation after each Slide, and then use the built-in methods to calculate the mean. I have attached a sample experiment that demonstrates how the Summation object can be used (note that the sample calculates a mean for subject accuracy, but can be modified to use subject reaction time). Once you have calculated the mean, you can use a bit of script to assign this to the Duration attribute so that the next Slide will be presented for the desired amount of time.
Also, you do not need to enumerate through responses as the script you included is doing. Since you are only collecting a single response, you can just access Stimulus.RT as necessary. For example, after each Slide object that collects a response, you would enter the following script:
MeanRT.AddObservation Stimulus.RT
Note that the script assumes that your Summation object is named "MeanRT" and your response object is named "Stimulus".
Then, at the start of every trial, you can calculate the mean, determine if it is greater than 2000, and then set the appropriate duration value in the Duration attribute:
If MeanRT.Mean > 2000 Then
c.SetAttrib "Duration", MeanRT.Mean
Else
c.SetAttrib "Duration", 2000
End If
You should declare the Summation object globally. This means that you will open the Script window (by selecting it from the View menu or by pressing ALT+5), click the User tab, and then enter your Summation declaration there. Refer to the sample for more information on this, and refer to pages 138-139 in the User's Guide for more information on c.SetAttrib.
Please let me know if you have any further questions.
- Matt
- Matt
PST Technical Consultant
http://pstnet.com
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 10/25/2007 4:12:06 PM
Posts: 2,
Visits: 10
|
|
| you have answered all of my questions. my new code is much more efficient and effective than before. thanks!
|
|
|
|