Randomly assigning colors to texts


Author
Message
mariela
mariela
Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)
Group: Forum Members
Posts: 14, Visits: 25
Dear all,

I have another question in regards to my experiment:
In my experiment I have 4 blocks of stimuli items. Now I would like to randomly assign 1 of 4 colors to the blocks.

I tried to do this by defining a value label and then put the <%value.color_1%> into the elemtnes defining the text:

<values >
/ color_1=noreplace((10,10,0),(0,10,10),(10,0,10),(10,10,10))
</values>

<text A> 
/ items = A
/color = <%values.color_1%>
</text>

<text B>
/ items = B
/ color = <%values.color_1%>
</text>

<text C>
/ items = C
/color = <%values.color_1%>
</text>

<text D>
/ items = D
/color = <%values.color_1%>
</text>

Unfortunately this is not working. The message list errors tells me that "Expression '<%values.color_A%' is invalid. Expression contains a syntax error."
Can you help me with this task? Is it correct to assign colors by using the value-function?

Thank you so much in advance!!



Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 103K
Your syntax is invalid on multiple levels -- it won't work like that. What you need to do is

(1) Set up a <list> for each color channel (R, G, B)

(2) Set up proper dependencies between the <lists>, and

(3) Set the <text> elements' color via their textcolorblue, textcolorgreen and textcolorred properties:

<block myblock>
/ onblockbegin = [text.mytext.textcolorred=list.r.nextvalue;
    text.mytext.textcolorgreen=list.g.nextvalue;
    text.mytext.textcolorblue=list.b.nextvalue]
/ trials = [1=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("R=<%text.mytext.textcolorred%> G=<%text.mytext.textcolorgreen%> B=<%text.mytext.textcolorblue%>")
</text>

<list r>
/ items = (255, 0)
/ selectionmode = random
</list>

<list g>
/ items = (128, 255)
/ selectionmode = list.r.currentindex
</list>

<list b>
/ items = (0, 128)
/ selectionmode = list.r.currentindex
</list>

The colors in the above example are (255,128,0) and (0, 255, 128).

mariela
mariela
Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)
Group: Forum Members
Posts: 14, Visits: 25
Thank you very much for your quick reply and syntax!
I'm sorry to bother you once again, but as I just started to use Inquisit I am still finding it difficult to apply a generalized syntax to my experiment.
Maybe I need to specify my objective a little further - because from your solution, the resulting color is defined by the elements in your list (I hope I didn't get that completely wrong) and I wonder how I can implement your solution into my setup ...

So, what I'd like to do is: I have four sets of items describing a certain objects:

Object 1 - described by 6 items (e.g. object 1 is yellow, object 1 is warm, ...)
Object 2 - described by 6 items
Object 3 - described by 6 items
Object 4 - described by 6 items

No I have defined a trial for each object with a timeout.

In my final block I defined that 28 items should be randomly selected from the 4 object trials (I used the noreplace-command).

In addition I now would like to randomly assign text colors to the different object trials. E.g. all items for object 1 are displayed in one color, all items for object 2 are displayed in a different color etc. And I'd like to define the possible colors that can be used.

My syntax currently looks like this:


<item object1>
/ 1 = "object 1 is yellow"
/ 2 = "object 1 is warm"
/ 3 = "object 1 is far away"
</item>

<item object2>
/ 1 = "object 2 is blue"
/ 2 = "object 2 is cold"
/ 3 = "object 2 is close"
</item>

<text object1> 
/ items = object1
</text>

<text object2> 
/ items = object2
</text>

<trial object1> 
/ stimulusframes = [1=object1]
/ timeout = 2000
</trial>

<trial object2> 
/ stimulusframes = [1=object2]
/ timeout = 2000
</trial>

<block objects>
/ trials = [1-6 = noreplace(object1, object2)]
</block>

Does your syntax still apply in this situation or do I need to do something different?
Thank you for your help, I really really appreciate it.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 103K
> Does your syntax still apply in this situation or do I need to do something different?

Yes it does, it's the same thing:

<block myblock>
/ onblockbegin = [text.object1.textcolorred=list.r.nextvalue;
    text.object1.textcolorgreen=list.g.nextvalue;
    text.object1.textcolorblue=list.b.nextvalue]
/ onblockbegin = [text.object2.textcolorred=list.r.nextvalue;
    text.object2.textcolorgreen=list.g.nextvalue;
    text.object2.textcolorblue=list.b.nextvalue]
/ trials = [1-4=noreplace(object1trial, object2trial)]
</block>

<trial object1trial>
/ stimulusframes = [1=object1]
/ validresponse = (57)
</trial>

<text object1>
/ items = object1items
</text>

<item object1items>
/ 1 = "Hi, I'm Object1. My color is R=<%text.object1.textcolorred%> G=<%text.object1.textcolorgreen%> B=<%text.object1.textcolorblue%>."
/ 2 = "Hey, it's Object1. The color is R=<%text.object1.textcolorred%> G=<%text.object1.textcolorgreen%> B=<%text.object1.textcolorblue%>."
</item>

<trial object2trial>
/ stimulusframes = [1=object2]
/ validresponse = (57)
</trial>

<text object2>
/ items = object2items
</text>

<item object2items>
/ 1 = "Me, I'm Object2. The color is R=<%text.object2.textcolorred%> G=<%text.object2.textcolorgreen%> B=<%text.object2.textcolorblue%>."
/ 2 = "Hello, it's Object2 speaking. Observe my color R=<%text.object2.textcolorred%> G=<%text.object2.textcolorgreen%> B=<%text.object2.textcolorblue%>."
</item>

<list r>
/ items = (255, 0)
/ selectionmode = random
/ selectionrate = always
</list>

<list g>
/ items = (128, 255)
/ selectionmode = list.r.currentindex
/ selectionrate = always
</list>

<list b>
/ items = (0, 128)
/ selectionmode = list.r.currentindex
/ selectionrate = always
</list>

mariela
mariela
Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)Distinguished Member (2.8K reputation)
Group: Forum Members
Posts: 14, Visits: 25
Thank you thank you thank you thank you - it works excellent!!!

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search