Subject is first presented with two target triangles: one pointing to the left, one pointing to the right. I've run into a roadblock with a task and would appreciate any advice from the community! My knowledge of Python is still very limited. It's the best way to debug and capture gotchas.I am using PsychoPy version 1.82.01 in the Builder View. The while loop is ok if you want to animate something but if not, the event.waitKeys() would be much simpler and safer.Īnd lastly, while you try to make this work, use a lot of print statements to check the actual contents of theseKeys and other variables. I'm a bit in doubt about whether you would want to use event.waitKeys() rather than than event.getKeys() in a while-loop, and use the maxWait argument if you want to control waiting time and use a core.Clock() if you want to track timing. Then the increment of currentProb happens automatically and the loop is terminated when it should. So rather than while currentProb <= nProblem: Using for-loops, you don't have to keep track of the current loop number. It really looks like you want to use a for loop rather than a while loop. Response.append(theseKeys) # OBS: pick the first response So do theseKeys = event.getKeys(keyList=)Ĭore.quit() # assuming that re is imported If you have your keyList as above, you KNOW that any non-escape response is one of these so it's unneccessary. TheseKeys is a list and when you do "(x,y,z) in list", it will look for an element (x,y,z) and not any occurrances of x, y and z. Extend the keyList with "escape" - and possibly "enter" which you use later. Here theseKeys can only contain the stuff in keyList so "escape" is never there. Getting responses theseKeys = event.getKeys(keyList=) #PSYCHOPY GET LOOP NUMBER CODE#I cannot write up your complete code but hopefully point out a few things to get you most of the way. #dataFile.write('PID COND PROB ATT TIME RESP\n')Īttempt = 1 #LB = was previously setting to 1 foreverĭataFile.write(attempt-1,attemptresponse,theseKeys,response,correctAns) #output separated by commas Response.rt.append(())Īttempt = 888 #ends and goes to next problemĭataFile.write(attempt,attemptresponse,theseKeys,response,correctAns) #output separated by commas If response = '9999': # was this correct? If len(theseKeys) > 0: # at least one key was pressed #continually redraw text onscreen until return pressedĪnswer = visual.TextStim(win, text=response,color="black",pos=(0,-100)) #otherwise, take the last letter off the string #if key isn't backspace, add key pressed to the string #elif minutesleft.status = STARTED and t >= (0.0 (600-win.monitorFramePeriod*0.75)): #most of one frame period left # keep track of start time/frame for later #PSYCHOPY GET LOOP NUMBER UPDATE##if timer.status = STARTED: # only update if being drawn While currentProb = (0.0 (600-win.monitorFramePeriod*0.75)): #most of one frame period left I didn't include the libraries and other setup. There is no error message that is returned, but rather, the code does not register the response and thus the task is frozen in place at the prompt screen. This is my first time using Python and I can't work out the kinks in the code. Loop 3: if the response is correct, then say "correct" and move onto the next problem else, say "incorrect" and ask if they would like to try again or move on Loop 2: allows up to 3 attempts per problem The structure should be something like this. How do you do this though? The task will ultimately involve 4 math problems, and participants will be allowed to have up to 3 attempts for each problem. I am trying to use the Coder view to make an experiment that involves feedback and multiple conditional statements.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |