List of images from spreadsheet is empty / images not displaying

URL of experiment:
https://run.pavlovia.org/jonas.tvedt/cueing/?__pilotToken=1f0e3dad99908345f7439f8ffabdffc4&__oauthToken=a72848ae19ac2a14c3ddc63d93b5490500697d9647b91ac1df508a41d649c62a

Description of the problem:
There is a problem displaying images from a list of file names imported from a spreadsheet.

I am reading in the files from a spreadsheet like this:

stim_dict = new TrialHandler({
psychoJS: psychoJS,
nReps: 1, 
method: TrialHandler.Method.SEQUENTIAL,
extraInfo: expInfo, 
originPath: undefined,
trialList: 'stimuli.xlsx',
seed: undefined, 
name: 'stim_dict'});

…then I use python list comprehension to convert the list of dictionaries to a list of file names. The python code is auto-translated to JS like this:

allstim = function () {
    var _pj_a = [], _pj_b = stim_dict;
    for (var _pj_c = 0, _pj_d = _pj_b.length; (_pj_c < _pj_d); _pj_c += 1) {
        var i = _pj_b[_pj_c];
        _pj_a.push(i["faces"]);
    }
    return _pj_a;
}

When I run the experiment offline i get a list like this:

allstim = ['images/F013C.png', 'images/F013L.png', ...]

However, when the images do not show when I run it online and when I check the console the list is empty.

So, I’m thinking there is problem with geting the values from the list of dictionaries (stim_dict) by the auto-generated method?

Got it! I used this python code:

allstim = [i['faces'] for i in stim_dict]
print('all stimuli',allstim)

…which was auto generated to this JS code:

allstim = function () {
    var _pj_a = [], _pj_b = stim_dict;
    for (var _pj_c = 0, _pj_d = _pj_b.length; (_pj_c < _pj_d); _pj_c += 1) {
        var i = _pj_b[_pj_c];
        _pj_a.push(i["faces"]);
    }
    return _pj_a;
}

…then I added .trialList to the myData object manually:

allstim = function () {
    var _pj_a = [], _pj_b = stim_dict**.trialList**;
    for (var _pj_c = 0, _pj_d = _pj_b.length; (_pj_c < _pj_d); _pj_c += 1) {
        var i = _pj_b[_pj_c];
        _pj_a.push(i["faces"]);
    }
    return _pj_a;
}
1 Like