Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Colour of the stimuli

JullietteJulliette Posts: 3
edited April 13 in Expyriment

I am implementing Stroop task. Therefore I need to consider a special color for the stimuli ( only for choice 1). Therefore, I have the excel file as follow:

    choice1  choice2  choice 3   color_choice1
             Red         Blue         Red             BLUE
             Green      blue         Red             RED
               .                 .              .                   .

I have the part of code as below:

           t = expyriment.design.Trial()
            stim1 = expyriment.stimuli.TextLine(text=trial[0], position=(0,200), text_size=32, text_colour=trial[3])
            stim2 = expyriment.stimuli.TextLine(text=trial[1], position=(-230,-230), text_size=32)
            stim3 = expyriment.stimuli.TextLine(text=trial[2], position=(230,-230), text_size=32)  
            canvas = expyriment.stimuli.Canvas(size=(600, 600))

I expected as trial[3]="BLUE", it prints stim1 as Red with blue color. But it does not work. Do you have any comment please, how to fix it?

Comments

  • fladdfladd Posts: 52

    Hi Juliette,

    the colour needs to be specified in RGB terms (e.g. [255, 0, 0] for red). To simplify this, we provide constants for common colours in expyriment.misc.constants (e.g. expyriment.misc.constants.C_RED for red).
    So in your particular case, something like this might work:

    from expyriment.misc import constants
    stim1 = expyriment.stimuli.TextLine(text=trial[0], position=(0,200), text_size=32, text_colour=eval("constants.C_{0}".format(trial[3].upper())))
    
    Thanked by 1Julliette

    Florian Krause (Developer)
    http://www.expyriment.org

Sign In or Register to comment.