OS (e.g. Win10): Windows 10 PsychoPy version (e.g. 1.84.x): 2022.1.2 What are you trying to achieve?
I am making a two-choice categorization training task for nonhuman primates. They will go through 50 tasks, each task consists of 2 images containing stimuli, and the user will categorize the image as either A or B and then receive feedback. After reaching a criterion of 80% accuracy across the last 50 trials, they should move to the next task containing the next two stimuli/images. Part of my excel sheet can be seen below, it contains the task number, stimul/image, some stimulus information, the correct answer, and Ans which tells the program which polygon in the builder is the correct answer.
I’m not exactly sure how to program it so it moves to the next two rows (next task) in excel after meeting this criterion. Is this something that needs to be done in the loop I have set up, or through custom code?
Any advice is very much appreciated!
Hi @bjackson55, what you could do, is reshape your conditions file to be in the wide format (one row per task, Stim to StimA and StimB, Color to ColorA and ColorB, etc.). Then you could have two routines, one for A and one for B. Around these two routines have two loops: The inner one repeats indefinitely (e.g., 10000 iterations) and needs no conditions file. The outer one takes your conditions file in the wide format and has one iteration. Lastly, after each response, push the .corr variable to an ever-growing array. This array you can then analyze after each repetition of the inner loop to see if your condition to go to the next task is met. If so, you can break out of the inner loop and the next task begins. Hope that helps! Let me know if you need clarification on any of the suggestions.
Thanks so much for your response. I am unsure how to set up the two routines. Currently, I have my Task_stim image, which is the A or B stim, then polygon buttons for A and B responses, my mouse component for selecting A or B, and custom code that tells the program if the mouse is located in the A or B response area to write to a list which rect it was in, and if it matches the list in my conditions sheet, give positive feedback. I do not have a .corr variable because there is no actual key press or mouse click, because I am using touchscreen systems for the animals.
So the issue I’m running into trying the wide format is how to tell the program now which is the correct response without having a column in my excel sheet. Below is how I have changed the program to two routines for A and B. Then is how I had my feedback setup, with Resp being a custom data column with A_rect or B_rect, and AB_Clicked in my excel sheet with the correct A/B_rect answer. Is there a way to change my feedback code to fit this new format?
Is the column “Ans” in the original conditions file specifying which response is correct? I thought you could just divide it into two columns as well, one for each trial of the task.
Just to make sure: Do I understand you correctly that each task consists of two trials, which both have their independent stimuli and correct answer?
Could you maybe upload your experiment and the stimuli, just so I can have a look?
Yes the Ans column is what the feedback code is comparing to to know whether to provide positive or negative feedback. So if the cursor is in A_rect, and Ans says A_rect, its tells them they are correct.
Each task consists of two stimuli. There isn’t a set trial number. The A and B stimuli should randomly appear until the animal reaches an accuracy criterion of 80% correct in the last 50 trials.
Here is what I started with originally. Currently I just have polygon squares set up at my A and B response buttons but they are labeled A_rect and B_rect. TouchCat.zip (209.7 KB)
Ah ok, I see. Then you have to do it a little different. You have to split your conditions file up by task (i.e., have 50 condition files, one for each task, each with two rows). Those get fed to the inner infinite loop in full random mode. The outer loop then gets a new conditions file that goes through the conditions files for the inner loop like so:
TaskFile
Task1.xlsx
Task2.xlsx
Task3.xlsx
...
“TaskFile” is the variable that determines the file used in the inner loop. Like you already do, you can then check your condition after each trial (+ feedback) and finish the infinite inner loop, when it is met. Then the outer loop goes to the next row/task and the next infinite loop begins.
Thank you so much for your help!
For the inner loop, what should I put for nReps? If I leave it blank, I get an error message. If I put 10000, it doesn’t seem to stop even when my criterion is met.
To meet criterion I have custom code creating a list of the score (1 if correct or 0 if incorrect), and then sum the last 10. Then an if statement saying if that sum /10 >=.8 and trial count is 10 or more, finish that inner loop.
Your code looks fine to me, but I don’t usually use Python. So maybe I am missing something. You can try to debug the code by printing all relevant variables during an experiment run. Then you can see which line does not do what it is supposed to do.
****EDIT: I just rewrote the end routine and now it’s working, I must have had an extra space in there somewhere. Thank you so much for your help!
I have tried printing all of the variable in my formula and it shows that everything is working.
I’m wondering if I should put something in my inner loop nReps other than a large number.