Staircase handler up vs. down step sizes

529 views
Skip to first unread message

Jade Silver

unread,
Oct 19, 2013, 1:23:22 PM10/19/13
to psychop...@googlegroups.com
Is there any way to set different stepsizes for the Up and Down steps using the staircase handler? As far as I can see, you can either use one value for both, or an array that needs to be the same size as the # of trials (which isn't an elegant solution for this imo).

I solved this by setting my own up and down stepsizes and modifying the stimulus manually (bypassing that part of the staircase handler), but it would be handy if the handler did this automatically.

v1.78.01

Thanks,
jade

Jonathan Peirce

unread,
Oct 21, 2013, 1:37:47 PM10/21/13
to psychop...@googlegroups.com
At the moment you can set a single value or a list for adaptive step
sizes. The step size refers to both directions of step. You can alter
the up/down ratio to home in on different parts of the staircase though.
The commonly used staircases home in on a 2AFC threshold using a 1-up,
3-down staircase, or on a 1-up, 1-down staircase to find a PSE.

If you do give a list of step sizes, this shouldn't be the length of the
entire trial set. Each successive value only gets used at a reversal.
This is designed for the common approach for reducing the step size each
time the staircase reverses so as to home in quickly on the rough area
of the threshold and then use smaller steps once you're close.

does that help?
Jon
> --
> You received this message because you are subscribed to the Google
> Groups "psychopy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to psychopy-user...@googlegroups.com.
> To post to this group, send email to psychop...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/psychopy-users/5be95120-fbc6-4621-a4c2-854f04af6536%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk/

Jade Silver

unread,
Oct 21, 2013, 1:48:36 PM10/21/13
to psychop...@googlegroups.com
I wanted to use different step sizes for up and down separately as per Garcia-Perez (using 1 up / 1 down with a single stimulus), "Yes-No Staircases with Fixed Step Sizes: Psychometric Properties and Optimal Setup," Optometry & Vision Science, 2001, 78, 56-64.

OK, I understand the utility of changing stepsizes in the beginning, makes sense. :)

Thanks,
Jade

Jonathan Peirce

unread,
Oct 21, 2013, 2:03:48 PM10/21/13
to psychop...@googlegroups.com
OK, you'd have to implement your own for that, which might be a subclass of the main StairHandler (the same way the QuestHandler is a subclass). That way you only have to write the code for the altered updating rule.

I personally stick to the steps being the same in the two directions. The Garcia-Perez (2011) concern that this might not home in exactly on a particular % correct point doesn't worry me a great deal because I tend to do the analysis using a curve fit to the entire dataset rather than taking average of reversals.

all the best,
Jon

For more options, visit https://groups.google.com/groups/opt_out.

A Kumcu

unread,
Oct 21, 2013, 2:16:23 PM10/21/13
to psychop...@googlegroups.com
I see... I tried running the staircase analysis demo script on some test data using my contrast numbers but it gave a really strange result, and I didn't look into it further.

Guess I should learn how to do psychometric fitting then! ;)

thanks
jade


--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/PQwxOHsU6RA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.

To post to this group, send email to psychop...@googlegroups.com.

Jonathan Peirce

unread,
Oct 21, 2013, 2:57:14 PM10/21/13
to psychop...@googlegroups.com
The curve fitting improved in psychopy.data a great deal over the summer. Basically I switched it from using a minimisation routine to an analytic (nonlinear least-squares) method which is considerably faster and won't go crazy if your data is a bit noisy.

So if your previous look was a while ago have another look now and do let me know if you still ever get odd-looking fits.

cheers,
Jon

For more options, visit https://groups.google.com/groups/opt_out.

Jade Silver

unread,
Oct 21, 2013, 7:33:57 PM10/21/13
to psychop...@googlegroups.com
Hi Jon,

