Changing postion of image/polygon

I am working on experiment, in which I present ratings as bars on a horizontal line. So far I only presented 8 ratings, which represented the ‘average ratings of 8 people’. To do so I draw 8 elements from a given interval and save them to a list. Then in position attribute of polygon for x axis, for each of the ratings I refer to the according element of the list by using: name_of_list[postion_of_element]. The value of y axis is constant. And that was working perfectly :slight_smile:

Now, I want to upgrade my experiment and present 8 ratings for 3 different conditions:

  1. average ratings
  2. maximum ratings
  3. end ratings

But I want each condition to be displayed randomly. So far I managed to change displayed questions for each condition by making a loop and refering to Excel file and it is working. However, I struggle to change the x position of these 8 ratings according to the question that was chosen in each trial. What I want to achieve is to present in random order:

  • question for average ratings and 8 bars (representing ratings) from average ratings list
  • question for maximum ratings and 8 bars (representing ratings) from maximum ratings list
  • question for end ratings and 8 bars (representing ratings) from end ratings list

I tried to add position of rating 1, 2, etc. to my Excel file as new column and refer in each column to the position of the item on according list (eg. visceralratingPlac[0]) and in position attribute refer to such column, but I got the error message that I am trying to use string instead of float.

Is there a possibility to change it to float or maybe there is another way of achieving what I need?
Although I work in Builder, I know a little bit of coding, so making changes in code does not frighten me :slight_smile:

I attach the current Psychopy and Excel files, which work (version with manipulation of questions but without the manipulation of ratings):
manipQuestions.xlsx (9.7 KB) Position change.psyexp (159.3 KB)

Hi,

I’m flying a little blind here, but I think what you want to do is add a new column to your conditions file, called, say condition. This will also ease the analysis procedure somewhat, as it will be explicitly recorded in your data file in the appropriate rows. The value in each row of the condition column should match the corresponding row in the questionManip column, being, say average, maximum, or end.

Then edit the code component on your noceboManip routine to look like this:

# creating intervals for average, max and end rating
if condition == 'average':
    visceralratingPlac = randint(intervalMinPlac, intervalMaxPlac, size=8)
elif condition == 'maximum':
    visceralratingPlac = randint(intervalMinPlacMax, intervalMaxPlacMax, size=8)
elif condition == 'end':
    visceralratingPlac = randint(intervalMinPlacEnd, intervalMaxPlacEnd, size=8)
else: # defensive programming:
    print('Oops! Unexpected condition value.')
    core.quit()

i.e. note you are now just creating a single variable name (say visceralratingPlac), instead of the three you were previously creating. This is so that you can just use that variable name in your polygon stimulus components (which is the current arrangement).

You can now delete the equivalent code in the “end routine” tab of the code component on the start routine. The code above won’t be able to run there, because the variable condition isn’t accessible until the manipQ loop starts.

You might need to make other edits of the code to fit with this sort of system, but hopefully this will get you started.

1 Like

Hi Michael,
thank you for your response! The solution you suggested works perfectly!

1 Like