| Reference | Downloads | Github

Is there a psychopy function to generate coordinates for iso-eccentric locations in visual search displays?

I am looking for a function that would automatically compute location coordinates for X items (X being an argument of the function) presented at X iso-eccentric locations equally spaced around the central fixation point (or equally spaced around a point Y that would also be an argument fo the function). Ideally, the function should also take an argument Z to specify the eccentricity, and stimulus type (I am planning to present both words and pictures :slight_smile: ).
Many thanks for your help guys!

Hi @jeanne_lusiot, how about this:

import numpy as np
from numpy import (sin, cos, pi)

def isoEccentric(nPoints, radius, yLocs, xLocs):
   """Draw nPoints around a circle with radius and xLocs/yLocs given"""
    degreePoints = 360/nPoints
    angles = np.arange(0,360,degreePoints)
    angles = [convert*pi/180 for convert in angles] # points of circle in radians
    xyss = [[radius*cos(deg)+xLocs,radius*sin(deg)+yLocs] for deg in angles]
    return xyss

xyss = isoEccentric(nPoints=4, radius=100, yLocs=0, xLocs = 0)

This function will provide locations around coordinates defined by xLocs and yLocs, at a distance specified by the radius. You can see the points drawn using ElementArrayStim components - see attached example (if you run, use ‘q’ to quit). (1.4 KB)

1 Like

@dvbridges That is awesome, thanks!! This will work for shapes and pictures. Will this function also work for words as well?

It should work, it will just be a case of defining the positions for each text component. If you create 4 locations in xyss, then you could have four text components that index the position of those coordinates in a list. E.g.,

text1.pos = xyss[0]
text2.pos = xyss[1]

Or, you could define the positions in when you initiate the text component object. E.g., see attached (1.5 KB)

Can this code be reworked so that it does not need to import numpy? and can be used on Pavlovia as an online experiment? It works great in builder but currently not able to initalize online

Hi @Emma1 , yes here is the converted Python function that is compatible with the auto-JS translate. You will need to add Array.prototype.append = [].push; to a separate code component used for JS code only (see Wakefields crib sheet).

def isoEccentric(nPoints=4, radius=100, yLocs=0, xLocs=0):
    degreePoints = 360/nPoints
    angles = []
    radianPoints = []
    xyss = []

    for p in range(0, nPoints):
        angles.append(p * degreePoints)
    for angle in angles:
        radianPoints.append(angle * pi / 180)
    for angle in radianPoints:
        xyss.append([radius*cos(angle)+xLocs,radius*sin(angle)+yLocs] )
    return xyss

xyss = isoEccentric(4, 100, 0, 0)


I am trying to achieve something similar, but I am having some troubles adjusting the code.
I am working in the builder mode and I have a visual search task with a target letter and many distractors letters. I want them to be randomly located at two eccentricities (4.30 deg and 9.07 deg) around the center of the screen (and sometimes in the centre) in different locations, without being overlapped.

Do I just need to create and then specify as many locations in xyss as my stimuli are?
I am not sure that my approach is correct though (as I am not that expert in pyshcopy or python), so any suggestions would be really appreciated :slight_smile:

Thank you in advance for your help :slight_smile: