| Reference | Downloads | Github

Getting the clock to end a routine after a set period of time

Hi again,

Progress is good! Now I am trying to set a time limit on my staircase routine of 10 minutes (actually you will see in the code it is for 1 minute at the moment whilst I try and fix the code, but please ignore that).

There must either be something wrong with my clock code, or maybe is it in the wrong loop?
The programme runs fine, but is not stopping after 1 minute as I would have hoped.
Here is the relevant bits of my code:

stop = 0
endtime = 1*60 #ends after 1 minute

for thisCondition in staircase:
    #t1 = trialClock.getTime()

    correctStim = 6 #number of frames the correct stim will appear for. Notice it is constant
    incorrectStim = correctStim + thisCondition #number of frames the incorrect (long) stim will appear for. Expressed as correctStim frames + whatever number the staircase spits out.
    list = [0,1]#Randomly choose which stim will come first
    order = choice(list)

    if order == 0:#correctStim will be first
        correctResponse = 1
        for frameN in range (7):

etc. as stimuli are presented…

    #get response
    while thisResp==None:
        for thisKey in allKeys:
            if (thisKey=='1' and correctResponse==1) or (thisKey=='2' and correctResponse==2):
               thisResp = 1#correct
                print ("correct")
            elif (thisKey=='1' and correctResponse==2) or (thisKey=='2' and correctResponse==1):
                thisResp = 0#incorrect
            elif thisKey in ['q', 'escape']:
                core.quit()#abort experiment
    #t2 = trialClock.getTime()
    #rt = t2 - t1
    staircase.addResponse(thisResp, thisCondition)
    dataFile.write('%i	%i	%i	%i\n' %(correctResponse, correctStim, incorrectStim, thisResp))
    finish = clock.getTime()
    if finish>endtime:
        stop = 1
    if stop==1:
        continueRoutine = False

Can anyone spot what I have done wrong please?
Thank you!
Christina x

You’re ending your Routine when the clock runs out. What you need is to end the staircase loop. I think you’ll be able to do that with staircase.finished=True rather than continueRoutine = False

Oh I see!
staircase.finished=True is having the desired effect, only now I get a strange runtime error that I had not been encountering up until now:RuntimeWarning: overflow encountered in power
yy = self.expectedMin + (1.0-self.expectedMin)*(1-numpy.exp( -(xx/alpha)**(beta) ))
Please could you possibly explain what this means?
Thanks again,