Mouse and staircase

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10):
Windows 10
PsychoPy version (e.g. 1.84.x):
2024.2.4

Hello

I’m new to this, and was trying to create a task using a staircase to adjust difficulty with a mouse response. I think there is a problem with how the code is generated.

If I create a task with a keyboard, everything works fine, and The builder generates (python) code with

        stair.addResponse(key_resp.corr, level)
        stair.addOtherData('key_resp.rt', key_resp.rt)

If I have a mouse response (with “Store Correct” ticked on the mouse gui)
Builder generates code:

        stair.addData('mouse.x', mouse.x)
        stair.addData('mouse.y', mouse.y)
        stair.addData('mouse.leftButton', mouse.leftButton)
        stair.addData('mouse.midButton', mouse.midButton)
        stair.addData('mouse.rightButton', mouse.rightButton)
        stair.addData('mouse.time', mouse.time)
        stair.addData('mouse.corr', mouse.corr)
        stair.addData('mouse.clicked_name', mouse.clicked_name)

With an ‘interleaved staircase’, this crashes with
TypeError: MultiStairHandler.addData should only receive corr / incorr. Use .addOtherData('datName',val)

If I replace addData with addOtherData it runs (but the staircase level does not change)
If I also add
stair.addResponse(mouse.corr[0], level)
then it works with the level adapting according to response

with ‘staircase’ it generates the same code as above. Which does run, but the task just gets harder irrespective of response.
If I add
stair.addResponse(mouse.corr[0], level)
AND either remove the above ‘addData’ lines or change them to ‘addOtherData’ then the script runs as expected. If I leave them as addData, then the staircase level just gets harder.

So it seems to me that when using a mouse with a staircase,

  1. the builder should generate code with addOtherData
  2. It should ideally add a ‘stair.addResponse’ line

Thanks

Michael

Just in case anyone else has the same issue, I got the mouse / staircase combination to work with builder by:

  1. in mouse, change “save mouse state” from “on click” to “never”.
  2. in code under ‘end routine’ add stair.addResponse(mouse.corr[0], level)