Hi
I am trying to add a small portion of custom python code which chooses a file (after reading another one, kept in the repository) which is then passed to a trial loop.
pracBlock = data.TrialHandler(nReps=1, method='random',
extraInfo=expInfo, originPath=-1,
trialList=data.importConditions(file_for_practice),
seed=None, name='pracBlock')
Specifically, the file_for_practice variable is set by the python code
filename = 'file_which.txt'
with open(filename, 'r') as file:
lines = file.readlines()
lines = [int(line.rstrip()) for line in lines]
if lines[0]== 1:
file_for_practice='practice1.xlsx'
with open(filename, 'w') as file:
file.write('2')
else:
file_for_practice='practice2.xlsx'
with open(filename, 'w') as file:
file.write('1')
I tried this locally by modifying the python script I had. I do not know precisely how I might be able to replicate this behavior (choosing a conditions file based on a variable) in my experiment on pavlovia since I do not know if the conditions field in the condition dialog box which expects an excel file can use a variable.
I wish to provide a variable (file_for_practice) which is setup by my python code instead but I do not know how to convey this to psychopy and my java code seems to not work (I wrote Java for the first time today, so that might be the reason.)
I am wondering if anyone knows how can I accomplish this task of setting the conditions file through a variable name? Or if this is something one cannot do or there is better way of doing this compared to how I am trying to do it.
Thank you for your patience in reading my question through.
Anna