This document is to clean, analyze, and present data for a study about visual and orthographic imagery and its effects on memory for face and name pairs. We analyze one behavioral experiment with two testing blocks, each with their own hypotheses, as well as the Internal Representations Questionnaire (IRQ) developed by Roebuck and Lupyan (2020). We predict that in block 1 (see a written name, choose the corresponding face image), high scores for orthographic imagery based on IRQ responses would predict more accurate face selection given an orthographically represented name. For block 2 (see a face, select the corresponding name), high scores for visual imagery would yield more accurate name selection given a face image. We predict no interaction between internal representation modality (orthographic vs. visual) and block type (see-name-choose-face vs. see-face-choose-name), given that imagery of either type could support memory for faces and names given either task.
setwd("Documents/experiments/imagery/toy_data/") # setting working directory to where data files are stored
temp <- list.files(pattern="*.csv") # getting file name of everything in directory
d <- lapply(temp, read_csv, show_col_types = FALSE) # applying read function to all CSVs in list of file names
d <- rbindlist(d, fill = TRUE) # binding them together into one big dataframe ;)
#just getting the essential parts of the experiment to calculate face-name memory accuracy
imagery_exp <- d %>% filter(exp_section %in% c("training", "selectFace_response", "selectName_response")) %>% select(worker_id, exp_section, stimulus, face, response)
# recoding their responses
imagery_exp$response <- recode_if(x = imagery_exp$response,
condition = imagery_exp$exp_section == "selectName_response",
`0` = "Alex",
`1` = "Cameron",
`2` = "Charlie",
`3` = "Chris",
`4` = "Jamie",
`5` = "Jordan",
`6` = "Kendall",
`7` = "Parker",
`8` = "Sam",
`9` = "Taylor") # for name buttons
imagery_exp$response <- recode_if(x = imagery_exp$response,
condition = imagery_exp$exp_section == "selectFace_response",
`0` = "faces/CFD-MF-302-027-N_small.jpg",
`1` = "faces/CFD-MF-330-001-N_small.jpg",
`2` = "faces/CFD-MF-338-001-N_small.jpg",
`3` = "faces/CFD-MF-342-022-N_small.jpg",
`4` = "faces/CFD-MF-344-012-N_small.jpg",
`5` = "faces/CFD-MM-306-010-N_small.jpg",
`6` = "faces/CFD-MM-312-002-N_small.jpg",
`7` = "faces/CFD-MM-317-061-N_small.jpg",
`8` = "faces/CFD-MM-318-003-N_small.jpg",
`9` = "faces/CFD-MM-322-002-N_small.jpg") # for face buttons
# cleaning up some file names to make it a bit simpler
imagery_exp$stimulus <- gsub(c("names/"), c(""), imagery_exp$stimulus)
imagery_exp$stimulus <- gsub(c(".m4a"), c(""), imagery_exp$stimulus)
imagery_exp$stimulus <- gsub(c('<h1 style="color:red;font-size:40px;">'), c(""), imagery_exp$stimulus)
imagery_exp$stimulus <- gsub(c('</h1>'), c(""), imagery_exp$stimulus)
imagery_exp$stimulus <- gsub(c('<img src= faces/'), c(""), imagery_exp$stimulus)
imagery_exp$stimulus <- gsub(c('_medium.jpg></img><br><br>'), c(""), imagery_exp$stimulus)
imagery_exp$face <- gsub(c('faces/'), c(""), imagery_exp$face)
imagery_exp$face <- gsub(c('_medium.jpg'), c(""), imagery_exp$face)
imagery_exp$response <- gsub(c("faces/"), c(""), imagery_exp$response)
imagery_exp$response <- gsub(c("_small.jpg"), c(""), imagery_exp$response)
imagery_exp <- mutate_all(imagery_exp, .funs=tolower) # make everything lowercase
imagery_exp$general_section <- if_else(imagery_exp$exp_section == "training", "train", "test") # making a general section label
# removing unfinished data
total_trials <- imagery_exp %>% group_by(worker_id) %>% summarise(total_trials = n())
bad_guys <- total_trials %>% filter(total_trials < 11)
imagery_exp <- imagery_exp %>% filter(!worker_id %in% bad_guys$worker_id)
rm(total_trials)
rm(bad_guys)
imagery_exp_cleaned <- data_frame() # create a list to hold cleaned stuff
num_ids <- length(unique(imagery_exp$worker_id)) %>% as.numeric() # get the full number of unique ids
for (index in 1:num_ids){
sub_id <- unique(imagery_exp$worker_id)[index]
subset <- imagery_exp %>% filter(worker_id == sub_id) %>%
pivot_wider(names_from = general_section,
id_cols = worker_id,
values_from = c(stimulus, face, response, exp_section)) %>%
unnest() %>%
select(worker_id, exp_section_test, stimulus_train, face_train, stimulus_test, response_test)
subset <- mutate_all(subset, .funs=tolower)
subset$correct_response <- rep(x = c(NA), times = 10)
for(i in c(1:5)){
prompt <- subset$stimulus_test[i]
truth <- subset %>% filter(stimulus_train == prompt)
subset$correct_response[i] <- truth$face_train
}
for(j in c(6:10)){
prompt <- subset$stimulus_test[j]
truth <- subset %>% filter(face_train == prompt)
subset$correct_response[j] <- truth$stimulus_train
}
subset$hit <- if_else(subset$response_test == subset$correct_response, 1, 0)
imagery_exp_cleaned = rbind(imagery_exp_cleaned, subset)
}
rm(subset)
rm(truth)