StairHandler logic for up/down step on a compare contrast task

My jnd task asks the participant to compare contrast of two gratings: standardStim and comparisonStim

standardStim has a fixed contrast of .6
comparisonStim has a contrast value set from whatever value is contained in the level variable from the StairHandler.

However, as this is a jnd comparison task, I need the following to happen:

If the previous level was less than .6, and if the current step is a down step, then the StairHandler should increase the current level so that it gets closer to the standard stimuli fixed .06 contrast.

But StairHandler is designed to decrease level on a down step. This works fine when level > standardStim’s fixed contrast, because then down steps decrease level (making the task harder) because comparisonStim's contrast is brought closer to standardStim.

My question is: What is the best way (code or some other change in my design) to ensure the following pseudocode conditional:

If current step is down and the previous step’s level < .06: increase level by stepsize
If current step is up and the previous step’s level < .06: decrease level by stepsize

Note: I have played around with a code block which uses the variable my_loop.currentStaircase.currentDirection and I can successfully create conditionals based on this value. I’m sure I can hack something together that gets the job done, but I am asking here because I want to know a “best practice” or maybe someone will point out that the StairHandler has a feature to handle jnd comparison tasks.

A quick update to my question:

I’ve read over the source code in staircase.py but I am still unsure the best way to intervene in the logic that governs the next intensity (i.e., https://github.com/psychopy/psychopy/blob/master/psychopy/data/staircase.py#L393-L419).

Can anyone provide some pointers on how to intervene in the default logic of StairHandler() to adjust the next intensity (and future intensities) so that an up step is always an easier task (further from my standardStim's contrast) and a down step is always a more difficult task (closer to my standardStim's contrast)?

Again, the conceptual issue is that the difficulty of the task is not a linear function of intensity level, and it is not obvious to me how to get StairHandler to do what I need.

Hi There,

Have you had a play with the JND demo in coder? (coder view> demos> exp control > JND_staircase_exp.py) since you are also trying to use a JND perhaps this would be helpful?

Becca

Thank you for your response, Becca! I did look at the demo. I am able to get everything working as long as I have minVal above 0. Ideally my experiment would allow minVal to be a negative number.

Essentially what I was trying to do was have PsychoPy’s StairHandler behave differently when level becomes a negative number; I wanted up steps to decrease level and down steps to increase level.

The only solution I can come up with is to use a bit of code to conditionally invert the stepSizes parameter if level < 0. But I am not sure this is the right way to go about it.

I think you want to have StairHandler managing the absolute difference from your standard stimulus, and manually do the conversions to get the actual stimulus value to present.

You could either have two interleaved staircases to separately handle values below and above the standard, or alternatively do some kind of randomisation to decide if you subtract or add the difference that StairHandler suggests. Maybe that’s what your question is about, I’m not sure which of those is the “best practice”, but my guess is interleaved staircases is more robust.