I'm using the pyschopy demo (JND_staircase_analysis) to run an analysis of the staircase experiment (with some test data). The psychometric fit doesn't really seem to work (though again, I haven't looked into how the fitting function works myself, so I just ran it blindly).

PsychoPy v1.78.01. I'm a newbie, only been running PsychoPy for 2-3 weeks now.

In attachment you can find:

- output from the staircase (psydata)
- the output from the psychometric fitting using the pyschopy demo  (jpg file)
- an extract of the staircase code I'm using


Thank you very much for all your help. :)
Jade
test_20131022010654.psydat
test_20131022010654_code.txt
test_20131022010654_psych_fit.jpg

Jonathan Peirce

unread,
Oct 22, 2013, 7:51:52 AM10/22/13
to psychop...@googlegroups.com
Hi Jade,

OK, your message prompted me finally to update that demo code to do the analysis more easily. The attached code generated the attached figure (from your own data).

I think the reason you were having trouble is to do with the settings for expected 'threshold' (0.8 for 2AFC task, 0.5 for a PSE or Y/N task) and the expected minimum (0.5 for 2AFC and 0.0 for Y/N task). I've added those to the top of the script so it's easier to switch them according to task.

I've also set the script to fit using each unique staircase level, and then vary the size of the points in the figure to reflect the number of samples at that level. That's better practice and makes for an informative graph. (I've also added in that the fit should be weighted by the number of points collected at that level, but that has no effect on your data. I need to check if it's working more generally in the fit function).

The improved script will also be included in the next release of PsychoPy (soon)

hope this helps
Jon

For more options, visit https://groups.google.com/groups/opt_out.

-- 
Jonathan Peirce
Nottingham Visual Neuroscience

http://www.peirce.org.uk

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.


last.pdf
JND_staircase_analysis.py

A Kumcu

unread,
Oct 22, 2013, 9:06:47 AM10/22/13
to psychop...@googlegroups.com
Jon, I am very grateful for this! it helps immensely. I will study it
to understand the fitting better. I'm pretty new to this topic.

Interesting that the threshold gives a higher level than the average
of the few reversals (0.036).

Kind regards
Jade
> https://groups.google.com/d/msgid/psychopy-users/526666D8.2030405%40nottingham.ac.uk.

Jonathan Peirce

unread,
Oct 22, 2013, 10:26:10 AM10/22/13
to psychop...@googlegroups.com
Actually something does look fishy here. When I plot every point of the
staircase (with a dot) it looks to me like the Y values on the left
don't match up with the X values on the right. :-/ I'll do some digging
and get back to you.

Jon
>>>> Setup," Optometry& Vision Science, 2001, 78, 56-64.
last.pdf

A Kumcu

unread,
Oct 22, 2013, 10:38:34 AM10/22/13
to psychop...@googlegroups.com
Hi Jon,

While you're busy with this, I have 2 additional questions if you don't mind. :)

- Can the analysis script handle 2 interleaved staircases?

- Is there a way to grab a different field from the staircase datafile
to fit? For example, a separate field that was added to the staircase
using
>>> staircase.addOtherData('resp.contrastcalc', FgContrastCalc)

Do I need to just add another line to the script, e.g.
>>> allIntensities.append( thisDat.contrastcalc )


Thanks!
jade


On Tue, Oct 22, 2013 at 4:26 PM, Jonathan Peirce
> https://groups.google.com/d/msgid/psychopy-users/52668B02.8090904%40nottingham.ac.uk.

Jade Silver

unread,
Oct 28, 2013, 5:20:02 PM10/28/13
to psychop...@googlegroups.com
For posterity's sake ;) I can confirm that the staircase script does handle interleaved staircases and I was able to add separate fields to to the staircase handler, and load them back into the JND analysis script.

Phew, it's been a small learning curve with PsychoPy but have enjoyed using it. Hopefully my participants will enjoy participating just as much. ;)

Jade


On Tuesday, October 22, 2013 4:38:34 PM UTC+2, Jade Silver wrote:
Hi Jon,

