-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroc_behavioral_summary_stats.Rmd
More file actions
114 lines (80 loc) · 3.58 KB
/
Copy pathroc_behavioral_summary_stats.Rmd
File metadata and controls
114 lines (80 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
title: "roc_behavioral_summary_stats"
author: "Ben Smith"
date: "9/14/2021"
output: html_document
---
```{r setup, include=FALSE}
library(dplyr)
knitr::opts_chunk$set(echo = TRUE)
#data_path <- "../../../files/data/"
Sys.setenv(R_CONFIG_ACTIVE = Sys.info()["nodename"])
data_dir <- config::get("dev_analysis_data_dir")
roc_task_dir <- paste0(config::get("dropbox_path"),"/Berkman Lab/Devaluation/Tasks/ROC/output")
```
```{r}
roc_events_raw <- readr::read_csv(paste0(config::get("dev_scripts_path"), "/fMRI/fx/multiconds/ROC/betaseries/events.csv"))
```
codes:
1 = look neutral, 2 = look no crave, 3 = look crave, 4 = regulate crave
# https://uosanlab.slack.com/archives/C1K1SEA3T/p1631229602021000?thread_ts=1630105278.004000&cid=C1K1SEA3T
See also https://raw.githubusercontent.com/UOSAN/ROC/00d0628e488c7a95697d44bc8db9d4cf472590a7/ROC_R1scan.txt
```{r}
roc_events_raw$instruction <- ""
roc_events_raw[roc_events_raw$condition %in% c(1,2,3),"instruction"] <- "Look"
roc_events_raw[roc_events_raw$condition==4,"instruction"] <- "Regulate"
```
```{r}
roc_events_raw$stimulus <- ""
roc_events_raw[roc_events_raw$condition==1,"stimulus"] <- "Neutral"
roc_events_raw[roc_events_raw$condition==2,"stimulus"] <- "No Crave"
roc_events_raw[roc_events_raw$condition %in% c(3,4),"stimulus"] <- "Crave"
roc_events_raw$condition_label<-paste0(roc_events_raw$stimulus,"_",roc_events_raw$instruction)
```
```{r}
table(roc_events_raw$condition_label)
```
Now, let's import the data about each stimulus that was presented.
```{r}
library(rmatio)
matfile2<-rmatio::read.mat(paste0(roc_task_dir,"/DEV025_5_stimuli_10-Oct-2019_08-50.mat"))[[1]]
matfile_df_list <- lapply(matfile2,function(stimulus_item){
return(data.frame("instruction_filename"=stimulus_item[[1]],"food_filename"=stimulus_item[[2]],"food_name"=stimulus_item[[3]]))
})
stimulus_key_df <- do.call(rbind,matfile_df_list)
stimulus_key_df$stimulus_key_index=1:nrow(stimulus_key_df)
```
```{r}
readr::write_csv(roc_events_raw,file = paste0(data_dir,"roc_behavioral_data_all.csv"))
```
Now get the summary stats.
What summary statistics do we want?
Basic:
- ratings in each condition
- Basic inhibitory control: look-regulate
- Unhealthy food-related inhibitory control: [unhealthy] look-regulate (pre-reg)
- Unhealthy food-related inhibitory control: [unhealthy] look-regulate - [healthy] [look-regulate] (pre-reg)
That'll do.
```{r}
roc_events_raw.1<-roc_events_raw
roc_events_raw.1[roc_events_raw.1$rt==0,"rt"]<-NA #these are actually NA
roc_events_raw.1$rating <-as.double(roc_events_raw.1$rating)
condition_ratings <- roc_events_raw.1 %>% select(-file) %>% group_by(subjectID,wave,run,instruction,stimulus,condition_label) %>%
summarise(mean_rating=mean(rating,na.rm = TRUE),mean_rt=mean(rt,na.rm=TRUE),
non_response_count = sum(is.na(rating))) %>% ungroup()
```
```{r}
mean_ratings <- condition_ratings %>% select(subjectID,wave,run,condition_label,mean_rating) %>% group_by(subjectID,wave,run) %>%
tidyr::spread(key = "condition_label",value="mean_rating")
mean_rts <- condition_ratings %>% select(subjectID,wave,run,condition_label,mean_rt) %>% group_by(subjectID,wave,run) %>%
tidyr::spread(key = "condition_label",value="mean_rt")
mean_ratings$Crave_Regulate_Minus_Look <- mean_ratings$Crave_Regulate - mean_ratings$Crave_Look
mean_ratings$Crave_Minus_Neutral <- mean_ratings$Crave_Look -mean_ratings$Neutral_Look
mean_ratings$Crave_Minus_NoCrave <- mean_ratings$Crave_Look -mean_ratings$`No Crave_Look`
```
```{r}
mean_ratings
```
```{r}
readr::write_csv(mean_ratings,file=paste0(data_dir,"roc_summary_stats.csv"))
```