displaying response count at end of block

359 views
Skip to first unread message

kelsey.lei...@gmail.com

unread,
Jun 5, 2013, 9:47:58 AM6/5/13
to e-p...@googlegroups.com
Hi all,
 In my experiment there is a condition where the subject can choice between two responses (either "n" or "b" key presses). I want to keep track of how many times the participant selects each key (n or b) and present a total for each key type at the end of each block. I've inserted my code here showing how I am counting response selection. As you can see I am setting two separate attributes: c.SetAttrib "total_b" and c.SetAttrib "total_n". I've tried to reference these attributes later in a Text Object, but E prime says, "no such attribute". 

' choice_selection
If ((c.GetAttrib("Cue") = "E") And (currentresponse = ("n"))) Then
count_n = count_n +1 
Else If ((c.GetAttrib("Cue") = "E") And (currentresponse = ("b"))) Then
count_b = count_b +1 
End If
End If

If ((c.GetAttrib("Cue") = "E") And (currentresponse = ("n"))) Then
c.SetAttrib "total_n", count_n 
Else If ((c.GetAttrib("Cue") = "E") And (currentresponse = ("b"))) Then
c.SetAttrib "total_b", count_b 
End If
End If

If there is anything I can clarify please let me know. Thanks for your time and answers.
Best,
Kelsey

free_operant_task

unread,
Jun 6, 2013, 3:55:42 PM6/6/13
to e-p...@googlegroups.com
Hi Kelsey,

Have you defined the attribute globally on the user tab of the generated script? To count across multiple blocks or reference the counter variable at the highest level of the task, you need to define the variable on the user tab of the script. I can send an example scirpt where I have used counter variables like these, if you like.

Hope this helps,
Holly

kelsey.lei...@gmail.com

unread,
Jun 7, 2013, 6:16:33 AM6/7/13
to e-p...@googlegroups.com
Hi Holly,
 Thanks for the question/help.

In the user script I've already written:
Dim count_n As Integer
Dim count_b As Integer
Dim total_n As Integer
Dim total_b As Integer 

During an inter trial interval I set these counters to 0
count_n = 0
count_b = 0

Then of course the script I've posted already which runs during the main body of the experiment.
In the data file I can read something like this:
total_n     total_b
NULL      1
1             NULL
NULL     2

So it is being recorded correctly in the data file.

I hope this information makes  what I'm trying to do clearer.
Best,
Kelsey

Susan Campbell

unread,
Jun 7, 2013, 7:34:53 AM6/7/13
to e-p...@googlegroups.com
Hi Kelsey,

It sounds like you're running into a common problem people have with E-Prime: understanding the difference between variables and attributes. By defining something in the user script, you're declaring it as a variable, not an attribute. Attributes show up in lists and data files; variables don't. You also seem to have a scope issue on the attribute, which is making things more complicated.

What's confusing here is that E-Prime is trying to help you out by creating attributes when you use c.setattrib -- so you now have a total_n attribute as well as a variable, and that's what gets logged in the data file. But that attrbiute only exists in the lowest-level list that's running when E-Prime creates it. I would guess that your attempt to display the counts is outside that list. Alternatively, if you didn't fall into that trap, you're trying to use the variable, which you've actually never assigned a value to.

The first thing to try is to create an attribute in the list that's above the one you're setting the value in (the list that's running when you try to display the value at the end), and then let it set the value in that list. Or you could just keep track of those totals in the global variable you already have (if you don't care about logging as you go) and then log them in an inline after the list.

HTH,
Susan

Reply all
Reply to author
Forward
0 new messages