Assistance needed handling non-responses in loop with multiple conditionals

Hi all,

I am in need of some help with what is likely to be a simple problem for you all.

I am creating a dichotomous choice task for participants – they have 3 practice trials and 50 actual trials to make such choices using the mouse.

The issue I am having is dealing with non-responses. I have the task set up exactly how I would like it, but non-responses on a single trial crash the program. This is due to the fact that there are two conditionals in my loop. The loop routines are as follows:

  1. Make choice
  2. Feedback (choice is highlighted)
  3. Fixation cross

Making things a little more complex, I am designing this for in a neuroimaging study and needed routines 1 and 2 to always have the exact combined duration of 5 seconds, so the duration of routine 2 is set to be the 5 - duration of routine 1.

I also have a snippet of code of course for the feedback section that refers back to the actual choice made via mouse.

These two components are certainly what is breaking things and I am really unsure of how to proceed. You will see below where I have tried to manually supply the duration value for routine 2 if no response occurs, but I still need to figure out how to pass an actual response value (due to no response) to the conditional statement of whether the response was “correct” or not.

The specific error: “AttributeError: ‘NoneType’ object has no attribute ‘contains’”

Code from routine 1:
Begin Experiment tab:

testClock = core.Clock()
timestop=0

Begin Routine tab:

testClock.reset()

End Routine tab:

tRT = testClock.getTime()
thisExp.addData('choiceRT', tRT)
if ((mouse.getPressed()[0]==1) & (testClock.getTime() < 5)):
    timestop=(5-tRT)
    thisExp.addData('fbDuration', 5-tRT)
else:
    timestop=.5
    thisExp.addData('fbDuration', .5)

if mouse.clicked_name[0]==corrAns:
    correct = 1
else:
    correct = 0

thisExp.addData('correct_ans', correct)

Code from routine 2:
Begin experiment tab:

tCol1 = "white"
tCol2 = "white"

Begin routine tab:

if ((rtrial == 0) & (correct == 1)):
    tCol1 = "white"
    tCol2 = "black"

if ((rtrial == 0) & (correct == 0)):
    tCol1 = "black"
    tCol2 = "white"

if ((rtrial == 1) & (correct == 1)):
    tCol1 = "black"
    tCol2 = "white"

if ((rtrial == 1) & (correct == 0)):
    tCol1 = "white"
    tCol2 = "black"

Any thoughts would be helpful!