>>> email to psychopy-users+unsubscribe@googlegroups.com.
>>> To post to this group, send email to psychopy-users@googlegroups.com.
>>> To view this discussion on the web visit
>>>
>>> https://groups.google.com/d/msgid/psychopy-users/526666D8.2030405%40nottingham.ac.uk.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> Jonathan Peirce
> Nottingham Visual Neuroscience
>
> http://www.peirce.org.uk
>
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it.   Please do not
> use, copy or disclose the information contained in this message or in any
> attachment.  Any views or opinions expressed by the author of this email do
> not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system,
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "psychopy-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/psychopy-users/PQwxOHsU6RA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

shark_scott

unread,
Dec 8, 2013, 12:04:52 PM12/8/13
to psychop...@googlegroups.com
Hi Jade,
    Could you give a quick explanation of how you got the JND analysis script to handle interleaved staircases?  I created an interleaved staircase in Builder but when I tried to run the analysis on the resulting .psydat file, Psychopy told me:
   assert isinstance(thisDat, data.StairHandler)
AssertionError
    Did you have to separate the two staircases into different files (as is done in the demo for the staircase analysis)?  If so, how did you do that?
    Thanks!
    Mark
>>> psychopy-user...@googlegroups.com.
>>> To post to this group, send email to psychop...@googlegroups.com.
>>> To view this discussion on the web visit
>>>
>>> https://groups.google.com/d/msgid/psychopy-users/526666D8.2030405%40nottingham.ac.uk.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> Jonathan Peirce
> Nottingham Visual Neuroscience
>
> http://www.peirce.org.uk
>
>
> This message and any attachment are intended solely for the addressee and
> may contain confidential information. If you have received this message in
> error, please send it back to me, and immediately delete it.   Please do not
> use, copy or disclose the information contained in this message or in any
> attachment.  Any views or opinions expressed by the author of this email do
> not necessarily reflect the views of the University of Nottingham.
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system,
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "psychopy-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/psychopy-users/PQwxOHsU6RA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> psychopy-user...@googlegroups.com.
> To post to this group, send email to psychop...@googlegroups.com.
> To view this discussion on the web visit

Jade Silver

unread,
Dec 8, 2013, 12:36:40 PM12/8/13
to psychop...@googlegroups.com
Hi Mark,

Yes I created two staircase files. Here is an extract of the code I used (I use Coder, not Builder). The last few lines are the code to save the two files. I gave the rest in case your staircase names are different.

stairs=[]
thisStair=[]
info['startPoints']=[0.05,0.1]  # Your starting points

# To interleave multiple staircases
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)
    thisInfoStair = copy.copy(info)
    #now add any specific info for this staircase
    thisInfoStair['thisStart']=thisStart #we might want to keep track of this
    thisStair = data.StairHandler(startVal=thisStart,
        extraInfo=thisInfoStair, nTrials=70,  
        stepType = 'lin', stepSizes=[myStepSize],
        minVal=0.0001, maxVal=1,
        nUp=nUpVal, nDown=nDownVal)
    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()  # Sets the next intensity level based on the previous

         ... do some stuff / check for response
                    thisStair.addData(thisResp) # adds response (correct/incorrect) and staircase value to staircase handlers


for thisStair in stairs:
#create a filename based on the subject and start value
    fileNameS= subjectName + '_start%.3f' %(thisStair.extraInfo['thisStart']) # give a unique name by subject & start value
    thisStair.saveAsPickle(outputdirpickle + fileNameS)
    thisStair.saveAsText(outputdirpickle + fileNameS)  # optional

cheers
asli

shark_scott

unread,
Dec 8, 2013, 10:19:41 PM12/8/13
to psychop...@googlegroups.com
Hi,
    Thanks!  I'll play around with that to see if I can get it working in Builder.
    Thanks,
    Mark
Reply all
Reply to author
Forward
0 new messages