Overview

The Quest algorithm has been ported directly from the MATLAB sources available with the PsychToolbox. The MATLAB source code was written by Denis Pelli. Thanks to Denis for allowing it to be released under the BSD license to the (Python) world.

This Python version does not depend on the Vision Egg, and may be useful in other contexts.

Download

Download the source directly from the Quest package at the SourceForge download page.

Example

The intensity scale is abstract, but usually we think of it as representing log contrast.
Specify true threshold of simulated observer: 0.5
Estimate threshold: 0.4
Trial   1 at  0.7 is right
Trial   2 at  0.4 is right
Trial   3 at -0.2 is wrong
Trial   4 at  0.7 is right
Trial   5 at  0.4 is right
Trial   6 at  0.4 is wrong
Trial   7 at  1.1 is right
Trial   8 at  0.9 is right
Trial   9 at  0.7 is right
Trial  10 at  0.7 is right
36 ms/trial
Mean threshold estimate is 0.60 +/- 0.38

Quest beta analysis. Beta controls the steepness of the Weibull function.

Now re-analyzing with beta as a free parameter. . . .
logC     sd      beta    sd      gamma
 0.62    0.39    3.7     4.5     0.500
Actual parameters of simulated observer:
logC    beta    gamma
 0.50    3.5     0.50

The example above is taken directly from the demo() function of Quest.py and is a direct translation of the demo included in the original MATLAB source:

   1     print 'The intensity scale is abstract, but usually we think of it as representing log contrast.'
   2 
   3     tActual = None
   4     while tActual is None:
   5         sys.stdout.write('Specify true threshold of simulated observer: ')
   6         input = raw_input()
   7         try:
   8             tActual = float(input)
   9         except:
  10             pass
  11 
  12     tGuess = None
  13     while tGuess is None:
  14         sys.stdout.write('Estimate threshold: ')
  15         input = raw_input()
  16         try:
  17             tGuess = float(input)
  18         except:
  19             pass
  20 
  21     tGuessSd = 2.0 # sd of Gaussian before clipping to specified range
  22     pThreshold = 0.82
  23     beta = 3.5
  24     delta = 0.01
  25     gamma = 0.5
  26     q=QuestObject(tGuess,tGuessSd,pThreshold,beta,delta,gamma)
  27 
  28     # Simulate a series of trials.
  29     trialsDesired=100
  30     wrongRight = 'wrong', 'right'
  31     timeZero=time.time()
  32     for k in range(trialsDesired):
  33         # Get recommended level.  Choose your favorite algorithm.
  34         tTest=q.quantile()
  35         #tTest=q.mean()
  36         #tTest=q.mode()
  37 
  38         tTest=tTest+random.choice([-0.1,0,0.1])
  39 
  40         # Simulate a trial
  41         timeSplit=time.time(); # omit simulation and printing from reported time/trial.
  42         response=q.simulate(tTest,tActual)
  43         print 'Trial %3d at %4.1f is %s'%(k+1,tTest,wrongRight[response])
  44         timeZero=timeZero+time.time()-timeSplit;
  45 
  46         # Update the pdf
  47         q.update(tTest,response);
  48 
  49     # Print results of timing.
  50     print '%.0f ms/trial'%(1000*(time.time()-timeZero)/trialsDesired)
  51 
  52     # Get final estimate.
  53     t=q.mean()
  54     sd=q.sd()
  55     print 'Mean threshold estimate is %4.2f +/- %.2f'%(t,sd)
  56     #t=QuestMode(q);
  57     #print 'Mode threshold estimate is %4.2f'%t
  58 
  59     print '\nQuest beta analysis. Beta controls the steepness of the Weibull function.\n'
  60     q.beta_analysis()
  61     print 'Actual parameters of simulated observer:'
  62     print 'logC beta    gamma'
  63     print '%5.2f        %4.1f   %5.2f'%(tActual,q.beta,q.gamma)

References

License

The Python Quest package is released under a BSD-style license. (The Vision Egg itself has a LGPL license.)

Quest (last edited 2008-03-17 07:02:02 by AndrewStraw)