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

Hello!
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).

isoEccentric.py (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]
#etc...

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

isoEccentricText.py (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)