Converting staircase to interleaved

Hi,
I have a small problem that I am struggling to solve when I am adapting a staircase I have written into an interleaved version with the multiStair Handler. In the previous staircase I had some code for a variable thisCondition, which I don’t seem to have ever defined myself so assume it was imported from somewhere? The following snippet worked fine for the single staircase, but in multiStairHandler I am getting error messages that thisCondition is not defined.

 for thisCondition in stairs:

    
        grating.setContrast(.5)
        grating2.setContrast(.5)
    
    
        Stim = 60 #number of frames the onset delayed stim will appear for. Notice it is constant
        nondelayedStim = thisCondition #total number of advance frames the non-delayed stim will appear for. Expressed as whatever number the staircase spits out.

Please does anyone have any advice on a fix?
Here is a longer snippet of my interleaved stair code if this info helps:

#create staircases
stairs=[]
for thisStart in info['startPoints']:
    #we need a COPY of the info for each staircase 
    #(or the changes here will be made to all the other staircases)
    thisInfo = copy.copy(info)
    #now add any specific info for this staircase
    thisInfo['thisStart']=thisStart #we might want to keep track of this
    thisStair = data.StairHandler(startVal=thisStart, 
        extraInfo=thisInfo,
        nTrials=400, nUp=1, nDown=2,
        minVal = round(threshframes-3), #maxVal=8, 
        stepSizes= [round(threshframes/4) , 1 ])
        #stepSizes= [4,1])
    stairs.append(thisStair)
    
for trialN in range(info['nTrials']):
    shuffle(stairs) #this shuffles 'in place' (ie stairs itself is changed, nothing returned)
    #then loop through our randomised order of staircases for this repeat
    for thisStair in stairs:
        thisIntensity = thisStair.next()
        print 'start=%.2f, current=%.4f' %(thisStair.extraInfo['thisStart'], thisIntensity)
        
        #---------------------
        #run your trial and get an input
        #---------------------
        clock=core.Clock()
        clock.reset()
        stop = 0
        endtime = 10*60 #ends after 10 minutes

    for thisCondition in stairs:

    
        grating.setContrast(.5)
        grating2.setContrast(.5)
    
    
        Stim = 60 #number of frames the onset delayed stim will appear for. Notice it is constant
        nondelayedStim = thisCondition #total number of advance frames the non-delayed stim will appear for. Expressed as whatever number the staircase spits out.
            
        list = [0,1]#Randomly choose which stim will be delayed
        order = choice(list)

Thanks for your help,
Christina

Check out the MultiStairHandler, designed to handle multiple interleaved staircases of various types. For this you use a conditions file (or list of dicts if you prefer) to specify the behaviour of each stair and any additional info that it needs to provide on each trial. I’m afraid it looks like I haven’t written a demo for that but there is example code in the reference for it:

http://www.psychopy.org/api/data.html#multistairhandler

Yes I think making an explicit call to MultiStairHandler will be best for you. Right now you create a number of staircases and then put them in a list ( stairs.append(thisStair) ). Then you loop through the staircases with for thisCondition in stairs and then seem to be treating thisCondition as a number when it is infact a staircase object.

In general, I think you’ve got two loops, one after another, that loop over the same list ( for thisStair in stairs and for thisCondition in stairs ), which doesn’t make a whole lot of sense to me. I think you probably would want to nest the two loops, with the inner loop actually running through the trials in the staircase you loop over in the outer loop?