Does it work if you try the following?
sq_1.setFillColor(colors[0])
Does it work if you try the following?
sq_1.setFillColor(colors[0])
Hello, I hope all is well!
I was now trying your last suggestion (sq_1.setFillColor(colors[0])) I tried this:
so in this case I am not sure if how I wrote the code is correct.
Do you think, instead of writing numbers from 0-18 in the spreadsheet, if I write the names of the colors I defined in the code (e.g., blue_bright, cyan_vibrant), would that work?
I didn’t work on this in the last few days and psychopy in the background was closed for some reason, so now when I logged in to continue and synced to see if the adjustment worked, it asked me to create a new project and I got : ’ stdout: ‘On branch master
nothing to commit, working tree clean’’ then, I deleted the git folder and tried to sync with a new project, but I first got ‘no git’ then same working tree clean error.
How should I proceed?
Thank you so much for your guidance!
Do you have the text broght_blur in your spreadsheet instead of the index number?
hi, what is that mean? no, I had numbers but then later on I tried entering the names of the colors to the spreadsheet like ‘blue_bright’ that didn’t work as well.(i see squares all black) what do you recommend? also for the test trial where only one square should change color, does this making sense:
thank you very much!
Also I would use randint(len(test_colors)) to generate a random index. randint(5) generates numbers 0-4
Once you have a list of colours called colors why are you creating lists called test_colors and updated_colors?
Please try using .setFillColor() instead of .fillColor =
that was for the test trial, in this trial my goal was the change only one color. is that still wrong?
right now, i can see same squares showing for both initial and test trial so that works, in test trial participants should click to which square they think changed color (its currently all black) and also apparently not every square can be clicked. this is how the routine and mouse component looks (first polygon is the fixation cross so i didn’t include it)
hello, now that my goal is to get colors i defined in the code from the spreadsheet, i thought this is unnecessary ![]()
what do you think about this approach? thank you so so much!
Enumerate hasn’t translated and I’m not sure this approach will work. Try
sq_1.setFillColor(colors[square_1_color])
sq_2.setFillColor(colors[square_2_color])
sq_3.setFillColor(colors[square_3_color])
sq_4.setFillColor(colors[square_4_color])
sq_5.setFillColor(colors[square_5_color])
sq_6.setFillColor(colors[square_6_color])
where your polygons are called sq_x, the list of colours is called colors and the spreadsheet columns are called square_x_color.
thanks! but that didn’t work also:( is there another way?
I was thinking if I create 50 sets of squares(trial number) in polygon properties, I could enter the code of the color with no problem, and in the test trial, same set of squares will be created and in the code component would this work (for test colors I would write the numbers of the colors as in your spreadsheet instead of blue_bright etc) :
Please have a look at the demo I’ve just written for you.
Using the left and right arrow keys or my clicking on the polygon, select the square that matches the given colour. One colour is chosen based on a numerical index in a spreadsheet. The other is a random other colour.
col2 = (Colour + 1 + randint(6))%7
if corrAns == 'left':
polygon_left.setFillColor(colours[Colour][1])
polygon_right.setFillColor(colours[col2][1])
else:
polygon_right.setFillColor(colours[Colour][1])
polygon_left.setFillColor(colours[col2][1])
I would not recommend combining schemes…there is no expectation that a colour from one scheme will be distinct from colours in a different scheme.
Thank you soo much, this is so cool! Now that my goal is to have 6 squares with only one of them changing in the test trial, I couldn’t figure out how I would adapt your demo to my own. I thought at first I should focus on making sure the colors are shown and I realized I didn’t write the colors like you, so I changed them. But unlike you, I entered the name of the columns in the polygon properties (like $square_1_color on set every repeat) because there will be 50 trials and I wanted to adjust all of them via spreadsheet. Then I deleted the name of the column and left it as default but this time I got an error. Then I focused on the test trial of how you get one of them random and of them from spreadsheet, it makes so much sense, however, how would I make sure the initial trial and test trial are exactly the same with only one changing with that code and for 50 trials, ( I am trying to create this task : change_localization [PsychoPy] )
How do you think I can proceed from here?
thank you so much! I made extreme progress thanks to your guidance!!
I’m not clear what bit you’re struggling with. I’ve changed my demo so that one square is set in code and the other is set each repeat (also from the spreadsheet). Then I change the colour of one of the two squares to a random new colour – which can be the same as the other square.
If I was creating an experiment like this then I might shuffle a list of 7 colours each trial, use six of them to colour the squares and then change one of them to the 7th colour. The spreadsheet might contain the number of the square to change but wouldn’t have the colours at all.
It seems excessively complex. You said it didn’t work and I couldn’t unpick exactly why.
Got it! thank you. - I just looked at the demo and trying to understand how I would adapt it to mine…so I created colors and defined their numbers just like you did. For shuffling I think I can use shuffleArray(colors) in begin routine but this would bring a random color and how would I know which one was selected so that I can avoid using it for applying these to the 6 squares for the next step : setfillColor…
Do you want your 6 squares to be 6 different colours and then for one of them to change into a 7th colour?