Fitting a psychometric curve to find perceptual threshold

Hi everyone,

In my experiment, I try to determine the perceptual threshold of my participants (i.e., stimulus detected 50% of the time). While I find a perfectly functional code in Python that works great when I run my experiment locally I’m having trouble finding a code working online, does anyone have an idea/already try to do this?
A little more context: I have an array of five visual intensities [0.05, 0.07, 0.09, 0.1, 0.12] and the percentage of correct detection for each intensity, for example [30, 35, 55, 65, 95]. I want to fit a logistic regression to find the intensity for which the percentage of correct detection will be 50.

Thanks in advance for your help,

Perrine

Hi Perrine - I’m trying to do something similar and haven’t found a solution. Just wondering if you managed to get it working?

Hi, I haven’t found a way to fit a psychometric curve directly but was able to determine the intensity at which participants detect the stimulus 40% of the time using the following code:

let intensity = [0.005, 0.01, 0.02, 0.03, 0.05];
let correct_answer = [correctAns_int1, correctAns_int2, correctAns_int3, correctAns_int4, correctAns_int5];
let trials_number_by_int = 20;
// Calculate percentage correct
let percentage_correct = correct_answer.map(x => (x / trials_number_by_int) * 100);

function interpole(x, x1, y1, x2, y2) {
    return y1 + (x - x1) * (y2 - y1) / (x2 - x1);
}
function foundIntensity(percentage) {
    for (let i = 0; i < percentage_correct.length - 1; i++) {
        if (percentage_correct[i] <= percentage && percentage <= percentage_correct[i + 1]) {
            return interpole(percentage, percentage_correct[i], intensity[i], percentage_correct[i + 1], intensity[i + 1]);
        }
    }
    return null;
}
thresh_40 = foundIntensity(40);

Hoping this can help you :slight_smile: