psychopy.org | Reference | Downloads | Github

Cannot find conditions file in loop

Hi all,

I’ve been trying to put one of my experiments online and have been running into quite a few issues. It’s a relatively simple experiment where two pictures are presented at the same time and then the participant is asked to make a rating on the similarity of the pictures. This is embedded in a loop to display different pictures each time.

I have been able to debug some of the issues, but two major problems remain:

  1. First of all the OK button on the start up screen to enter participant info is greyed out. I know that other people have been running into the same issues and have posted into that thread as well. I have skipped this issue by manually editing out the chunk that disables the button (although I don’t understand what it is caused by) and have been able to move on to the experiment in this way.

  2. After displaying the instructions, instead of displaying the stimuli, it just skips to the end of the experiment and displays the “thank you” message. This is the error message it displays:
    script.js:1146 Uncaught ReferenceError: trials_2 is not defined
    at psychoJS.Scheduler.trials_2LoopEnd [as currentTask] (script.js:1146)
    at psychoJS.Scheduler.run (scheduler.js:106)
    at psychoJS.Scheduler.run (scheduler.js:109)
    at update (scheduler.js:145)

It doesn’t seem to be able to find the conditions file that is in the loop and defined by the scheduler “trials_2”. However, I have made sure to redefine and double check that the scheduler is defined. Here is the code below:

function trials_2LoopBegin(thisScheduler) {
// set up handler to look after randomisation of conditions etc
try {
var trials_2 = new psychoJS.data.TrialHandler(
{
nReps:1,
method:‘random’,
extraInfo:expInfo,
originPath:undefined,
trialList:psychoJS.data.importConditions(‘Color_Behavioral.xlsx’),
seed:undefined,
name:‘trials_2’}
);

  thisExp.addLoop(trials_2); // add the loop to the experiment
  thisTrial_2 = trials_2.trialList[trials_2.trialSequence[0]]; // so we can initialise stimuli with some values
  // abbreviate parameter names if possible (e.g. rgb=thisTrial_2.rgb)
  abbrevNames(thisTrial_2);
  // Schedule each of the trials in the list to occur
  for (var i = 0; i < trials_2.trialSequence.length; ++i) {
    thisTrial_2 = trials_2.trialList[trials_2.trialSequence[i]];
    thisScheduler.add(abbrevNames(thisTrial_2));
    thisScheduler.add(FixTimingRoutineBegin);
    thisScheduler.add(FixTimingRoutineEachFrame);
    thisScheduler.add(FixTimingRoutineEnd);
    thisScheduler.add(StimuliRoutineBegin);
    thisScheduler.add(StimuliRoutineEachFrame);
    thisScheduler.add(StimuliRoutineEnd);
    thisScheduler.add(JitterRoutineBegin);
    thisScheduler.add(JitterRoutineEachFrame);
    thisScheduler.add(JitterRoutineEnd);
    thisScheduler.add(recordLoopIteration(trials_2));
  }
} catch (exception) {
  console.log(exception);
}

return psychoJS.NEXT;

}

function trials_2LoopEnd(thisScheduler) {

var trials_2 = thisScheduler;

// get names of stimulus parameters

if (psychoJS.isEmpty(trials_2.trialList)) { // XXX equiv of : in ([], [None], None)
  params = [];
}
else {
  params = Object.keys(trials_2.trialList[0]);
}

// save data for this loop
thisExp.loopEnded(trials_2);
return psychoJS.NEXT;

}

I’m not very fluent in JS at all, so any help with fixing these bugs would be highly appreciated!

Thanks!
Leyla

As it says in the warning message (when you export the script) psychojs is really not ready for primetime and we aren’t supporting it until we’ve done some more work there. If you aren’t very fluent in JS then I really recommend you use a different package for now

Hi Jon, I’m having a similar problem, but with psychopy. I’ve been following your youtube Stroop Task tutorial step by step, but I’m having trouble getting my conditions file into the loop. I’ve tried .xlsx and .csv but neither are working.

From the builder view, when I hit the browse button next to “conditions,” I can see my files and click on them, but then nothing happens. The conditions area remains blank. I’ve also tried typing the file name in directly and hitting “okay,” but when I open the properties window back up again it just says, "No parameters set (conditionsFile not found). It’s my first time using psychopy and I downloaded the most recent version today. Do you have any advice on this? Thanks!

Other things I’ve tried:
-Deleting the loop and making a new one
-Closing the program and reopening it
-Adjusting the .xlsx file info to open with psychopy
-Adjusting the file so that it’s read/write and fully accessible
-Resaving the file

FYI: I’m using a macOS Sierra Version 10.12.6
I originally created the file in “numbers” and exported it to .xlsx and .csv

Update: I figured out my problem from one of your other responses. It turned out, I had a default header, “Table 1” in my excel that I guess psychopy didn’t understand or was reading as a blank cell.

Headers in your conditions file become variables in the script and so they can’t contain spaces or punctuation, just letters, underscores and numerals (first character can’t be a numeral either)

Hi Jon,

I am not building an online experiment yet but this thread seems like a relevant place to post this question. I am trying to attach an excel .xlsx file but in the loop properties window, the excel sheet is not opening/attaching. The conditions is blank every time I select the file. I’ve tried deleting everything and starting over but I still have the same problem. I’m using the 1.90.2 version if that helps.

@suelynnmah please create a new thread for loop issues that are not about online studies