Synch from Builder to Pavlovia

URL of experiment: Irene de Caso / Political_bias · GitLab

Description of the problem: I have created an experiment in the Psychopy builder and would like to upload it to pavlovia but I can’t find any good instructions. I have tried selecting sync in the Pavlovia.org tab but it only asks me about changes so that does not seem to be the way.

I have also gone to the online tab in settings and pressed ok in this image

and then gone to file–> export HTML and now I have a folder called html which contains the java files as well as a folder that contains my excel file, though no trace of the images I use in the experiment inside this folder.

I have also created a project in pavlovia which is empty and I create a new file where I simply pasted the java script inside the html file.

Pavlovia is also telling me I wont be able to pull or push anything until I create a SSH file but have no idea what that is.

As you can probably guess I am very new to this and don’t really know what I’m doing. Have never used Github just know a bit of python.

Thanks for your help on any of these bits.

You should be able to press sync from within Builder. I don’t explicitly export the html or sync from Github. If necessary files aren’t getting copies to html/resources when the sync then you may need to copy them there manually.

I’d recommend you look at my crib sheet (see pinned post).

Best wishes,

Wakefield

1 Like

Hey!! Thanks so much for your reply. It took me to Anastasia Sare´s guide which I found really helpful. I am now able to pilot my study in pavlovia and have solved some simple errores in which a variable had to be defined. I consider it a significant advancement but I am stuck again

I am having issues trying to solve an error which I believe is related with the random and shuffle functions.

In my python code snippet I use random.shuffle(). From your crib sheet I see you say there’s usually errors with both Random and shuffle. Am I right to assume that shuffle is not part from Random in Javascript? Assuming this I removed the ‘import random’ and defined var shuffle and then set shuffle = util.shuffle.

I was getting the following error:

TypeError: Cannot assign to read only property ‘91’ of string ‘Agradecido,Adorable,Capaz,Brillante,AlegreCodicioso,Desagradable,Cabezón,Amargado,Antipático’
at shuffle (Political_bias_short_Pav.js:109)
at Scheduler.experimentInit [as _currentTask] (Political_bias_short_Pav.js:131)
at Scheduler._runNextTasks (util-2020.1.js:1093)
at Scheduler._runNextTasks (util-2020.1.js:1096)
at update (util-2020.1.js:1060)

line 109 from my script is:
words_Sanchez = (positive_words.slice(4, 6) + negative_words.slice(4, 6));

and line 131 is an empty line that preceeds
// Initialize components for Routine “trial”

I also tried including a shuffle funcion instead of definining it as a variable but I also get the same error with a number other than ‘91’.

Could you please help me understand what this error means and how to fix it? Here is the link to the experiment in case you want to have a look. https://pavlovia.org/AirenAirens/political_bias

Thank you!

key_resp_3 = new core.Keyboard({psychoJS: psychoJS, clock: new util.Clock(), waitForStart: true});
 

core.Keyboard needs manual translation.

words_Abascal = (positive_words.slice(0, 2) + negative_words.slice(0, 2));
 

You need to use append not + to add lists together.

1 Like

Thank you so much!!! I used arr1.concat.(arr2) and defined the key_resp_3 variable and finally moved on to new errors :slight_smile: I’m having to define many other variables which for some reason are not being created automatically. Is this normal?

My feeling is that variables which are first defined inside loops or conditionals (anything tabbed in Python) need to be given a starting value in Begin Experiment code. Use auto translate for the starting values to avoid using “var” when it isn’t appropriate.

1 Like

Thanks… I’m a bit worried because the variables from the builder related with my routines (i.e, text, image or key_resp) have been defined inside the experimentInit() function, but then when later functions use these variables they obviously don’t find them , so I am removing these variables from the experimentInit() function and instead defining them ‘globally’ (unsure this is the correct term. Basically defining them outside of any function). I am only keeping the variables related with the clock inside the experimentInitt () function.

I am not confident at all at what I am doing and would love to double check that it is not ridiculous and a waste of time before I carry on.

When you say “variables which are first defined inside loops or conditionals (anything tabbed in Python) need to be given a starting value in Begin Experiment code” do you mean that let`s say that for example I have a routine that presents some text that is constant. Do you mean I would need to add a code snippet in that routine and define in the Begin experiment tab:

text= new visual.TextStim({
win: psychoJS.window,
name: ‘text’,
text: ‘default text’,
font: ‘Arial’,
units: undefined,
pos: [0, 0], height: 0.1, wrapWidth: undefined, ori: 0,
color: new util.Color(‘white’), opacity: 1,
depth: 0.0
});
???

To avoid mis-advising you, please could you show my what you mean, e.g. screen shots of components. It sounds like you’re describing doing something more complicated than I was suggesting.

However, I’m now wondering whether you have a component parameter set to constant when it should be each repeat.

1 Like

Hey :slight_smile: Here is the experiment I am trying to run. Pavlovia As you can see, I have commented out of the experimentInit function the defined variables and have pasted them above, outside of any function

Since I have started piloting on pavlovia I have only modified things in the javascript and left psychopy as it was. During for example instructions for example my component parameter is set to constant, but I change this to each repeat in the trials inside a loop.

I would strongly urge you not to edit the js files directly unless your experiment is finished and there is a minor point of customisation (such as the name rules for the data files or the quit message) that can’t be reached from the Builder. You should be able to do everything else with a combination of auto, JS and Both code components.

1 Like

I see. The thing is that my experiment runs without any problems in Psychopy so I thought it was finished and ready to upload to pavlovia but now I find myself having to repeatedly define variables.

The experiment is a simple one.
I begin the experiment with a code component where in the Begin Experiment tab I set and randomise some lists of words from which I will later on select items to be presented inside a text component. Which exact item will be presented in each trial in the text component is defined inside a code snippet with a simple for loop. Then participants have to respond using a rating scale.

The text appears simultaneously with an image component. The image is selected based on if statements related to the text item. See image:

Let’s say I went back to Psychopy. Since it works well there, do you have any idea of what it is I am doing wrong that is giving these issues with the variables? I am having to define clock variables in the javascript in every routine for example setting_conditionsClock = new util.Clock() , or having to set var Components;
and Components = repeatedly. Do you have any idea of what it is I need to change in my psychopy script?

I have the feeling my rating component might be giving me problems too. It’s set to last up to 4s but it dissapears and moves onto the next trial if the person responds within 4 seconds. Here is what I have selected. Do you think this could be giving me problems? I never mention the rating component in my code snippets. Thanks so much for your help.

Have you looked through my crib sheet for aspects that need code_JS or manual translation?

I try to keep as much code on auto as possible.

If it’s working in Builder locally I would definitely go back to there and start the translation process again.

1 Like

Thanks so much for your advice. I have looked at the crib sheet, yes, but I think that the only things I add in my code snippets that seem to need manual translation are the random.shuffle and the thisExp. I have however not applied the changes in the code snippet but applied them directly in the javascript so will get on with that now. I however have the feeling that part of the problems I’m encountering are to do with where in the code snippet I’m writing my code. Will explore a bit more in psychopy. THANK YOU SO MUCH.