Python in opensesame
Hello, I am a student and new to opensesame. I want to use python to calculate a score from the measurements taken. I would like my participant's response in the form to be set as right (1) and false (0) in the excel table.
I have a second question, my experiment contains two loops and I would like only one of them to be executed. I would like the probability to be 50%.
I don't know how to do theses things.
thanks in advance
Comments
Hi @lenalee1,
Your post does not contain enough information for me to suggest a scoring method (you need to specify what the scoring criteria are; For example, is is a serial recall task or a free recall task?). Generally, given how your task seem to be structured, my advice would be to use code to store the word stimuli in an array, then code to parse the string recalled by participants (separating the individual words), and then code to loop through both to calculate your score (e.g., if a correct response is a word recalled in the same serial position as it was presented in, then you'd loop through the R responses, compared them to the S stimuli words, and if you have a match and the index of the elements in each array is the same, then you'd have a correct response for that position).
Alternatively, you could just implement the first two bits of code to make sure to output the presented words and the individual recalled words, and then compute your scoring in Excel using formulas. If you find the parsing of the recalled string in Python or Javascript difficult, you could also output the recalled string to the data output and parse it using formulas in Excel.
Note that your data logging is a little messy. As it stands, the output log saves a single piece of information per row. What you want is to output the information as separate columns on the same row for that trial (otherwise, analyzing your log is gonna turn into a bit of a nightmare).
As for the execution of one loop at random, you could achieve it by using nested loops and setting the "repeat" property of the higher loop to 0.5 cycles. That higher loop should contain 2 rows and a variable to call, for example, "SelectedLoop". On one row, you give it a value of 1 and on the other you give it a value of 2. You can then use this variable in the sequence for the higher loop to set the "Run if" property of the two individual loops accordingly (so that loop 1 will only be run if SelectedLoop = 1, and loop 2 will only be run if SelectedLoop = 2).
Hope this helps!
Fabrice.