psychopy.org | Reference | Downloads | Github

Setting a Prime image in a stop signal task on Pavlovia

URL of the experiment: Pavlovia

Description of the problem: @wakecarter @dvbridges @jon I have designed a stop-signal task (green circle as the stop signal) with 1 practice block and 4 main blocks. It also has a prime image (facial expressions) that comes up after the fixation. This is the sequence of the routine: fixation, prime (face image) on all trials, go signal with X or N, stop signal with a green image on some trials, key response on go trials. The prime image is showing up during the practice block and block 1. However, during blocks 2, 3, and 4, the prime is only set on selected trials. It shows ‘undefined’ on others.

2021-10-04 at 12.14.14

Is there any way to resolve this?

If you want to sometimes show an image and sometimes not the easiest way (avoiding code) is to have a blank transparent png image that you show when you want nothing to be displayed.

@wakecarter But I want the prime image to be displayed on every trial. And the images are random. hence, the code.

prime2 is your image component?

Please could you show a screenshot?

Yes, prime2 is an image component.

What do you have for the image of prime2? Is it set every repeat? What’s in Begin Routine of code_7?

@wakecarter It is set to constant currently. I tried setting it to every repeat but that did not work.

Begin Routine of code_7:
//
document.body.style.cursor=‘none’;

Bcolor = [0.882352941176471, 0.803921568627451, 0.0980392156862746]
win.setColor(Bcolor)

if GNG2[trialN] == 2:
stop2.duration = 0
ssdG = 0
thisExp.addData(‘RaceConditionDelay’, ssdG)
stop2.setAutoDraw(False)

thisExp.addData(“Trial_Number”, trialN);
thisExp.addData(“GnG_1NoGo_2Go”, GNG2[trialN]);
thisExp.addData(“StimXO_1X_2O_”, stimXO2[trialN]);
thisExp.addData(“emotionN_1Angry_2Happy_3Neutral_NoEmot0”, emoId2[trialN]);
thisExp.addData(“EmoStim”, emo2[trialN]);
thisExp.addData(“CorrResp_NoResp0_Left1_Right2”, corrResp2[trialN]);

if GNG2[trialN] == 1:
if emoId2[trialN] == 1:
thisExp.addData(‘RaceConditionDelay1’, ssd1)
thisExp.addData(‘RaceConditionDelay’, ssd1)
console.log(“ssd1”, ssd1);
if emoId2[trialN] == 2:
thisExp.addData(‘RaceConditionDelay2’, ssd2)
thisExp.addData(‘RaceConditionDelay’, ssd2)
console.log(“ssd1”, ssd2);
if emoId2[trialN] == 3:
thisExp.addData(‘RaceConditionDelay3’, ssd3)
thisExp.addData(‘RaceConditionDelay’, ssd3)
console.log(“ssd1”, ssd3);
if emoId2[trialN] == 4:
thisExp.addData(‘RaceConditionDelay4’, ssd4)
thisExp.addData(‘RaceConditionDelay’, ssd4)
console.log(“ssd1”, ssd4);

if stimXO2[trialN] == 1:
goXO2.text = ‘X’
else:
goXO2.text = ‘O’

if GNG2[trialN] == 1:
print(“trial number”,trialN)
print(“image_Prime_NOGO”, eFace[emo2[trialN]-1])
print(“ssd_nogo”, ssd);
stop2.setImage(‘greenimage.jpg’)
prime2.setImage(eFaceNG[(emo2[trialN] - 1)]);
thisExp.addData(“name_file”, eFaceNG[(emo2[trialN] - 1)]);
stop2.setAutoDraw(false);

if GNG2[trialN] == 2:
print(“trial number”, trialN);
print(“none.jpg”);
print(“emo2[trialN]”, emo2[trialN])
print("[(emo2[trialN] - 1 - 12)])", [(emo2[trialN] - 1 - 12)]);
print(“image_Prime_GO”, eFaceG[(emo2[trialN] - 1 - 12)]);
print(“ssd_go”, ssd);
stop2.setImage(“none.jpg”);
prime2.setImage(eFaceG[(emo2[trialN] - 1 - 12)]);
thisExp.addData(“name_file”, eFaceG[(emo2[trialN] - 1 - 12)]);
stop2.setAutoDraw(false);

