When setting the image of ImageStim - not html or experiment settings (online) tab issue

OS: Win
Version: 2022.1.1.

Description of the problem: I made a glass pattern discrimination task with three separate feedback conditions (trial-by-trial, block, no feedback) as outer loops. Experiment runs perfectly locally but having issues piloting online.

A lot of my initial errors came from resource errors, and I have been following crib sheet ( PsychoPy Python to Javascript crib sheet 2021 - Google Docs) to correct these.

Having worked through these, I’m now getting another issue with my blank500 routine, which uses a photo of a white cross as a fixation. The image I used locally worked fine, but is presented issues when downloading online. I have changed this image to be a PNG, JPG and TIF file but none of these appear to work. I loaded these in experiment settings → online tab in the builder but this did not work.

I have since been editing the .JS script on the gitlab file to make small adjustments outside of the builder, so my builder save is now lagging behind somewhat and I am reluctant to use it as it might discard all the changes I made to the .JS file (I’m not sure if synching changes from builder will overwrite changes to JS file via gitlab.pavlovia).

I’ve added the new images under

psychoJS.start({
  expName: expName,
  expInfo: expInfo,
  resources: [
    {'name': 'fixation.png', 'path': 'fixation.png'},
    ...

to make sure that they are downloaded. My other stimuli were initially listed as "[stimuliName].PNG’, but piloting online didn’t download these. When I changed it to "[stimuliName].png’, the stimuli downloaded so I have been consistent with this.

When piloting the experiment, I choose the feedback condition to complete (‘t’, ‘b’, ‘n’) and it takes me to the instructions. After hitting space to proceed to the practice run, it gives me this error:

I believe it has something to do with my // Initialize components for Routine "blank500" code, which I have been playing around with:

  blank500Clock = new util.Clock();
  image = new visual.ImageStim({"win": psychoJS.window, "name": "image", "image": "fixation.png", "mask": null, "anchor": "center", "ori": 0.0, "pos": [0, 0], "size": [0.5, 0.5], "color": [1, 1, 1], "colorSpace": "rgb", "opacity": null, "flipHoriz": false, "flipVert": false, "texRes": 128.0, "interpolate": true, "depth": (- 1.0)});
  image = 'fixation.png'
  image = new visual.ImageStim({
    win : psychoJS.window,
    name : 'image', units : undefined, 
    image : 'fixation.png', mask : undefined,
    ori : 0.0, pos : [0, 0], size : [0.5, 0.5],
    color : new util.Color([1,1,1]), opacity : undefined,
    flipHoriz : false, flipVert : false,
    texRes : 128.0, interpolate : true, depth : 0.0 

As you can see, I have tried including the image in the new visual.ImageStim section, and also tried just outright setting image = 'fixation.png' . But I still get the same error message. I acknowledge the name for this image file is not detailed enough (I must have forgotten to change its name when using the builder), but would this make a difference?

I scoured through the discourse topics for similar issues and most seem to be solved by getting rid of the html output (mine never had this) and including the stimuli under the online tab of experiment settings (I have tried this also). I’ve been referring to the crib sheet (i.e. [page 21] (PsychoPy Python to Javascript crib sheet 2021 - Google Docs)).

Any help is appreciated in advance. I’m new to coding so forgive me if there are any simple JS errors here, but I can’t think of what to try next.

Thanks,

Ethan

From my crib sheet:

Don’t
Use simple terms for variables, since they may already be in use by PsychoPy. Variable names to avoid are: class, core, image, index, Length, list, Object, Number, round, sound, Symbol, t, thisTrial, trials, util, visual.

Thanks for your reply, wakecarter.

It is clear that I did not properly consult your crib sheet. I not only had the name as “image” (which I did forget to change within the builder), but I also had some of my image stimuli as .tif files which you also explicitly advised against.

At first I changed the file types to .png and it worked without changing the name of image , but I have since changed the name.

I’m now getting new errors for my feedback routine scripts such as TypeErrors, but these are also discussed in your crib sheet and online so I’ll pay closer attention to these.

Thank you :slight_smile:

1 Like