Daw Sequential Learning “Two-Step” Task

L:\Administrative\RA training documents\Habit Behavioral Instructions

Running the DAW Task

- Open MATLAB

  1. Navigate to L:\Tasks\Daw_TwoStep_SequentialLearning
  2. In the command window, enter MBMF to launch the task
  3. You will be prompted to enter the subject’s ID
  4. Enter the ID in the format LunaID_YYYYMMDD

a. b. Enter the ID in the format LunaID_YYYYMMDD 4. The subject will use the keyboard to respond. Ask the subject to position their left index finger on the “1” key and their right index finger on the “0” key 5. A tutorial is included at the beginning of the task; read through the instructions and have the participant complete the practice trials when prompted 6. Once the tutorial is complete, the subject will complete 3 blocks of 67 trials (total 201), with two options for breaks in between the blocks

Read through the following instructions to the participant, pressing the space bar after each to advance to the next screen: 1. In this game, you will be taking a spaceship from earth to look for space treasure on two different planets 2. Each planet has two aliens on it, and each alien has its own space treasure mine 3. On each planet, you will pick one alien to ask for space treasure. These aliens are nice, so if an alien just brought treasure up from the mine, it will share it with you 4. For each choice, choose the left alien by pressing the “1” key and the right alien by choosing the “0” key. The choice you make will be highlighted. Ready to practice? a. [The subject will complete three trials in which they will practice selecting an alien] 5. After you choose an alien, you will find out whether you got treasure 6. The treasure looks like this 7. If the alien couldn’t bring treasure up this time, you’ll see an empty circle 8. The circle looks like this 9. If an alien has a good mine, that means it can easily dig up space treasure and it will be very likely to have some to share. It might not have treasure EVERY time you ask, but it will most of the time. Another alien might have a bad mine that is hard to dig through at the moment and won’t have treasure to share most times you ask 10. For example, the alien on the yellow planet has a good mine right now. Try asking it for treasure 10 times by pressing the 1 or 0 key a. [The subject will complete 10 trials in which they practice asking the alien for treasure; they can use either 1 or 0 to select the alien since there is only one alien on the screen] 11. See, this alien shared treasure most of the times you asked, but not every time. Some will be more likely to share because it’s easier to dig right now 12. You can practice choosing now. You have 20 choices to try to figure out which alien has a good mine. Remember, key 1 is for the left alien, and key zero is for the right alien a. [Subject will complete 20 trials in which they practice selecting an alien and evaluating the reward they receive] 13. Good. You might have learned that this alien had treasure more often. Also, even if this alien had a better mine, you couldn’t be sure it had treasure all the time. Each alien is like a game of chance, you can never be sure but you can guess 14. The treasure an alien can give will change during the game. Those with a good mine might get to a part of the mine that is hard to dig. Those with little to share might find easier treasure to dig. Any changes in an alien’s mine will happen slowly, so try to focus to get as much treasure as possible 15. Now that you know how to pick aliens, you can learn to play the whole game. You will travel from earth to one of two planets. Here is the yellow planet. And here is the green planet 16. First you need to choose which spaceship to take. The spaceship can fly to either planet, but one will fly mostly to the green planet, and the other mostly to the yellow planet 17. The planet a spaceship goes to the most won’t change during the game. Pick the one that you think will take you to the alien with the best mine, but remember sometimes you’ll go to the other planet 18. Let’s practice before doing the full game. Remember, you want to find as much space treasure as you can by asking an alien to share with you. This is just a practice round of 20 flights. 19. You will have 3 seconds to make each choice. If you are too slow, you will see a large X appear on each spaceship or alien and that choice will be over a. [This is true for both the spaceship choice and the alien choice, but the instructions only say “alien,” so make sure you mention the spaceship as well] 20. Don’t feel rushed, but please try to make a choice every time 21. Good luck! Remember 1 selects left and 0 selects right a. [Subject will complete 20 trials in which they practice choosing a spaceship and then choosing an alien] 22. That’s the end of the practice. Press any key to see how you did 23. You got N pieces of treasure! 24. Okay, that’s nearly the end of the tutorial. In the real game, the planets, aliens, and spaceships will be new colors, but the rules will be the same. The game is hard, so you will need to concentrate, but don’t be afraid to trust your instincts 25. Here are three hints on how to play the game: a. Hint #1. Remember which aliens have treasure. How good a mine is changes slowly, so an alien that has a lot of treasure to share now will probably be able to share a lot in the near future b. Hint #2. Remember each alien has its own mine. Just because one alien has a bad mine and can’t share very often, does not mean another has a good mine. Also, there are no funny patterns in how an alien shares, like every other time you ask, or depending on which spaceship you took. The aliens are not trying to trick you c. Hint #3. The spaceship you choose is important because often an alien on one planet may be better than the ones on another planet. You can find more treasure by finding the spaceship that is most likely to take you to the right planet 26. Okay, now you know how to play. In the real game, we’ll count how many pieces of space treasure you find 27. Ready? Now it’s time to play the game. Good luck, space traveler! a. [Inform the subject that the game is split into three sections; they can take a short break in between each section at the screen that reads “Take a break! Press any key to continue when ready”] b. [Press the space bar to launch the task if the subject is ready to begin] c. [The task takes about 15-20 minutes so you can step out if you’d like]

