URL of experiment: https://run.pavlovia.org/aelreym/concurrent_schedule_task/html
Description of the problem:
I am trying to assign the participants to one of two conditions at the beginning of my experiment by displaying a different image. I have added the function “shuffle” in a code component and this works in the Builder interface but seems not to work online. I don’t get any error message online but it displays always the same image (the first one in the list). Does anyone see something that may solve that?
Is there also away to save data about which image has been displayed? I have tried something like
but I don’t know what I should add in the brackets so that it saves the infos I am looking for.
@aelreym, the auto-translate is not using the correct output on this occasion. If you switch your code type to “both”, then you can use PsychoJS built-in shuffle function:
imglist = [1,2,3]
util.shuffle(imglist) // shuffles in place
Thank you @dvbridges And do you know how I can save some data about which image from the list has been shown?
You would use something like the following, but it depends on which item in the list you are presenting:
psychoJS.experiment.addData ('imageName', imglist)
Perhaps it would be better to use a loop to handle how your conditions are presented, and what data is saved?
Thanks. I think this is sufficient because the participant is assigned to one and the same condition for the whole experiment and I get this information through your code. This was just to assign different participants to different conditions.
hi, I’m new to psychopy and python. And I am curious where I should put pictures that I want to show?
Because I see the ‘imglist’ in your code component but I have no idea where the pictures is?
I have saved them in the same folder than the experiment, this is enough If you do it in the builder.
If you run your experiment online you should have them in the same folder than your experiment and in the folder html under “resources” but this should be done automatically when you export the experiment.
Hello, I have another question:
I would like to display two different texts in the routine before according to the image they were assigned to in the shuffle function. Do you have any idea how I can code this? Should I put some code in the text component directly or in a code component?
is in the tab “begin experiment” but one routine later than the routine with the text component, does it matter or not? I am asking because I am confused between the tab “begin experiment” and the sequence of the code.
Thank’s for your answer!
Just a suggestion as I am also a newbie in PsychoPy. Does the images you are presenting have certain properties that you will assign them with different texts? I am assuming no for the answer I am providing below.
Name a list of number of 0s and 1s (the total number of 0 or 1 is the total number of images I suppose) in the
begin experiment section, for instance:
assignList = [0, 0, 0, 1, 1]
Then, according to whether the index of the image presented in the
assignList corresponds to 0 or 1, you can write a if-else statement to decide which text to present.
If you are confused about the sequence of the
begin experiment in each routine, maybe you can create a new routine at the beginning of the workflow and put all the code into the
begin experiment in this routine.
I am not sure if these will be helpful for you, hope you can debug successfully.
Hi @Kuriko and thanks for your input.
Yes I have already named this list, but I don’t know how to formulate the if-else statement you are talking about to decide which text to present.