Staircase error

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

OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): 2023.2.3
Standard Standalone? (y/n) y
What are you trying to achieve?: insert a staircase loop

What did you try to make it work?: inserted a staircase loop, put in the values, clicked on run

What specifically went wrong when you tried that?:
Error window appeared with the following text:

Traceback (most recent call last):
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\builder.py”, line 1275, in runFile
self.app.runner.panel.runLocal(event)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\runner\runner.py”, line 749, in runLocal
generateScript(experimentPath=currentFile.replace(‘.psyexp’, ‘_lastrun.py’),
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 91, in generateScript
compileScript(infile=exp, version=None, outfile=filename)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 229, in compileScript
_makeTarget(thisExp, outfile, targetOutput)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 209, in makeTarget
script = thisExp.writeScript(outfile, target=targetOutput)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment_experiment.py”, line 301, in writeScript
self_copy.flow.writeBody(script)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\flow.py”, line 304, in writeBody
entry.writeMainCode(script)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\routines_base.py”, line 537, in writeMainCode
event.writeRoutineEndCode(buff)
File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\components\slider_init
.py", line 389, in writeRoutineEndCode
buff.writeIndented(code % (loopName, name, name))
UnboundLocalError: local variable ‘loopName’ referenced before assignment

Identical behaviour in 2024.1.1

Does loopName appear in your code?

Please could you show your flow and you staircase?

Hi,

I have no idea where the loopName variable comes from…

Flow is shown below (split in half):

The first loop (“practice”) is a standard ‘sequential’ loop controlled by an excel file.

The second loop (“painStairs”) is where I’ve tried (and failed) to use a simple staircase (see parameters below).

Please note that whilst the numbers in the nUp nDown might look weird - when using more typical values 1 and 3, respectively, the code still fails (same error).

The slightly unusual thing about my intended use for the staircase is that I start with a low level (as this will be used as the temperature of a thermode applied to the skin), and increase until a critical value (pain rating) has been exceeded. So, I don’t have a two choice scenario, e.g. where a subject can either detect a difference in the orientation of a grating, or not. Instead the subject provides a rating with a slider object, using a keyboard object (keyResp2) to collect responses (‘left’ or ‘right’) in the routine getRating2. Whilst there is no correct or incorrect answer per se, I have a little bit of code in getRating2 that at the end of the routine, determines if the reported pain level is above the required level and sets keyResp2.corr = 1, or keyResp2.corr = 0 otherwise. So the idea is that once you’ve exceeded the required threshold, $level should not be repeated and instead should be reduced, and keep reducing if the subject continues to report pain levels above the desired level, until they are below the threshold, where they should reply 2 or 3 times with ratings below the desired pain level before the temperature rises again (with the next step on the threshold ladder). Rinse & repeat…

Sorry about the lengthy explanation…

Best wishes,

Jon

FYI if I use an “interleaved staircase” with excel file configured as per the settings above, it seems to work.