Hello, I am having an issue getting my experiment to run on an older psychopy2 version. Unfortunately, this is an fMRI scan and the scanner personnel are unwilling to update psychopy to psychopy3. For reference, I have no issues running the script from scratch on psychopy3, however the following errors occur on the older system. Any ideas for potential solutions/what might be wrong with the code?
I have the following code…
#!/usr/bin/env python2
from future import print_function, division
import numpy as np
import csv
import os
from psychopy import visual, core, data, tools, event
from psychopy import gui
from datetime import datetime
from scipy.stats import norm
from scannercoms import *
#from jkpsycho import *
Added for the scanner
def get_parameters(skip_gui=False):
# Setup my global parameters
try:#try to get a previous parameters file
param_settings = tools.filetools.fromFile(‘lastParams_MSTCont.pickle’)
except:
param_settings = [1234,2.0,0.5,‘AllShort_Set2’,1,‘1’,‘1VC’,‘2B’,‘3NM’,False,False,-1]
print(param_settings)
print(type(param_settings))
if not skip_gui:
param_dialog = gui.Dlg(‘Experimental parameters’)
param_dialog.addField(‘ID’,param_settings[0],tip=‘Must be numeric only’)
param_dialog.addField(‘Duration’,param_settings[1])
param_dialog.addField(‘ISI’,param_settings[2])
param_dialog.addField(‘Lag set’, choices=[‘AllShort_Set1’,‘AllShort_Set2’],initial=param_settings[3])
param_dialog.addField(‘Order’,param_settings[4])
param_dialog.addField(‘Set’, choices=[‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘C’,‘D’,‘E’,‘F’,‘ScC’],initial=param_settings[5])
param_dialog.addField(‘Resp 1 keys’,param_settings[6])
param_dialog.addField(‘Resp 2 keys’,param_settings[7])
param_dialog.addField(‘Resp 3 keys’,param_settings[8])
param_dialog.addField(‘Self-Paced’, initial=param_settings[9])
param_dialog.addField(‘Two-Choice’, initial=param_settings[10])
param_dialog.addField(‘Randomization’,param_settings[11],tip=’-1=Use ID, 0=Use time, >0 = Use specific seed’)
param_settings=param_dialog.show()
#print(ok_data)
if param_dialog.OK:
tools.filetools.toFile(‘lastParams_MSTCont.pickle’, param_settings)
params = {‘ID’: param_settings[0],
‘Duration’: param_settings[1],
‘ISI’:param_settings[2],
‘LagSet’: param_settings[3],
‘Order’:param_settings[4],
‘Set’: param_settings[5],
‘Resp1Keys’:param_settings[6],
‘Resp2Keys’:param_settings[7],
‘Resp3Keys’:param_settings[8],
‘SelfPaced’: param_settings[9],
‘TwoChoice’: param_settings[10],
‘Randomization’:param_settings[11] }
else:
core.quit()
else:
params = {‘ID’: param_settings[0],
‘Duration’: param_settings[1],
‘ISI’:param_settings[2],
‘LagSet’: param_settings[3],
‘Order’:param_settings[4],
‘Set’: param_settings[5],
‘Resp1Keys’:param_settings[6],
‘Resp2Keys’:param_settings[7],
‘Resp3Keys’:param_settings[8],
‘SelfPaced’: param_settings[9],
‘TwoChoice’: param_settings[10],
‘Randomization’:param_settings[11] }
return params
Main routine
params = get_parameters()
print(params)
Set our random seed
if params[‘Randomization’] == -1:
seed = params[‘ID’]
elif params[‘Randomization’]==0:
seed = None
else:
seed = params[‘Randomization’]
np.random.seed(int(seed))"
And I keep getting the following errors…
######################## Running: D:\MST-master\test.py ########################
pygame 1.9.6
Hello from the pygame community. Contribute - pygame wiki
None
<class ‘NoneType’>
Traceback (most recent call last):
File “D:\MST-master\test.py”, line 110, in
params = get_parameters()
File “D:\MST-master\test.py”, line 63, in get_parameters
param_dialog.addField(‘ID’,param_settings[0],tip=‘Must be numeric only’)
TypeError: ‘NoneType’ object is not subscriptable
Experiment ended.
Thank you,
Daniel