Change the SlideObject Correct Response based on Attribute

1,867 views
Skip to first unread message

Caleb J. Picker

unread,
Jan 11, 2011, 9:02:27 PM1/11/11
to e-p...@googlegroups.com
Hello all,

I would just like to post a solution to this problem because I had difficulty finding it.

Just to clarify, the problem is this.  You have a slide object that collects input responses (e.g. TestSlide) with allowable response 'F' and 'J'.  Based on your List object (this presumably houses your stimuli and the correct responses), you have an attribute for correct responses (let's say "CorrectResp").  However, now let's say you have two similar experiments with two different Correct Responses.  In your List object, you might then have two attributes (CorrectResp1 and CorrectResp2).  Each attribute corresponds to a different experiment (say, Expt1 and Expt2).

In an inline (placed before the TestSlide runs), you need to change your 'Correct:' property of your TestSlide based upon which experiment is selected at startup.  One solution I came up with is as follows:

Select Case c.getattrib("Group")
    Case "Expt1"
        TestSlide.InputMasks.Add Keyboard.CreateInputMask("fj", c.GetAttrib("CorrectResp1"),_
        CLng(TestSlide.Duration), CLng("1"), ebEndResponseActionTerminate, CLogical("Yes"),_
        "", "", "ResponseMode:All ProcessBackspace:Yes")
    Case "Expt2"
        TestSlide.InputMasks.Add Keyboard.CreateInputMask("fj", c.GetAttrib("CorrectResp2"),_
        CLng(TestSlide.Duration), CLng("1"), ebEndResponseActionTerminate, CLogical("Yes"),_
        "", "", "ResponseMode:All ProcessBackspace:Yes")
    Case Else
        MsgBox "Set correct response Error!"
End Select

The only way I found out how to do to this was by inputing an attribute within the 'Correct: ' field on the TestSlide object.  I then generated the script, and searched for the line where E-Prime 'sets up' the Slide Object.  From my understanding, what this line actually does is create allowable responses (in this case a keyboard with keys 'f' and 'j'), correct attribute, sets the duration, and then sets up the rest of the properties.  This list is pretty much all of the properties for any given slide object.  The only way to change these properties directly is by using this inline, figuring out which property is which, and then making the adjustments accordingly.

There is also another way.  Instead of creating two attributes, you can have one "CorrectResp" attribute (this way, you will not need to use the above inline).  Then you will need an inline that says the following:

dim y as integer

For y = 1 to List1.Size
Select Case c.getattrib ("Group")
    Case "Expt1"
        If List1.getattrib("Stimulus") = "Property1" then
            List1.setattrib(y, "CorrectResp"), "F"
        Elseif List1.getattrib("Stimulus")="Property2" then
            List1.setattrib(y, "CorrectResp")="J"
        Else
            MsgBox "Set Correct Response Error Expt 1"

Then just repeat this for Case "Expt2"

You just need to place this before you run your testing procedure and set the TestSlide 'Correct: ' Property field to [CorrectResp].

I hope this helps.  If anyone else has more elegant solutions than this (this is admittedly basic), please feel free to post.

Caleb J. Picker

liwenna

unread,
Jan 12, 2011, 6:00:44 AM1/12/11
to E-Prime
Hi Caleb,

Thank's for your explanation!

I'd like to add another way to implement pretty much the same thing in
a different way for those that for some reason or another want to cut
on their use of inlines.

http://images.redial.net/crespbasedonversion.jpg

See the image linked above.
This list contains (among others) the attributes cresp, crespa, and
crespb . The slideobject should be refered to the attribute cresp for
the correctresponse (in the slide object properties fill in [cresp]
for correct response). As one can see cresp is then referred further
to [cresp[version]] . The attribute version can have either value A or
B, so that [cresp[version]] actually means either [crespA] or [crespB]
and thus for cresp the value of either attribute crespa or crespb will
be implemented. The attribute "version" can be a startup
variable(create this in the menu that is found under the e-prime logo
at the top of your experiment tree). Another option, for a simple odd/
even randomisation, is to add an inline with the following two lines
at the start of your experiment:

if c.getattrib ("subject") mod 2 = 1 then c.setattrib "version", "A"
if c.getattrib ("subject") mod 2 = 0 then c.setattrib "version", "B"

This inline will assign value A to the attribute "version" for all odd
subject numbers and version B to all even subject numbers so that you
don't have to manually assign a version at start up.

In addition: when using this the way I did (randomizing the response
buttons, i.e. button 1 for answer a and 2 for answer b in half the
participants and vice versa in the other half) you'll also need to
adjust the instructions based on the assigned version. This is easily
done by creating two states in your instructionslide(s). One state
should be named A and the other state B and contain the according
instructions. In the instruction slide properties fill in [version] in
the box activestate and the program will show either state A or state
B according to the value of "version".

Best,

AW

On Jan 12, 3:02 am, "Caleb J. Picker" <dbzgtfan4e...@gmail.com> wrote:
> Hello all,
>
> I would just like to post a solution to this problem because I had
> difficulty finding it.
>
> Just to clarify, the problem is this.  You have a slide object that collects
> input responses (e.g. TestSlide) with allowable response 'F' and 'J'.  Based
> on your List object (this presumably houses your stimuli and the correct
> responses), you have an attribute for correct responses (let's say
> "CorrectResp").  However, now let's say you have two similar experiments
> with two different Correct Responses.  In your List object, you might then
> have two attributes (CorrectResp1 and CorrectResp2).  Each attribute
> corresponds to a different experiment (say, Expt1 and Expt2).
>
> In an inline (placed before the TestSlide runs), you need to change your
> 'Correct:' property of your TestSlide based upon which experiment is
> selected at startup.  One solution I came up with is as follows:
>
> Select Case c.getattrib("Group")
>     Case "Expt1"
>         TestSlide.InputMasks.Add Keyboard.CreateInputMask("fj", *
> c.GetAttrib("CorrectResp1"*),_
>         CLng(TestSlide.Duration), CLng("1"), ebEndResponseActionTerminate,
> CLogical("Yes"),_
>         "", "", "ResponseMode:All ProcessBackspace:Yes")
>     Case "Expt2"
>         TestSlide.InputMasks.Add Keyboard.CreateInputMask("fj", *
> c.GetAttrib("CorrectResp2"*),_

Caleb J. Picker

unread,
Jan 12, 2011, 4:32:18 PM1/12/11
to e-p...@googlegroups.com
Liwenna,

That is actually quite clever!  So I want to see if I understand this.  See below.

On Wednesday, January 12, 2011 3:00:44 AM UTC-8, liwenna wrote:
Hi Caleb,

Thank's for your explanation!

I'd like to add another way to implement pretty much the same thing in
a different way for those that for some reason or another want to cut
on their use of inlines.

http://images.redial.net/crespbasedonversion.jpg

See the image linked above.
This list contains (among others) the attributes cresp, crespa, and
crespb . The slideobject should be refered to the attribute cresp for
the correctresponse (in the slide object properties fill in [cresp]
for correct response). As one can see cresp is then referred further
to [cresp[version]] . The attribute version can have either value A or
B, so that [cresp[version]] actually means either [crespA] or [crespB]
and thus for cresp the value of either attribute crespa or crespb will
be implemented. The attribute "version" can be a startup
variable(create this in the menu that is found under the e-prime logo
at the top of your experiment tree).
So E-Prime does the following:
1) Select a Trial.
2) Collect a response.
3) Compare the response to [cresp] attribute.  [cresp] is set to the "Correct: " property field of the SlideObject.
4) The [cresp] attribute references [cresp[version]].
5) [version] is resolved based on the startup attribute "version" (c.getattrib("version"), with choices of either 'A' or 'B'.
6) Thus, based on the version, the SlideObject references either [crespa] or [crespb], within the same List1 Object.
 
