# Reconstructing QUEST psychometric function

**URL:** <https://discourse.psychopy.org/t/reconstructing-quest-psychometric-function/7551>\
**Category:** Coding\
**Tags:** analysis\
**Created:** [April 26, 2019, 2:09pm UTC](https://discourse.psychopy.org/t/reconstructing-quest-psychometric-function/7551 "2019-04-26T14:09:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Scott](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/martin_scott/32/4502_2.png) [@Martin\_Scott](https://discourse.psychopy.org/u/Martin_Scott)\
**Post date:** [April 26, 2019, 2:09pm UTC](https://discourse.psychopy.org/t/reconstructing-quest-psychometric-function/7551/1 "2019-04-26T14:09:16Z")

</div>

Hi There,

I’m trying to reconstruct the psychometric function from a dataset collected using the QUEST adaptive staircase handler. The experiment was a 2AFC contrast detection task - I have simplified the experiment to a single staircase for this post. In a single trial, two gabor patches of different contrast were presented either side (randomised) of a fixation cross (pedestal, target). The contrast of the pedestal was fixed at 0% (transparent), the contrast of the target was the pedestal contrast + the staircase increment. The participant had to select the gabor of highest contrast (target). The parameters of the staircase were:

```auto
stairs = data.QuestHandler(startVal=0.0145, startValSd=0.02, 
    pThreshold=0.82, nTrials=150, delta=0.01, gamma=0.01,
    method='quantile',
    minVal=0, maxVal=1.0, beta=3.5, stopInterval=.05)

```

Using the built-in demos as guidance, I’ve used the functionFromStaircase & FitWeibull functions to reconstruct the fit, but the threshold this produces does not match that produced by querying the mean of the QuestHandler object. My code is:

```auto
thisFile = 'datafile_0_percent'
thisDat = fromFile(thisFile)
print('Mean Thresh is %f' % (thisDat.mean()))

#detection threshold is around 1.4%
Mean Thresh is 0.01408328315420852

#Whereas if I try to reconstruct the function

i, r, n = data.functionFromStaircase(allIntensities, allResponses, bins=10)

fit = data.FitWeibull(i, r, expectedMin = 0.5, guess=[0.0145, 0.02])
thresh = fit.inverse(0.82)
print(thresh)

0.001749428283190563

```

I know this is a naive question - but could somebody help me to understand why these thresholds differ so much? I’m unsure of some of the parameters of the FitWeibull function: I’m assuming “guess” is my priors (tGuess & tGuessSd), while expectedMin is the minimum possible performance on a 2AFC (50%). I’m quite new to psychophysics (especially Bayesian) - I hope you can forgive any dumb oversights…! I should say - these stimuli are still in prep - I haven’t inflicted them on anyone but myself yet!

Kind regards,

Martin.
