Chi-Lin Yu
6 6, 2016
head(dta[,1:6],5)
Subject Channel Condition value.1 value.2 value.3 1 subj1 Fp1 nonword -1.545226 -1.889412 -1.463414 2 subj1 Fp2 nonword -1.373787 -1.853133 -1.751572 3 subj1 F3 nonword -2.856959 -2.690639 -0.926768 4 subj1 F4 nonword -2.302168 -2.675416 -1.816674 5 subj1 C3 nonword -4.778307 -4.948525 -2.399150
tail(dta[,1:6],5)
Subject Channel Condition value.1 value.2 value.3 1356 subj9 FT7 word 1.809377 2.3673330 1.6798440 1357 subj9 FT8 word 1.007716 1.2813160 1.0245420 1358 subj9 A2 word -1.071328 -0.8085886 0.2553779 1359 subj9 VEOG1 word 17.208140 24.4108600 24.2048600 1360 subj9 HEOG1 word 2.666729 4.6142750 4.8465790
str(dta[,1:9],digits.d=1)
'data.frame': 1360 obs. of 9 variables: $ Subject : Factor w/ 20 levels "subj1","subj2",..: 1 1 1 1 1 1 1 1 1 1 ... $ Channel : Factor w/ 34 levels "Fp1","Fp2","F3",..: 1 2 3 4 5 6 7 8 9 10 ... $ Condition: Factor w/ 2 levels "nonword","word": 1 1 1 1 1 1 1 1 1 1 ... $ value.1 : num -2 -1 -3 -2 -5 ... $ value.2 : num -2 -2 -3 -3 -5 ... $ value.3 : num -1.5 -1.8 -0.9 -1.8 -2.4 ... $ value.4 : num -1.3 -1.9 -0.2 -1.5 -1.3 ... $ value.5 : num -1 -1.6 0.8 -0.8 0.5 ... $ value.6 : num -1.7 -1.6 0.3 -0.8 1.1 ...
dta2 <- data_select(data = dta,frames = timepoint , datacol=4:110,subjcol=1, chancol=2,othvarcol=3, select_subj = c(paste("subj",c(2:20),sep="")), select_chan = c(levels(dta$Channel)[c(1:28,30:32)])) dta2$Channel <- as.factor(as.character(dta2$Channel)) dta2$Subject <- as.factor(as.character(dta2$Subject)) head(dta2[,1:6])
Subject Channel Condition value.1 value.2 value.3 1 subj2 Fp1 nonword -1.50746400 -2.75760800 -3.1641520 2 subj2 Fp1 word 0.30547570 -0.18280880 -1.0255810 3 subj2 Fp2 nonword 2.41785600 3.23360400 2.7211370 4 subj2 Fp2 word 3.80168600 5.28677300 4.5428270 5 subj2 F3 nonword -10.06585000 -14.17141000 -12.4640200 6 subj2 F3 word 0.02098846 -0.05941113 -0.2208613
scalp_plot(chan_data = dtasum, frames = timepoint, datacol =3:428, chancol =1 ,cpvarcol =2 , ylim=c(-10,10),color = c("blue","red"))
[1] "The following electrodes will not be plotted :" [1] "A2" "T3" "T4" "T5" "T6"
TableGrob (9 x 11) "arrange": 27 grobs z cells name grob C3 1 ( 5- 5, 4- 4) arrange gtable[layout] C4 2 ( 5- 5, 8- 8) arrange gtable[layout] CP3 3 ( 6- 6, 4- 4) arrange gtable[layout] CP4 4 ( 6- 6, 8- 8) arrange gtable[layout] CPZ 5 ( 6- 6, 6- 6) arrange gtable[layout] CZ 6 ( 5- 5, 6- 6) arrange gtable[layout] F3 7 ( 3- 3, 4- 4) arrange gtable[layout] F4 8 ( 3- 3, 8- 8) arrange gtable[layout] F7 9 ( 3- 3, 2- 2) arrange gtable[layout] F8 10 ( 3- 3,10-10) arrange gtable[layout] FC3 11 ( 4- 4, 4- 4) arrange gtable[layout] FC4 12 ( 4- 4, 8- 8) arrange gtable[layout] FCZ 13 ( 4- 4, 6- 6) arrange gtable[layout] Fp1 14 ( 1- 1, 5- 5) arrange gtable[layout] Fp2 15 ( 1- 1, 7- 7) arrange gtable[layout] FPZ 16 ( 1- 1, 6- 6) arrange gtable[layout] FT7 17 ( 4- 4, 2- 2) arrange gtable[layout] FT8 18 ( 4- 4,10-10) arrange gtable[layout] FZ 19 ( 3- 3, 6- 6) arrange gtable[layout] O1 20 ( 9- 9, 5- 5) arrange gtable[layout] O2 21 ( 9- 9, 7- 7) arrange gtable[layout] P3 22 ( 7- 7, 4- 4) arrange gtable[layout] P4 23 ( 7- 7, 8- 8) arrange gtable[layout] PZ 24 ( 7- 7, 6- 6) arrange gtable[layout] TP7 25 ( 6- 6, 2- 2) arrange gtable[layout] TP8 26 ( 6- 6,10-10) arrange gtable[layout] 27 ( 1- 1,11-11) arrange gtable[guide-box]
Fig <- ciplot(dta2,frames = timepoint, datacol=4:429, subjcol=1, chancol=2, othvarcol=3, cpvarcol = 3, fun=samplemean <- function(x, d){return(mean(x[d]))}, bootnum=500, bootintval=c(.025,.975), bootalpha=0.5)+ ylim(-5,5)
dta2_test <- chan_test(dta2,4:429,chancol=2,testtype="erpfatest", design_model=(~Subject+Condition), design0_model=(~Subject))
List of 10 $ pval : Named num [1:426] 0.92 0.947 0.951 0.664 0.283 ... ..- attr(*, "names")= chr [1:426] "value.1" "value.2" "value.3" "value.4" ... $ correctedpval: Named num [1:426] 0.989 0.989 0.989 0.988 0.69 ... ..- attr(*, "names")= chr [1:426] "value.1" "value.2" "value.3" "value.4" ... $ significant : Named int [1:50] 148 149 150 151 152 153 154 161 162 181 ... ..- attr(*, "names")= chr [1:50] "value.148" "value.149" "value.150" "value.151" ... $ pi0 : num 1 $ test : Named num [1:426] 0.01051 0.00465 0.00389 0.1965 1.23797 ... ..- attr(*, "names")= chr [1:426] "value.1" "value.2" "value.3" "value.4" ... $ df1 : int 15 $ df0 : int 16 $ nbf : int 3 $ signal : num [1, 1:426] -0.0643 -0.0549 0.0408 0.1621 0.335 ... $ r2 : Named num [1:426] 0.0007 0.00031 0.000259 0.01293 0.076239 ... ..- attr(*, "names")= chr [1:426] "value.1" "value.2" "value.3" "value.4" ...
Fig <- mcplot(tests_rst = dta2_test, type = "test", multi = T, cor = FALSE, data = dta2 , frames = seq(0,1700,by=4) , datacol = 4:429, subjcol = 1 , chancol = 2 , othvarcol = 3, cpvarcol = 429 , significant_col = "pink" , significant_alpha = 0.2)
NULL
Fig <- mcplot(tests_rst = dta2_test, type = "signal", multi = T,cor = FALSE, data = dta2,frames = seq(0,1700,by=4), datacol = 4:429, subjcol = 1 , chancol = 2 , othvarcol =3, cpvarcol = 3, significant_col = "pink" , significant_alpha = 0.2, ci.type = "boot", level = 0.95, fun = samplemean <- function(x, d){return(mean(x[d]))}, bootnum = 10, bootalpha=0.3)
Fig <- Fig+ scale_color_manual(values = c("Blue","Red"),name = "Cond")+ scale_fill_manual(values = c("Blue","Red"),name = "Cond")+ labs(list(title = "Channels Test Results",x="Time Points"))+ theme_bw()+ theme(legend.position=c(0.7,0.075), legend.direction = "horizontal")
Fig <- mcplot(tests_rst = dta2_test, type = "signal", multi = T,cor = FALSE, data = dta2,frames = seq(0,1700,by=4), datacol = 4:429, subjcol = 1 , chancol = 2 , othvarcol =3, cpvarcol = 3, significant_col = "pink" , significant_alpha = 0.2, ci.type = "scb", level = 0.95, ci.alpha = 0.3, cv.degree=2, cv.interval = NULL, scbtype = "normal")+ theme(legend.position=c(0.7,0.075), legend.direction = "horizontal")
dtaTP7 <- data_select(data = dta2,frames = timepoint, datacol=4:110,subjcol=1, chancol=2,othvarcol=3, select_chan = "TP7") Fig <- mcplot(tests_rst = dta2_test$TP7, type = "signal", multi = F,cor = FALSE, data = dtaTP7,frames = timepoint, datacol = 4:429, subjcol = 1 , chancol = 2 , othvarcol =3, cpvarcol = 3, significant_col = "grey50" , significant_alpha = 0.3, ci.type = "boot")+ theme_bw()+theme(legend.position = "none")+ scale_x_continuous(breaks=c(seq(0,1700,by=64)))
for (i in c(100,320,960)){ nam <- paste("T",i,sep="") assign(nam,coord_plot(tests_rst =dta2_test,frames=timepoint, elect_coord=readRDS("Elect_Location.RData"), type = "correctedpval",logscale = T, show = i, point_size = 10, show_na_ele = F, text = T,text_size = 3,text_col = "black", circle = T,nose = T,cir_nose_col="black")+ scale_fill_gradient2(low="blue",high = "red", midpoint = -log(0.05), na.value = "grey80", limit=c(0,25), guide_colorbar(title = "-Log \nCorrected \np-value"))+ theme_nothing(legend = T)+ labs(list(title = paste("Frames = ",i)))) }
[1] "The following electrodes will not be plot :" [1] "A2" "T3" "T4" "T5" "T6" [1] "The following electrodes will not be plot :" [1] "A2" "T3" "T4" "T5" "T6" [1] "The following electrodes will not be plot :" [1] "A2" "T3" "T4" "T5" "T6"
grid.arrange(T100,T320,T960,ncol=3)