Another option, for a simple odd/
even randomisation, is to add an inline with the following two lines
at the start of your experiment:

if c.getattrib ("subject") mod 2 = 1 then c.setattrib "version", "A"
if c.getattrib ("subject") mod 2 = 0 then c.setattrib "version", "B"

This inline will assign value A to the attribute "version" for all odd
subject numbers and version B to all even subject numbers so that you
don't have to manually assign a version at start up. 
So E-Prime will take the remainder of the Ss# divided by 2.  If the remainder is 1, then assign version A.  If the remainder is 0, assign version B.
Again, very clever! 
 

In addition: when using this the way I did (randomizing the response
buttons, i.e. button 1 for answer a and 2 for answer b in half the
participants and vice versa in the other half) you'll also need to
adjust the instructions based on the assigned version. This is easily
done by creating two states in your instructionslide(s). One state
should be named A and the other state B and contain the according
instructions. In the instruction slide properties fill in [version] in
the box activestate and the program will show either state A or state
B according to the value of "version".
In the past, I've always created two separate Instruction SlideObjects, but this solution seems less messy and easier to handle.  Thanks! 

Best,

AW

liwenna

unread,
Jan 13, 2011, 6:34:28 AM1/13/11
to E-Prime
At times e-prime turns out to be more clever than one figured before
^.^

Indeed it works just like you describe and actually it works just like
you described already in your first post. Just another way of
implementing the same trick.

The mod - thing can be useful in all kind of situations (i.e. offer a
break after every 40 trials by using a if triallist.sample mod 40 = 0
then... line). The slide-state dependent on an attribute 'trick' is
another thing that I use alot since I figured it out the first time.

best,

liw

On Jan 12, 10:32 pm, "Caleb J. Picker" <dbzgtfan4e...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages