Hi, good evening.
I want to export the data at the end of the Trial (loop) but for each data saved, the values of “target”, “cueside” and “tarside” are always the same.
For cueside, for example:
_thisDir = os.path.dirname(os.path.abspath(__file__))
os.chdir(_thisDir)
# Info about the experiment
expName = "Attention Network Task"
expInfo = {"Participant": "","Age": ""}
dlg = gui.DlgFromDict(dictionary=expInfo, title=expName)
if dlg.OK == False:
core.quit()
expInfo['date'] = data.getDateStr()
expInfo['expName'] = expName
# Data file name stem
filename = _thisDir + os.sep + u"data/%s_%s_%s" % (expInfo["Participant"], expName, expInfo["date"])
#ExperimentHandler
exp = data.ExperimentHandler(name=expName, extraInfo=expInfo, savePickle=True, saveWideText=True,
dataFileName=filename)
# save a log
logFile = logging.LogFile(filename+'.log', level=logging.EXP)
logging.console.setLevel(logging.WARNING)
endExpNow = False
#Cue locations
CUELOCS = ["upper", "both","lower","centre","blank"]
# All possible cues
cuestim = {}
cuestim["blank"] = ImageStim(disp, size=(300,300), image="blank.png")
cuestim["centre"] = ImageStim(disp, size=(300,300), image="centre.png")
cuestim["upper"] = ImageStim(disp, size=(300,300), image="upper.png")
cuestim["lower"] = ImageStim(disp, size=(300,300), image="lower.png")
cuestim["both"] = ImageStim(disp, size=(300,300), image="both.png")
# Create an empty list to contain the training trial
training = []
# Loop
for cueside in CUELOCS:
for tarside in TARLOCS:
for soa in SOAS:
for tar in TARGETS:
#for flank in FLANKERS:
# Training dictionary
trialtraining = {"cueside":cueside, "tarside":tarside, "target":tar, "soa":soa}
# add the trial dictionary to the list
training.extend (TRAININGREPEATS * [trialtraining])
# Randomise
random.shuffle (training)
In the end of the loop:
# Loop FIRST TRIAL
for trial_number, trialtraining in enumerate(training):
if trial_number == 96:
break
# Present fixmark
imgfix.draw()
fixonset = disp.flip ()
wait (FIXTIME)
# Draw the fixation mark and the cues
imgfix.draw()
cuestim[trialtraining["cueside"]].draw()
cueonset = disp.flip()
wait (CUETIME)
# Draw the fixation mark
imgfix.draw()
# Update the monitor
cueoffset = disp.flip()
#wait for the SOA minus the cue duration
wait (trialtraining ["soa"] - CUETIME)
# Draw the fixation mark
imgfix.draw()
# Draw a target stimullus
tarstim[trialtraining ["tarside"]].draw()
# Update the monitor
taronset = disp.flip()
# Wait for a response
resplist = waitKeys (maxWait=float("inf"), keyList = ["left", "right"],timeStamped = True)
if 'escape' in getKeys(): quit()
# Select the first response from the response list
response, presstime = resplist[0]
# Calculate de RT
RT = presstime - taronset
# Valid cue?
if trialtraining ["cueside"] == trialtraining ["tarside"]:
validity = 1
else:
validity = 0
# Check if the response was correct
if response == tarstim [trialtraining ["tarside"]].correctAns:
correct = 1
else:
correct = 0
# Extract data
exp.addData('cueside', cueside)
exp.nextEntry()
disp.flip()
But the cueside is saved only with the “blank” (not “upper”, “centre”, etc) value for all trials.
I hope I could let clear what is happening. I tried to summarize the code, but if needed I can put more information.
Thanks in advance