| Reference | Downloads | Github

Conditions file parameters missing from data files using Pavlovia

Hello! This is my first time using the forum in any capacity. Please let me know if there is a better sub-forum or format for my issue.

OS: Win 10
PsychoPy version: 3.1.2
Standard Standalone : Y

What are you trying to achieve?:
I’m trying to make sure condition file parameters are recorded in the data files.

What did you try to make it work?:
Ran the program through Psychopy locally and the condition file parameters as well as participant response time and accuracy (keyboard) are recorded in data set. Stimuli appear as indexed via the condition file as well.

What specifically went wrong when you tried that?:
The same program, when run through Pavlovia, does not record the condition file parameters but does record participant response time and accuracy. Accuracy is determined by the condition file and the stimuli would not appear without the program reading the file.

Hi dey.a,

This is a recent issue that the Psychopy/psychoJS developers are working on resolving. There is a hack solution to record your condition file parameters that I reference here.

Until the problem is resolved, you need to put in code manually at the end of the routine within the trial loop to record those trial parameters. You can use a code component for this in the Builder interface or put it into your javascript file after it’s been created. If your TrialHandler object is called trials and you want to record the displayed stimulus via its parameter stim_id, then you would put this code at the end of the routine:

psychoJS.experiment.addData("stim_id", trials.trialList[trials.thisIndex]["stim_id"]);

Hi kevinhroberts,

Thank you for your response and link to the other thread. Manually adding the parameters to the log after the routine seems to be working!

Hi @kevinhroberts

I’m having the same problem, so many thanks for your advice.

I tried your suggestion as JS code in Builder, but this stopped the study running online. I then tried to add the code directly into the JS file as well, which gets the study up and running again, but this hasn’t made any difference to the data files it’s creating. I’m evidently getting something wrong here. I edited the ‘study_name’.js file in the html folder, added the new code in front of the existing ‘addData’ code after each routine and then synced the project again to Pavlovia. Does that sound about right, or did I miss something?

Many thanks,

Hi Katie,

I’m not sure what went wrong with your experiment, it sounds like you were doing things correctly. If you are implementing this through Builder, you would put the JS code in the “End Routine” tab of a code component for the routine that you want to log the variables for.

If you’re putting the code directly into the JS (not generally recommended by the developers) then it should be placed in the function for the end of the routine. For example, I have a routine called “questions” which has this function which I added the recording of two variables, “stim_id” and “stim_type”:

function questionsRoutineEnd() {
  //------Ending Routine 'questions'-------
  for (const thisComponent of questionsComponents) {
    if (typeof thisComponent.setAutoDraw === 'function') {
  psychoJS.experiment.addData('key_resp_2.keys', key_resp_2.keys);
  if (typeof key_resp_2.keys !== undefined) {  // we had a response
      psychoJS.experiment.addData('key_resp_2.rt', key_resp_2.rt);

  //Variables from the spreadsheet to record manually
  psychoJS.experiment.addData('stim_id', trials.trialList[trials.thisIndex]["stim_id"]);
  psychoJS.experiment.addData('stim_type', trials.trialList[trials.thisIndex]["stim_type"]);

  // the Routine "questions" was not non-slip safe, so reset the non-slip timer
  return Scheduler.Event.NEXT;

Did you give the correct name for your TrialHandler? This is the name of your loop in the Builder interface. In the code above, the TrialHandler is named “trials”. You’ll need to change your code according to the name of your TrialHandler.

If this isn’t working for you (though it really should, if implemented correctly!) you can also try what is suggested by the developers, over here

Hi Kevin,

Thanks for your reply. My TrialHandler is also called ‘trials’, so naming shouldn’t be the issue, but reassuring to know I’ve tried the right things. I’ll try setting the version to 3.1.0 (although I’ve been advised previously to use a different version for other reasons) and inserting the code into the JS file again, hopefully one of these will solve things.

Many thanks,

Hi there,

Sorry about this. For what it’s worth, it turns out we had an issue where we were mixing two incompatible versions of the JS code - PsychoPy was outputting code in a way that was only compatible with a previous version of the PsychoJS lib.

We have now fixed the issue for all versions (the PsychoJS lib now handles the issue, whether or not the code exported from PsychoPy was written “correctly”). Your data file should now be collecting the conditions info correctly but let me know if you find any further occurences of this issue and if it has affected you badly for any “real” data collection.

Our apologies for the error

Hello @jon , is there still an issue with getting the onset timings for stimuli to be output into the data files when running the experiment using pavlovia? Having done a few pilot tests, i can only see response timings and can’t seem to find anything to assist with including onset timings in the output…

Hi Stuart,
You should now be seeing onset/offset times in the log files but, yes, they haven’t been added yet to the csv outputs for online studies yet

best wishes,

ahh ok i will check the logs, and come up with a way of combining them into the output csv. Is there any way of amending how the online csv output looks? My csv results have a blank line inserted into the right half of the output, misaligning the output lines and adding in blank lines throughout the output.

Thank you Jon,