psychopy.org | Reference | Downloads | Github

Generating a flanker display with letters: spacing issues

Hello,

I am currently coding a flanker task with letters (HHHHH, SSSSS, SSHSS, HHSHH). I also want to manipulate the spacing between letters. To this aim, I coded each letter separately, and created a variable called “spacing_letters” that determines the distance from center to center between two adjacent letters:

height_letters = 0.6
spacing_letters = 0.4

target_S = visual.TextStim(win=win, ori=0,
text=u’S’,
font=police,
pos=[0, 0],
color= [0,0,0], colorSpace=u’rgb255’, height = height_letters)

flanker_H_left_1 = visual.TextStim(win=win, ori=0,
text=u’H’,
font=police,
pos=[-spacing_letters, 0], height=height_letters,
color=[0,0,0], colorSpace=u’rgb255’)

flanker_H_left_2 = visual.TextStim(win=win, ori=0,
text=u’H’,
font=police,
pos=[-2*spacing_letters, 0], height=height_letters,
color=[0,0,0], colorSpace=u’rgb255’)

flanker_H_right_1 = visual.TextStim(win=win, ori=0,
text=u’H’,
font=police,
pos=[spacing_letters, 0], height=height_letters,
color=[0,0,0], colorSpace=u’rgb255’)

flanker_H_right_2 = visual.TextStim(win=win, ori=0,
text=u’H’,
font=police,
pos=[2*spacing_letters, 0], height=height_letters,
color=[0,0,0], colorSpace=u’rgb255’)

flanker_H_left_2.draw()
flanker_H_left_1.draw()
target_S.draw()
flanker_H_right_1.draw()
flanker_H_right_2.draw()
win.flip()
core.wait(20)

Giving the following display:

Capture_Arial

As you can see, the distance edge to edge between S and H is not the same that the distance between H and H. Also, the width of letters H and S appears slightly different. How can I create a better flanker display (same width and height for H and S, same distance from edge to edge)?
Thank you very much for your help!!

You could try a monospaced font such as Courier.

Also, are you sure you need the Coder? For a simple flanker task, the Builder might be a more straightforward solution.

Finally, it might not be necessary to draw each letter individually. You could simply define them as text strings such as HHSHH (or you could have a separate target and combine all flankers).

Hope this helps.

Jan