Skip to content

Commit c8dbd73

Browse files
author
jake-westfall
committed
Add summary result files, simulation code, some figure code
1 parent 2968e1e commit c8dbd73

File tree

1,207 files changed

+5080
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,207 files changed

+5080
-1
lines changed

README.md

Lines changed: 54 additions & 1 deletion

figures/figure1.R

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# replace with a directory on your machine
2+
path <- "/Users/Jake/Desktop/"
3+
4+
5+
# define helper functions ----------------------------------------
6+
7+
8+
# from the FIAR package
9+
# https://github.com/cran/FIAR/blob/master/R/hrfConvolve.R
10+
hrfConvolve <-
11+
function (x=NULL, scans = NA, onsets = c(), durations = c(), rt = NA,
12+
SNR=0, mean = FALSE, a1 = 6, a2 = 12, b1 = 0.9, b2 = 0.9,
13+
cc = 0.2)
14+
{
15+
hrf <- function(x, a1, a2, b1, b2, c) {
16+
d1 <- a1 * b1
17+
d2 <- a2 * b2
18+
c1 <- (x/d1)^a1
19+
c2 <- c * (x/d2)^a2
20+
res <- c1 * exp(-(x - d1)/b1) - c2 * exp(-(x - d2)/b2)
21+
res
22+
}
23+
if (is.null(x)){
24+
numberofonsets <- length(onsets)
25+
if (length(durations) == 1) {
26+
durations <- rep(durations, numberofonsets)
27+
}
28+
29+
stimulus <- rep(0, scans)
30+
for (i in 1:numberofonsets) {
31+
for (j in onsets[i]:(onsets[i] + durations[i] - 1)) {
32+
stimulus[j] <- 1
33+
}
34+
}
35+
hrfnn <- convolve(stimulus, hrf(scans:1, a1, a2, b1/rt,b2/rt, cc))
36+
37+
if(SNR>0){
38+
sdS <- sd(hrfnn)
39+
noise=rnorm(scans,sd=sdS/SNR)
40+
#Zx <- x/sd(x)
41+
#sdN <- sdS/SNR
42+
hrfnn <- hrfnn + noise
43+
}
44+
else{hrfnn <- hrfnn}
45+
46+
if (mean) {
47+
hrfnn - mean(hrfnn)
48+
}
49+
else {
50+
hrfnn
51+
}
52+
}
53+
else{ hrfnn <- convolve(x, hrf(length(x):1, a1, a2, b1,b2, cc))
54+
55+
if(SNR>0){
56+
sdS <- sd(hrfnn)
57+
noise <- rnorm(length(x),sd=sdS/SNR)
58+
59+
hrfnn <- hrfnn + noise
60+
}
61+
else{hrfnn <- hrfnn}
62+
63+
if (mean) {
64+
hrfnn - mean(hrfnn)
65+
}
66+
else {
67+
hrfnn
68+
}
69+
}
70+
71+
}
72+
73+
# function to build activation sequence
74+
act <- function(num_trials, pad=25, ISI=1:3, stim_sd=0){
75+
if(length(ISI)==1) ISI <- rep(ISI,2)
76+
ans <- c(unlist(lapply(seq(num_trials), function(x){
77+
c(1, rep(0, sample(ISI, 1)))
78+
})), numeric(pad))
79+
ans[ans>0] <- 1 + stim_sd*scale(rnorm(sum(ans>0)))
80+
return(ans)
81+
# return(ans * (rnorm(length(ans), mean=1, sd=stim_sd)))
82+
}
83+
84+
# function to draw a single panel w/ specified parameters
85+
hrf_plot <- function(means=c(1,1), stim_sd=0, main=""){
86+
act1 <- means[1]*head(c(act(5, ISI=3, stim_sd=stim_sd), numeric(15), act(5, ISI=3, stim_sd=stim_sd), numeric(30)), -15)
87+
act2 <- means[2]*head(c(numeric(30), act(5, ISI=3, stim_sd=stim_sd), numeric(15), act(5, ISI=3, stim_sd=stim_sd)), -15)
88+
plot(y=c(-.25,1.9), x=c(0,length(act1)), cex=0, xlab="", xaxt="n",
89+
yaxt="n", ylab="Neural activation\n(arbitrary scale)",
90+
mgp=c(1,1,0), main=main)
91+
axis(side=1, tick=FALSE, line=-1)
92+
lines(y=rep(act1, each=10), x=seq(length(act1)*10)/10, col="red")
93+
lines(y=rep(act2, each=10), x=seq(length(act2)*10)/10, col="blue")
94+
lines(hrfConvolve(x=act1, rt=1), type="l", col="red")
95+
conv2 <- hrfConvolve(x=act2, rt=1)
96+
conv2[1:20] <- 0
97+
lines(conv2, type="l", col="blue")
98+
abline(h=means, lty=2:3)
99+
}
100+
101+
102+
# build the plot! ---------------------------------------------------------
103+
104+
105+
png(paste0(path,"time_series.png"), height=10, width=8,
106+
units="in", res=200, pointsize=19)
107+
layout(cbind(c(rep(1:3, each=4),7,7,rep(4:6, each=4))))
108+
par(mar=c(.5,3,1,1)+.1)
109+
par(oma=c(2,0,2,0))
110+
x <- c(1,5,9,13,17,31,35,39,43,47,61,65,69,73,77,91,95,99,103,107)
111+
labs <- c("chair","house","tree","desk","spoon",
112+
"run","pay","speak,","climb","read",
113+
"road","paper","bread","mug","sign",
114+
"eat","take","see","find","ask")
115+
116+
hrf_plot(means=c(1.25,.75), stim_sd=0, main="Participant 1")
117+
text(x=c(40), y=1.7, cex=.75,
118+
labels="Stimulus presentations")
119+
arrows(x0=c(37,52), x1=c(31,59), length=.05,
120+
y0=1.58, y1=c(.8, 1.27), lwd=.8)
121+
hrf_plot(means=c(1.1,.9), stim_sd=0, main="Participant 2")
122+
text(x=x, y=c(1.8,-.15), labels=labs, cex=.75,
123+
col=rep(c("red","blue"),each=5))
124+
hrf_plot(means=c(1.4,.6), stim_sd=0, main="Participant 3")
125+
126+
set.seed(45634)
127+
hrf_plot(means=c(1.25,.75), stim_sd=.25, main="Participant 1")
128+
text(x=43, y=1.78, cex=.75,
129+
labels="Variable activations estimated from the data")
130+
arrows(x0=c(38,55), x1=c(35,60), length=.05,
131+
y0=1.65, y1=c(.95, 1.35), lwd=.8)
132+
set.seed(45634)
133+
hrf_plot(means=c(1.1,.9), stim_sd=.25, main="Participant 2")
134+
text(x=x, y=c(1.8,-.15), labels=labs, cex=.75,
135+
col=rep(c("red","blue"),each=5))
136+
set.seed(45634)
137+
hrf_plot(means=c(1.4,.6), stim_sd=.25, main="Participant 3")
138+
139+
mtext("Time (in seconds)", side=1, line=.5, outer=TRUE, cex=.9)
140+
mtext("A: Standard model (stimulus effects ignored)", side=3, line=.25, outer=TRUE)
141+
mtext("Time (in seconds)", side=3, line=16.5, cex=.9)
142+
mtext("B: Random stimulus model", side=3, line=14.5)
143+
dev.off()
144+
145+
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
10.6 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
12.5 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.
9.41 KB
Binary file not shown.

0 commit comments

Comments
 (0)