psychopy.org | Reference | Downloads | Github

How to access Iowa Gambling Task code

Hello! I’m new to both PsychoPy and programming and I’m trying to figure out how it works. I need to run an experiment online for the Iowa Gambling Task and I have found two links (1 | 2) on Pavlovia with the code but I’m not sure how to run it on PsychoPy.

I know this is super beginner level but could someone direct me to a resource that could help me out or let me know which file would be appropriate to use?

I’m going to assume you’re really starting from scratch here, so these are very basic directions. It’ll be easier to get (1), for the moment.

I assume you have installed PsychoPy’s latest version (2020.1.3). Open PsychoPy, on the top bar you’ll see a group of icons with globes and little symbols in the bottom right. Click the one with the magnifying glass in the bottom right of the globe.

In the new window, where it says “local root”, click “browse” and then select where you want to save the experiment to (when you get that far, you just need to set it up in advance).

Then, put “Iowa gambling” in the search box on the left. It looks like this one is Haaqiu’s, but there are also more recent ones you could check out. Select whichever one you want, and the “fork+sync” button should be available. Click “fork+sync”. This will download a copy of the experiment to a local folder on your computer.

To open it, in the builder just go to “open”, navigate to the folder that you set earlier, and open the .psyexp file. You should then be able to modify and run it on your local machine. To run it online, just click the globe icon with a running symbol in the bottom right, it will then guide you to upload it to a new repository in your Pavlovia account, where you can go it it and either pilot or run it.

Hope that helps!

Hello, thanks for getting back to me. When I click fork+sync, nothing happens and the following message shows up. I’ve tried uninstalling it already but it doesn’t seem to help!

Traceback (most recent call last):
File “C:\Users\2018\AppData\Local\PsychoPy3\lib\site-packages\gitlab\exceptions.py”, line 242, in wrapped_f
return f(*args, **kwargs)
File “C:\Users\2018\AppData\Local\PsychoPy3\lib\site-packages\gitlab\mixins.py”, line 204, in create
**kwargs)
File “C:\Users\2018\AppData\Local\PsychoPy3\lib\site-packages\gitlab_init_.py”, line 589, in http_post
post_data=post_data, files=files, **kwargs)
File “C:\Users\2018\AppData\Local\PsychoPy3\lib\site-packages\gitlab_init_.py”, line 495, in http_request
response_body=result.content)
gitlab.exceptions.GitlabHttpError: 409: {‘name’: [‘has already been taken’], ‘path’: [‘has already been taken’]}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\2018\AppData\Local\PsychoPy3\lib\site-packages\psychopy\app\pavlovia_ui\project.py”, line 349, in onSyncButton
fork = self.project.forkTo() # logged-in user
File “C:\Users\2018\AppData\Local\PsychoPy3\lib\site-packages\psychopy\projects\pavlovia.py”, line 887, in forkTo
fork = self.pavlovia.forks.create(newProjInfo)
File “C:\Users\2018\AppData\Local\PsychoPy3\lib\site-packages\gitlab\exceptions.py”, line 244, in wrapped_f
raise error(e.error_message, e.response_code, e.response_body)
gitlab.exceptions.GitlabCreateError: 409: {‘name’: [‘has already been taken’], ‘path’: [‘has already been taken’]}

It thinks you’ve made a repository of that name already. Look at the repositories in your dashboard, if you already have one called “Iowa Gambling Task” you may have to delete it to fork the new one.

Hi-- I am running into the same exact issue. Did you ever get this resolved?

Hi! Were you able to resolve this issue? I’m also experiencing it now :frowning:

Please could you paste your error message?

When I press fork+sync, my error is:
Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/gitlab/exceptions.py”, line 251, in wrapped_f
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/gitlab/mixins.py”, line 204, in create
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/gitlab/init.py”, line 604, in http_post
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/gitlab/init.py”, line 510, in http_request
gitlab.exceptions.GitlabHttpError: 409: {‘name’: [‘has already been taken’], ‘path’: [‘has already been taken’]}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/pavlovia_ui/project.py”, line 349, in onSyncButton
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/projects/pavlovia.py”, line 892, in forkTo
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/gitlab/exceptions.py”, line 253, in wrapped_f
gitlab.exceptions.GitlabCreateError: 409: {‘name’: [‘has already been taken’], ‘path’: [‘has already been taken’]}