Creating DAW parameters

TODO: Dan should finish this portion.

Below is code to clean the raw DAW data, run the generalized linear model, and extract DAW parameters by summing fixed and random effects for each subject. Keep in mind that merging demographic information and brain measures still need to happen. It is beyond the scope of this tool.

#Read in .csv files
luna_pet <- read.csv("luna_pet.csv", header = TRUE)
 
#Separating id column into "id" and "visit"
 
luna_pet <- luna_pet %>%
  separate(id, c("id", "vdate"))
 
#Adding trial number
luna_pet <- luna_pet %>%
  group_by(id, vdate) %>%
  mutate(trial = row_number())
 
# compute visit number
visit_info <- luna_pet %>% 
  select(id, vdate) %>% 
  group_by(id) %>% 
  distinct() %>% 
  mutate(visitnum=rank(as.numeric(as.character(vdate))))
 
#Merge visit number
luna_pet <- merge(luna_pet, 
             visit_info %>% select(id, vdate, visitnum), 
             by=c('id','vdate'))
 
#Creating lagged variables.
luna_pet <- luna_pet %>% 
  group_by(id, visitnum) %>% 
  mutate(choice1lag = lag(choice1),
         choice2lag = lag(choice2),
         statelag = lag(state),
         moneylag = lag(money),
         visitnumlag = lag(visitnum))
 
# transitional variables
luna_pet <- luna_pet %>% 
  mutate(commonrare = as.factor(ifelse((choice1lag == 1 & statelag == 2) |
                                         (choice1lag == 2 & statelag == 3),
                                       'common', 
                                       'rare')), 
         commonraredummy = ifelse(commonrare=="common", 
                                  1, 
                                  -1), 
         moneylagdummy = ifelse(moneylag == 1, 
                                1, 
                                -1), 
         firststagestay = ifelse(choice1 == choice1lag, 
                                 1, 
                                 0), 
         stayswitchwinlose = ifelse(firststagestay==1 & moneylag==0, 'lose-stay',
                             ifelse(firststagestay==1 & moneylag==1, 'win-stay', 
                                    ifelse(firststagestay==0 & moneylag==0,
                                           'lose-switch', 
                                           'win-switch'))))
# model
intmodeltoplot <- glmer(firststagestay ~ 1 + commonraredummy*moneylagdummy + 
                          (commonraredummy*moneylagdummy|id:visitnum),
                        data=luna_pet,
                        family="binomial",
                        glmerControl(optimizer = "bobyqa"))
summary(intmodeltoplot)
 
 
#Extracting random effects
dawranefint <- ranef(intmodeltoplot)
head(dawranefint$`id:visitnum`)
 
#Extracting fixed effects
dawfixedeffectsint <- summary(intmodeltoplot)$coefficients
dawfixedeffectsint
 
#Creating dataframe consisting of MB/MF/Habit parameter.
dawsubjecterms <- data.frame(
  idtemp = row.names(dawranefint$`id:visitnum`), 
  modelbased = dawranefint$`id:visitnum`$`commonraredummy:moneylagdummy` + 
    dawfixedeffectsint[4,1], 
  modelfree = dawranefint$`id:visitnum`$moneylagdummy + 
    dawfixedeffectsint[3,1],
  commonrare = dawranefint$`id:visitnum`$commonraredummy + 
    dawfixedeffectsint[2,1],
  firststagestay = dawranefint$`id:visitnum`$`(Intercept)` + 
    dawfixedeffectsint[1,1])
 
#Creating id column
dawsubjecterms$id <- unlist(lapply(strsplit(as.character(dawsubjecterms$idtemp),
                                            ":"),'[',1))
#Creating visit number column
dawsubjecterms$visitnum <- unlist(lapply(strsplit(as.character(dawsubjecterms$idtemp),
                                                  ":"),'[',2))
 
#Some cleaning for plotting
datereduce <- luna_pet %>% select(id, visitnum) 
 
# merge with model terms
m <- merge(dawsubjecterms,datereduce,by=c('id','visitnum')) %>% distinct() #%>% filter(complete.cases(.))
 
#Z-scores
m <- m %>% mutate(
  modelfree_z = scale(modelfree),
  modelbased_z = scale(modelbased),
  commonrare_z = scale(commonrare),
  firststagestay_z = scale(firststagestay),
  modeldiff_z = modelbased_z - modelfree_z
)

Great!

testing_1_2