psychopy.org | Reference | Downloads | Github

Pavlovia: only download relevant stimuli for participant

It took a while to load, but it’s now html-folder free in a new repository: https://gitlab.pavlovia.org/mdelrio/tempreg

Now it doesn’t seem to load any of the resources though…?

For some reason, it automatically identifies two resource files:

psychoJS.start({
  expName: expName,
  expInfo: expInfo,
  resources: [
    {'name': 'demoPracticeGrating1_1.png', 'path': 'demoPracticeGrating1_1.png'},
    {'name': 'bank-1300155_640.png', 'path': 'bank-1300155_640.png'}
  ]
});

However, it throws the error TypeError: Cannot read property ‘toString’ of undefined, when trying to load demoPracticeGrating1_1.png, so I’m not certain any files are loading correctly.

Do you know what line is giving this error?

Do you have participant in your expInfo dialogue box?

I’ve tried to run this locally and online now - online, it shows the default participant number in the dialogue box, and starts downloading only 2 items immediately. My best guess would have been that the order of events (participant number input and resource loading) is wrong, however it doesn’t appear to be the case in the js file… The error message is referring to one of the first images being presented, so it does seem like the resources are not loading properly.
Oddly, locally the experiment runs without throwing any errors, but it only presents the images for which the png files are “hard-coded” in the image components, the image files specified by the condition file are not presented at all.

The end goal would be to reroute participants from Qualtrics using your web app though, in case that changes the approach to debug this.

Please could you explain how you are going to generate and upload 1320 different png files for every participant, especially if you are using sequential participant numbers.

The idea was to generate sets of images in advance, name these as specified above and store them on gitlab. Each participant would only have to download the files containing their participant number in the file name when they do the task.
This was the working approach, unless I encounter storage problems on gitlab…

What do the images look like? How are they created? I’m just wondering if there is any way of economising.

For example, I recently created an experiment for someone who already created nearly 5000 individual images. I didn’t use any of them, instead using a handful of polygons, text components and one core image (of an aircraft).

This may be a bit more complicated, they are gratings embedded in filtered noise - there is a bit of math involved and some randomly generated numbers, and I would want to be able to reproduce the images exactly afterwards.

Sorry to insist, but I still don’t know why this doesn’t work and I am still getting this error - as far as I can tell, the experiment doesn’t wait for the participant number to be input, cannot download any resources since these are specified based on the participant number, and therefore throws an error immediately.

I realize that I have a lot of images, but the general procedure will be the same even if I am just assigning a new condition file to each participant.

I have uploaded the experiment to a new repository to avoid syncing issues: https://gitlab.pavlovia.org/mdelrio/lemon

Could you please let me know what I am doing wrong?

If you upload your psyexp file here or make your lemon repository public then I’d be happy to take a quick look.

Thank you! The repository is public now.

You have expInfo[‘participant’]=1; in Begin Experiment which will override your expInfo dialogue box.

You are setting

demoGrating1 = ‘demoPracticeGrating’ + str(int(expInfo[‘participant’]) % 4) + ‘_1.png’
demoGrating2 = ‘demoPracticeGrating’ + str(int(expInfo[‘participant’]) % 4) + ‘_2.png’

in Begin Experiment. I would set in Begin Routine (switch exampleGratingLeft and exampleGratingRight to Each Routine)

Yes, I was trying to hardcode it to see if I could get any resources downloaded in some way. I deleted this now (and left the default participant number field in the settings empty), moved the two lines of code to Begin Routine and set the image component to update the image file ($demoGrating1 and $demoGrating2) at every repeat. It still doesn’t seem to download any resources or ask for the participant number, though?

Please could you set it to running and add a few credits so I can see the error for myself?

Done!

I wonder whether the issue is a difference between expInfo[‘participant’] and expInfo[“participant”]

Please add
print(‘single’,expInfo[‘participant’])
print(‘double’,expInfo[“participant”])

to Begin Experiment at the top of cardCode

All set

for (var Idx = 1, pj_a = 5; (Idx <= pj_a); Idx += 1) {
stimuli.push({name:“demoPracticeGrating” + expInfo[‘participant’]+ "
" + Idx + “.png”,path: (“demoPracticeGrating” + expInfo[‘participant’]+ "
" + Idx + “.png”)});
}

Try putting brackets round the code for the names as well as for the paths.

Like this?

for (var Idx = 1, pj_a = 5; (Idx <= pj_a); Idx += 1) {
stimuli.push({name: (“demoPracticeGrating” + expInfo[‘participant’]+ "
" + Idx + “.png”),path: (“demoPracticeGrating” + expInfo[‘participant’]+ "
" + Idx + “.png”)});
}

Doesn’t seem to solve it, unfortunately…

Have you noticed that you get a different error if you finish the credit card too quickly?