Error: unknown resource

URL of experiment:
Unfortunately I don’t have permission to make the code public :frowning:

Description of the problem:
I’ve created a project in PsychoPy Builder. It runs fine locally. I’ve done “Export HTML” in the builder view and uploaded everything to GitLab. When I Pilot the project in Pavlovia, I get this error:

image

My project structure in GitLab is the following:

project
│   myExperiment.psyexp
│
└───resources
│   │   conditions.xlsx
│   │
│   └───stims
│       │   banana.png
│   
└───html
│   │   index.html
│   │   myExperiment-legacy-browsers.js
│   │   myExperiment.js
│   │
│   └───resources
│       │   conditions.xlsx
│       │   
│       └───stims
│           │   banana.png

I’ve checked that the structure of the project on GitLab equals the structure of my project locally.

I’ve tried these proposed solutions from other threads:

  • Starting from scratch in a new git repository
  • Switching the experiment’s status to Inactive then to Piloting again
  • Clearing my browser’s cache
  • Checking for type sensitive file extensions
  • Checking that I use “/” (not “\”) in file paths

Any ideas would be welcome!

Hey @kierad, sorry to hear you are having problems getting your experiment to work as expected.

It might be that you need to manually queue up images and other resources for downloading as the experiment boots up. Could you try amending the psychoJS.start() call in your script as follows?

psychoJS.start({
  expName: expName,
  expInfo: expInfo,
  // Manually populate the resources array, `name` should match
  // the `image` prop in your ImageStim
  resources: [
    {
      path: 'resources/stims/banana.png',
      name: 'resources/stims/banana.png'
    }
  ]
});

I hope that helps some, please feel free to follow up if not.

Hello @sotiri, thank you for solving my issue (and without even seeing the code!).

More information about loading resources can be found here: https://pavlovia.org/docs/experiments/resources

1 Like

Follow-up question:
I’ve solved this issue by manually changing the Javascript (as described in the solution), but this is overwritten each time I export to HTML/sync to Pavlovia. Is there a way of doing this in the Builder so that this overwrite doesn’t happen?

I have tried adding a JS custom code component like this:

psychoJS.downloadResources([
  resources: [
    {
      path: 'resources/stims/banana.png',
      name: 'resources/stims/banana.png'
    }
  ]
]);

But even if this is the first component, it doesn’t seem to load the resources early enough to prevent the “unknown resource” issue.

OK, that is a really good question, please allow me some time to investigate further, thanks for flagging, s.

1 Like

OK with reference to the following figure, if a file path for a given stimulus is statically specified, PsychoPy is smart enough to populate the resources array in JS for you.

As shown below, for anything extra or if dynamically sourcing file paths, e.g. from a spreadsheet, you can go into experiment settings and add those in manually (Thanks @Becca). You can avoid having to worry about psychoJS.downloadResources() playing tricks then.

For your reference, I have created a sample project below,

Is that more or less what you had in mind? s.

1 Like

Correction: as it turns out the latest version of PsychoPy should be automatically populating the resources array in JS from the Builder even if your file names are spreadsheet sourced, but provided their total is within reason :blush: