Having moved all of the visual stimuli to code I’m now getting TypeError: Cannot read property ‘map’ of undefined. Interestingly on my iPhone, I’m getting TypeError: undefined is not an object (evaluating ‘color.rgb.map’) which suggests it’s to do with the colour space. My code for creating the objects is now as follows:
Python
Begin Experiment
tpoints = []
for Idx in range(36):
tpoints.append([.5scaledtargetcos(Idx2pi/36),.5scaledflankersin(Idx2pi/36)])
bg=visual.ShapeStim(
win=win, name=“bg”,
fillColor=(0, 1, 0), fillColorSpace=‘rgb’,
lineColor=(0, 1, 0), lineColorSpace=‘rgb’,
vertices=[[-1,1],[1,1],[1,-1],[-1,-1]]
)
errorrec=visual.ShapeStim(
win=win, name=“errorrec”,
fillColor=[.2,.2,.2], fillColorSpace=‘rgb’,
lineColor=[1,1,1], lineColorSpace=‘rgb’,
vertices=[[.18,.49],[.42,.49],[.42,.40],[.18,.40]]
)
target_3 = visual.ShapeStim(
win=win,
fillColor=“yellow”, fillColorSpace=‘rgb’,
lineColor=“black”, lineColorSpace=‘rgb’,
vertices=tpoints,
pos = [0, voffset],
)
errortext = visual.TextStim(win=win, name=‘errortext’,
text=‘NA’,
font=‘Arial’,
pos=(0.3, .45), height=0.08, wrapWidth=None, ori=0,
color=‘white’, colorSpace=‘rgb’, opacity=1,
languageStyle=‘LTR’,
depth=-2.0);
dart = visual.ImageStim(
win=win,
name=‘dart’,
image=‘dandelion_dart.png’, ori=0, pos=[0,-.35], size=[.25,.25],
color=[1,1,1], colorSpace=‘rgb’, opacity=1,
flipHoriz=False, flipVert=False,
texRes=128, interpolate=True, depth=-4.0)
Begin Routine
points = []
for Idx in range(36):
points.append([.5scaledflankercos(Idx2pi/36),.5scaledflankersin(Idx2pi/36)])
pic = []
dartpos = [0, -.35]
dartsize = [.25,.25]
dartv = [0,0]
dartoldpos=[0,-.35]
inflight=0
drag = [.95,.90]
framecount = 0
for Idx in range(nflankers):
pic.append(visual.ShapeStim(
win=win,
fillColor=flankercolour,
lineColor=“black”,
vertices=points,
pos = [scalecos(Idx2pi/nflankers)(dtarget+offset+dflanker/2),voffset+scalesin(Idx2pi/nflankers)(dtarget+offset+dflanker/2)],
))
bg.setAutoDraw(True)
errorrec.setAutoDraw(True)
errortext.setAutoDraw(True)
target_3.setAutoDraw(True)
for Idx in range(nflankers):
pic[Idx].setAutoDraw(True)
dart.setAutoDraw(True)
PsychoJS
Begin Experiment
sin = function (a) {
return Math.sin(a);
}
cos = function (a) {
return Math.cos(a);
}
pi=Math.pi
win = psychoJS.window
tpoints = [];
for (var Idx = 0, _pj_a = 36; (Idx < _pj_a); Idx += 1) {
tpoints.push([(((0.5 * scale) * dtarget) * cos((((Idx * 2) * pi) / 36))), (((0.5 * scale) * dflanker) * sin((((Idx * 2) * pi) / 36)))]);
}
bg = new visual.ShapeStim({“win”: win, “name”: “bg”, “fillColor”: [0, 1, 0], “fillColorSpace”: “rgb”, “lineColor”: [0, 1, 0], “lineColorSpace”: “rgb”, “vertices”: [[(- 1), 1], [1, 1], [1, (- 1)], [(- 1), (- 1)]]});
errorrec = new visual.ShapeStim({“win”: win, “name”: “errorrec”, “fillColor”: [0.2, 0.2, 0.2], “fillColorSpace”: “rgb”, “lineColor”: [1, 1, 1], “lineColorSpace”: “rgb”, “vertices”: [[0.18, 0.49], [0.42, 0.49], [0.42, 0.4], [0.18, 0.4]]});
target_3 = new visual.ShapeStim({“win”: win, “fillColor”: “yellow”, “fillColorSpace”: “rgb”, “lineColor”: “black”, “lineColorSpace”: “rgb”, “vertices”: tpoints, “pos”: [0, voffset]});
errortext = new visual.TextStim({“win”: win, “name”: “errortext”, “text”: “NA”, “font”: “Arial”, “pos”: [0.3, 0.45], “height”: 0.08, “wrapWidth”: null, “ori”: 0, “color”: “white”, “colorSpace”: “rgb”, “opacity”: 1, “languageStyle”: “LTR”, “depth”: (- 2.0)});
dart = new visual.ImageStim({“win”: win, “name”: “dart”, “image”: “dandelion_dart.png”, “ori”: 0, “pos”: [0, (- 0.35)], “size”: [0.25, 0.25], “color”: [1, 1, 1], “colorSpace”: “rgb”, “opacity”: 1, “flipHoriz”: false, “flipVert”: false, “texRes”: 128, “interpolate”: true, “depth”: (- 4.0)});
Begin Routine
points = [];
for (var Idx = 0, _pj_a = 36; (Idx < _pj_a); Idx += 1) {
points.push([(((0.5 * scale) * dflanker) * cos((((Idx * 2) * pi) / 36))), (((0.5 * scale) * dflanker) * sin((((Idx * 2) * pi) / 36)))]);
}
pic = [];
dartpos = [0, (- 0.35)];
dartsize = [0.25, 0.25];
dartv = [0, 0];
dartoldpos = [0, (- 0.35)];
inflight = 0;
drag = [0.95, 0.9];
framecount = 0;
for (var Idx = 0, _pj_a = nflankers; (Idx < _pj_a); Idx += 1) {
pic.push(new visual.ShapeStim({“win”: win, “fillColor”: flankercolour, “lineColor”: “black”, “vertices”: points, “pos”: [((scale * cos((((Idx * 2) * pi) / nflankers))) * ((dtarget + offset) + (dflanker / 2))), (voffset + ((scale * sin((((Idx * 2) * pi) / nflankers))) * ((dtarget + offset) + (dflanker / 2))))]}));
}
bg.setAutoDraw(true);
errorrec.setAutoDraw(true);
errortext.setAutoDraw(true);
target_3.setAutoDraw(true);
for (var Idx = 0, _pj_a = nflankers; (Idx < _pj_a); Idx += 1) {
pic[Idx].setAutoDraw(true);
}
dart.setAutoDraw(true);
Currently I have to change .append to .push manually every time I change the code, as well as thisExp to psychoJS.experiment. I’m hoping to avoid having to keep changing win to psychoJS.window – my assumption is that I would be getting a different error message if that was the issue.
Best wishes,
Wakefield