Yeah sorry about.
Yes the experiment works locally and on Python, the problem is just that levels is not stored properly.
I have manually edit the JS but I am not sure why this is exactly relevant. The edits were definitely more minor than major.
Code in python:
“def setupLogging(filename):
“””
Setup a log file and tell it what level to log at.
Parameters
==========
filename : str or pathlib.Path
Filename to save log file and data files as, doesn't need an extension.
Returns
==========
psychopy.logging.LogFile
Text stream to receive inputs from the logging system.
"""
# set how much information should be printed to the console / app
if PILOTING:
logging.console.setLevel(
prefs.piloting['pilotConsoleLoggingLevel']
)
else:
logging.console.setLevel('warning')
# save a log file for detail verbose info
logFile = logging.LogFile(filename+'.log')
if PILOTING:
logFile.setLevel(
prefs.piloting['pilotLoggingLevel']
)
else:
logFile.setLevel(
logging.getLevel('info')
)
return logFile"
"# set up handler to look after randomisation of trials etc
conditions = data.importConditions(‘adaptive_loop_quest_debugging.xlsx’)
trials = data.MultiStairHandler(stairType=‘QUEST’, name=‘trials’,
nTrials=1.0,
conditions=conditions,
method=‘random’,
originPath=-1)
thisExp.addLoop(trials) # add the loop to the experiment
# initialise values for first condition
level = trials._nextIntensity # initialise some vals
condition = trials.currentStaircase.condition
for **level**, condition in trials:
currentLoop = trials
thisExp.timestampOnFlip(win, 'thisRow.t', format=globalClock.format)
# abbreviate parameter names if possible (e.g. rgb=condition.rgb)
for paramName in condition:
globals()[paramName] = condition[paramName]
# --- Prepare to start Routine "DiscriminationTrial" ---
# create an object to store info about Routine DiscriminationTrial
DiscriminationTrial = data.Routine(
name='DiscriminationTrial',
components=[Shape1, Shape2, key_resp_2],
)
DiscriminationTrial.status = NOT_STARTED
continueRoutine = True
# update component parameters for each repeat
# Run 'Begin Routine' code from SetupTrial
feature = discrimination_parameters[feature_index]
feature_center = [feature[0],feature[1]] # XX later number these
feature_vector = [feature[2],feature[3]]
#coord0 = feature_center # If no difference
trials.finished=True # Crash this phase XXdebugging
coord1 = vector_plus(feature_center,scalar_product(**level**,feature_vector))
coord2 = vector_minus(feature_center,scalar_product(**level**,feature_vector))
if random() < .5:
correct_answer = 'd' # different
shape1 = shape_from_coordinates(coord1,feature_space,10)
shape2 = shape_from_coordinates(coord2,feature_space,10)
else:
correct_answer = 's' # same
shape1 = shape_from_coordinates(feature_center,feature_space,10)
shape2 = shape_from_coordinates(feature_center,feature_space,10)"
“def endExperiment(thisExp, win=None):
“””
End this experiment, performing final shut down operations.
This function does NOT close the window or end the Python process - use `quit` for this.
Parameters
==========
thisExp : psychopy.data.ExperimentHandler
Handler object for this experiment, contains the data to save and information about
where to save it to.
win : psychopy.visual.Window
Window for this experiment.
"""
if win is not None:
# remove autodraw from all current components
win.clearAutoDraw()
# Flip one final time so any remaining win.callOnFlip()
# and win.timeOnFlip() tasks get executed
win.flip()
# return console logger level to WARNING
logging.console.setLevel(logging.WARNING)
# mark experiment handler as finished
thisExp.status = FINISHED
logging.flush()"