I have data from the behavioral component of an fMRI study in which subjects are asked to perform a 2AFC discrimination task with targets at variable contrast.  That is, a target will be presented at one of several possible contrasts, and the subject must later identify which of two possible responses has the same orientation as the target stimulus.

Below is an example of data from one subject:

[![enter image description here][1]][1]

Note that I've attempted to fit a psychometric function, using the following procedure (in Python):

    import numpy as np
    import pylab
    from scipy.optimize import curve_fit
    
    def sigmoid(x, x0, k):
         y = 1 / (1 + np.exp(-k*(x-x0)))
         return y
    
    xdata = np.array([0.0,   1.0,  3.0, 4.3, 7.0,   8.0,   8.5, 10.0, 12.0])
    ydata = np.array([0.01, 0.02, 0.04, 0.11, 0.43,  0.7, 0.89, 0.95, 0.99])
    
    popt, pcov = curve_fit(sigmoid, xdata, ydata)
    print popt
    
    x = np.linspace(-1, 15, 50)
    y = sigmoid(x, *popt)
    
    pylab.plot(xdata, ydata, 'o', label='data')
    pylab.plot(x,y, label='fit')
    pylab.ylim(0, 1.05)
    pylab.legend(loc='best')
    pylab.show()

Of particular note is the sigmoid formula I'm using:  `1 / (1 + exp(-k * (x - x0)))`.

The problem with this approach is that the fit will pass through zero, wheras with 2AFC data, the minimum value is theoretically .5 -- the guessing rate.

###How can I fit a sigmoid function such that the fit spans from .5 to 1.0?

  [1]: https://i.sstatic.net/G2Y7c.png