Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Colour of the stimuli

edited April 2017 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 =
            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?


  • 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())))
Sign In or Register to comment.