//

eFaceG[(emo2[trialN] - 1 - 12)] is undefined.

emo2[trialN] is 0 so eFaceG[-13] will only have a valid value if eFaceG has at least 13 elements. Is this the case?

@wakecarter
Yes, eFaceG has 36 elements. I have defined these variables in the Begin Routine of a code component of another routine that precedes this routine.

The issue is that a similar code works in Block 1 but not in blocks 2,3,4.

Try eFaceG[emo2[trialN] - 1 - 12]

I think the issue might be because line 4065 results in an array, not a single number.

I tried this, still not working.
I am using this code in block 1, which works perfectly:

//
if GNG1[trialN] == 1:
print(“trial number”,trialN)
print(“image_Prime_NOGO”, eFace[emo1[trialN]-1])
print(“ssd_nogo”, ssd);
stop1.setImage(‘greenimage.jpg’)
prime1.setImage(eFaceNG[(emo1[trialN] - 1)]);
thisExp.addData(“name_file”, eFaceNG[(emo1[trialN] - 1)]);
stop1.setAutoDraw(false);

if GNG1[trialN] == 2:
print(“trial number”, trialN);
print(“none.jpg”);
print(“emo1[trialN]”, emo1[trialN])
print("[(emo1[trialN] - 1 - 12)])", [(emo1[trialN] - 1 - 12)]);
print(“image_Prime_GO”, eFaceG[(emo1[trialN] - 1 - 12)]);
print(“ssd_go”, ssd);
stop1.setImage(“none.jpg”);
prime1.setImage(eFaceG[(emo1[trialN] - 1 - 12)]);
thisExp.addData(“name_file”, eFaceG[(emo1[trialN] - 1 - 12)]);
stop1.setAutoDraw(false);
//

Try

print('eFaceG',eFaceG)
print('index',(emo1[trialN] - 1 - 12))
print('image',eFaceG[(emo1[trialN] - 1 - 12)])

What does it show at the point of the crash?

Are you removing items from eFaceG (e.g. using .pop)?

This is what the output looks like.

No, I am not removing items, simply using .setAutoDraw.

Please try again using a positive index

print(‘index’,(len(eFaceG)+emo1[trialN] - 1 - 12))
print(‘image’,eFaceG[(len(eFaceG)+emo1[trialN] - 1 - 12)])

I’ve found something that suggests that negative indexes don’t work in JavaScript by default. Small negatives probably work via pre-coded “proxies” but those may not go up to -13.

This is the output:

If negative indexes do not work in JS, how is it possible that one of the blocks is running using the negative indexes up to -13?

I’m afraid I’ve got to the end of my suggestions.

I note that you are still using 2020.1. There have been a number of improvements since then. I’d be happy to fix your bug myself, but it would take me a significant length of time and involve updating to a more recent version.

Hii Surabhi,

Is your experiment giving errors after uploading to “Pavlovia” i.e. online version or it is not working as expected offline too ??
Because that way we can investigate step by step where it went wrong !!

Niket

Hello Niket,

It is neither working offline nor online. However, it’d be enough if it just works online on Pavlovia.

Hi Surabhi,

So if I understood correctly your experiment trial structure looks like this:

  1. Fixation cross
  2. Prime (emotional face)
  3. Go/NoGo signal (either X or N)
  4. Stop signal (green image) + Parallel response window

And these trials are blocked, B_practice, B1, B2, B3 and B4

And the issue is prime image is not showing up on some trials? Am I correct? If yes, there are few missing pieces of info here.

What is the duration for presentation of prime ? and Is length of our trial structure fixed or changes trial to trial ? You can also email me the zipped file too if its alright. (niketag@iitk.ac.in)

Niket