Have you looked at your dashboard to see if this is the issue?

I’m on a Mac computer (with BigSur) and I don’t think I have a dashboard. I can’t actually find a repository called Iowa Gambling Task, though

Your dashboard is here: https://pavlovia.org/dashboard

If you don’t have one, perhaps this issue is that you need to create a Pavlovia account.

Yes, thank you so much! (I’m really new to PsychoPy with no coding experience). When I try to run the IGT, I’m getting this Nameerror. Do you have any idea about what this means and how to resolve it?

2021-06-21 19:52:50.185 python[31519:2893292] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/zr/9znddnd51x5_mrjtcz4kg3240000gn/T/org.opensciencetools.psychopy.savedState
Traceback (most recent call last):
File “/Users/michellechernikova/Desktop/SURP 2021/once again/IGT_Fixed_lastrun.py”, line 130, in
A1 = (A_List[:])
NameError: name ‘A_List’ is not defined

Experiment ended.

Where does A_List come from?

It comes from this part of the code for the Iowa Gambling Task:

if ((expInfo[‘version’]) == ‘1’): #this is the AB version
A_List = [100, 100, -50, 100, -200, 100, -100, 100, -150, -250, 100, -250, 100, -150, -100, 100, -200, -50, 100, 100, 100, -200, 100, -250, 100, -100, -150, -50, 100, 100, -250, -100, -150, 100, 100, 100, -50, -200, 100, 100]
B_List = [100, 100, 100, 100, 100, 100, 100, 100, -1150, 100, 100, 100, 100, -1150, 100, 100, 100, 100, 100, 100, -1150, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, -1150, 100, 100, 100, 100, 100, 100, 100, 100]
C_List = [50, 50, 0, 50, 0, 50, 0, 50, 0, 0, 50, -25, -25, 50, 50, 50, -25, -25, 50, 0, 50, 50, 50, 0, -25, 0, 50, 50, -25, 0, 50, 50, 50, -25, -25, 50, -25, 50, 0, -25]
D_List = [50, 50, 50, 50, 50, 50, 50, 50, 50, -200, 50, 50, 50, 50, 50, 50, 50, 50, 50, -200, 50, 50, 50, 50, 50, 50, 50, 50, -200, 50, 50, 50, 50, 50, -200, 50, 50, 50, 50, 50]
elif ((expInfo[‘version’]) == ‘2’): #this is the BD version
A_List = [50, 50, 0, 50, 0, 50, 0, 50, 0, 0, 50, -25, -25, 50, 50, 50, -25, -25, 50, 0, 50, 50, 50, 0, -25, 0, 50, 50, -25, 0, 50, 50, 50, -25, -25, 50, -25, 50, 0, -25]
B_List = [100, 100, -50, 100, -200, 100, -100, 100, -150, -250, 100, -250, 100, -150, -100, 100, -200, -50, 100, 100, 100, -200, 100, -250, 100, -100, -150, -50, 100, 100, -250, -100, -150, 100, 100, 100, -50, -200, 100, 100]
C_List = [50, 50, 50, 50, 50, 50, 50, 50, 50, -200, 50, 50, 50, 50, 50, 50, 50, 50, 50, -200, 50, 50, 50, 50, 50, 50, 50, 50, -200, 50, 50, 50, 50, 50, -200, 50, 50, 50, 50, 50]
D_List = [100, 100, 100, 100, 100, 100, 100, 100, -1150, 100, 100, 100, 100, -1150, 100, 100, 100, 100, 100, 100, -1150, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, -1150, 100, 100, 100, 100, 100, 100, 100, 100]

A1 = (A_List[:])
B1 = (B_List[:])
C1 = (C_List[:])
D1 = (D_List[:])

A2 = (A_List[:])
B2 = (B_List[:])
C2 = (C_List[:])
D2 = (D_List[:])

A3 = (A_List[:])
B3 = (B_List[:])
C3 = (C_List[:])
D3 = (D_List[:])

In that case you just need to add A_List= [] etc before the if statements