Skip to content

Instantly share code, notes, and snippets.

@lvanderlinden
Created October 24, 2012 20:08
Show Gist options
  • Save lvanderlinden/3948514 to your computer and use it in GitHub Desktop.
Save lvanderlinden/3948514 to your computer and use it in GitHub Desktop.
location_target = self.get('location_target')
resp = self.get("response")
# Here you determine whether the response is correct, like
# the scripts posted earlier by yourself and Edwin.
# The only addition is the else-statement at the end,
# to make sure that RT should be included in the averages
# ig location_target is not "none".
if location_target == "none": # No-trial
# In OpenSesame 0.27, no-responses are saved as 'None'
if resp in ('timeout', 'None'):
correct = 1
else:
correct = 0
else: # Go-trial
correct = self.get('correct') # Assumed that 'correct' for go-trials is set in the GUI
# If trial is a go-trial, add trial-RT to the RT-list
lRT.append(self.get('response_time'))
# Add 'correct' always to the acc-list:
lCorrect.append(correct)
# Calculate averages and set them as my_avg_rt and my_acc,
# which you can simply use in a feedback display
if len(lRT) > 0:
exp.set('my_avg_rt', sum(lRT)/len(lRT))
else:
exp.set('my_avg_rt', 'undefined')
if len(lCorrect) > 0:
exp.set('my_acc', 100.*sum(lCorrect)/len(lCorrect))
else:
exp.set('my_acc', 'undefined')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment