So in this scenario, after a stimulus display on every trial, participants are prompted to give a response. Participants are only given 2 seconds (due to the prerequisite of the experiment) to give a response. In the below given block of codes, it works when a participant gives a response within the span of 2 seconds. However, if a participant did not provide a response during this time frame, the variable ‘Trespraw’ will contain no data at all. When this happen, it will generate a TypeError: ‘NoneType’ object has no attribute ‘getitem’ error when the script reaches the if statement sections.
Tresp is basically a variable to store the string data to be inputted in the csv file at the end.
Is there actually a way to get Trespraw (event.waitKeys to be specific) to generate something rather than provide a NoneType item when participants weren’t able to provide a response in time? Or could anybody think of a work around solution to this?
Trespraw = event.waitKeys(maxWait= 2.0, keyList = ['up', 'down','left', 'right'], timeStamped=True) Tresp = 'Empty' if Trespraw == 'up': Tresp = 'Up' if Trespraw == 'down': Tresp = 'Down' if Trespraw == 'left': Tresp = 'Left' if Trespraw == 'right': Tresp = 'Right'