forked from drqm/working_memory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
124 lines (124 loc) · 2.98 KB
/
.Rhistory
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
114
115
116
117
118
119
120
121
122
123
124
library(ggplot2)
library(lme4)
library(lmerTest)
install.library('lmerTest')
install.package('lmerTest')
install.packages('lmerTest')
install.packages('lmerTest')library(lmerTest)
library(lmerTest)
log_dir <- "../../misc/working_memory_logs"
fig_dir <- "../../scratch/working_memory/results/figures"
bnames <- c('maintenance','manipulation')
lnames <- c('recognize','invert')
subjects <- 11:90
scount <- 0
d <- c()
for (sub in subjects){
scount <- scount + 1
for (b in 1:length(lnames)){
ln <- lnames[b]
dfile <- sprintf('%s/%04.f_%s_MEG.csv',log_dir,sub,ln)
print(dfile)
d0 <- read.table(dfile,sep=',',header=T)
d0$block <- bnames[b]
if (scount == 1 & b == 1){
d <- d0
}else{
d <- rbind(d,d0)
}
}
}
pwd
cwd
wd
cd
getwd()
setwd('/projects/MINDLAB2020_MEG-AuditoryPatternRecognition/scripts/working_memory/')
setwd('/projects/MINDLAB2020_MEG-AuditoryPatternRecognition/scripts/working_memory/')log_dir <- "../../misc/working_memory_logs"
fig_dir <- "../../scratch/working_memory/results/figures"
bnames <- c('maintenance','manipulation')
lnames <- c('recognize','invert')
```
```{r}
## Load data:
subjects <- 11:90
scount <- 0
d <- c()
for (sub in subjects){
scount <- scount + 1
for (b in 1:length(lnames)){
ln <- lnames[b]
dfile <- sprintf('%s/%04.f_%s_MEG.csv',log_dir,sub,ln)
print(dfile)
d0 <- read.table(dfile,sep=',',header=T)
d0$block <- bnames[b]
if (scount == 1 & b == 1){
d <- d0
}else{
d <- rbind(d,d0)
}
}
}
```
d
d
unique(d$subject)
print(unique(d$subject))
d
subjects <- 11:90
scount <- 0
d <- c()
for (sub in subjects){
scount <- scount + 1
for (b in 1:length(lnames)){
ln <- lnames[b]
dfile <- sprintf('%s/%04.f_%s_MEG.csv',log_dir,sub,ln)
print(dfile)
d0 <- read.table(dfile,sep=',',header=T)
print(d0)
d0$block <- bnames[b]
if (scount == 1 & b == 1){
d <- d0
}else{
d <- rbind(d,d0)
}
}
}
d$subject
subjects <- 11:90
scount <- 0
d <- c()
for (sub in subjects){
scount <- scount + 1
for (b in 1:length(lnames)){
ln <- lnames[b]
dfile <- sprintf('%s/%04.f_%s_MEG.csv',log_dir,sub,ln)
print(dfile)
d0 <- read.table(dfile,sep=',',header=T)
d0$subject = as.factor(as.character(d0$subject))
d0$block <- bnames[b]
if (scount == 1 & b == 1){
d <- d0
}else{
d <- rbind(d,d0)
}
}
}
d
unique(d$subject)
d$accuracy <- as.numeric(d$type == d$response)
d2 <- aggregate(d$accuracy, by=list(d$subject,d$block), mean)
colnames(d2) <- c('subject','block','accuracy')
d2
ap <- ggplot(data=d2, aes(block,accuracy, fill = block)) +
geom_point(alpha=.1) +
geom_line(alpha = .1, aes(group=subject)) +
geom_violin(alpha = .1) +
scale_fill_manual(values=c('blue','red'))+
theme_bw()
ggsave(paste0(fig_dir,'/behavioral_accuracy.pdf'), ap, dpi= 300, width=15, height=10,units='cm')
m0 <- glmer(accuracy~block + (1+block|subject), data = d, family = 'binomial')
summary(m0)
exc <- unique(d2[d2$accuracy <= 0.5,'subject'])
print(exc)
quit()