ALFF-CBF SURF COUPLING

# read in packages
library(plyr)
## Warning: package 'plyr' was built under R version 3.2.5
# read in demos
alffCbf_subjDemos <- read.csv("/data/jux/BBL/projects/coupling/subjectsLists/n831_rest_cbf_finalSampleWmean_imageOrder.csv")
alffCbf_subjDemos$sex <- as.factor(alffCbf_subjDemos$sex)

# get all lh files
setwd("/data/jux/BBL/projects/coupling/couplingSurfaceMaps/alffCbf/lh/stat")
lh_alffCbf_files = list.files(pattern="*.asc")
lh_alffCbf_data = do.call(rbind, lapply(lh_alffCbf_files, function(x) read.table(x, stringsAsFactors = FALSE)))
lh_alffCbf_coupling <- as.data.frame(lh_alffCbf_data$V5)
lh_alffCbf_coupling_n <- t(as.data.frame(split(lh_alffCbf_coupling,1:831)))

# get mean coupling
mean_lh_alffCbf_coupling_n <- rowMeans(lh_alffCbf_coupling_n)
write.csv(mean_lh_alffCbf_coupling_n,"n831_mean_lh_alffCbf_coupling",row.names=FALSE)

# run lh model lm test
for (i in 1:10242) {
  lh_alffCbf_ttest <- lm(lh_alffCbf_coupling_n[,i] ~ 1)
}

# run lh model t test
for (i in 1:10242) {
  lh_alffCbf_ttest_2 <- t.test(lh_alffCbf_coupling_n[,i], alffCbf_subjDemos$meanCoupling)
}

# print out the results
summary(lh_alffCbf_ttest)
## 
## Call:
## lm(formula = lh_alffCbf_coupling_n[, i] ~ 1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -15.6062  -3.1448  -0.5051   3.2906  18.1890 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3.1448     0.1553   20.26   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.476 on 830 degrees of freedom
lh_alffCbf_ttest_2
## 
##  Welch Two Sample t-test
## 
## data:  lh_alffCbf_coupling_n[, i] and alffCbf_subjDemos$meanCoupling
## t = -0.40742, df = 830.27, p-value = 0.6838
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.3680287  0.2415082
## sample estimates:
## mean of x mean of y 
##  3.144838  3.208098
# get all rh files
setwd("/data/jux/BBL/projects/coupling/couplingSurfaceMaps/alffCbf/rh/stat")
rh_alffCbf_files = list.files(pattern="*.asc")
rh_alffCbf_data = do.call(rbind, lapply(rh_alffCbf_files, function(x) read.table(x, stringsAsFactors = FALSE)))
rh_alffCbf_coupling <- as.data.frame(rh_alffCbf_data$V5)
rh_alffCbf_coupling_n <- t(as.data.frame(split(rh_alffCbf_coupling,1:831)))

# run rh model t test
for (i in 1:10242) {
  rh_alffCbf_ttest <- lm(lh_alffCbf_coupling_n[,i] ~ 1)
}

# run lh model t test
for (i in 1:10242) {
  rh_alffCbf_ttest_2 <- t.test(rh_alffCbf_coupling_n[,i], alffCbf_subjDemos$meanCoupling)
}

# print out the results
summary(rh_alffCbf_ttest)
## 
## Call:
## lm(formula = lh_alffCbf_coupling_n[, i] ~ 1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -15.6062  -3.1448  -0.5051   3.2906  18.1890 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3.1448     0.1553   20.26   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.476 on 830 degrees of freedom
rh_alffCbf_ttest_2
## 
##  Welch Two Sample t-test
## 
## data:  rh_alffCbf_coupling_n[, i] and alffCbf_subjDemos$meanCoupling
## t = -1.8892, df = 830.22, p-value = 0.05921
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.6656611  0.0127221
## sample estimates:
## mean of x mean of y 
##  2.881629  3.208098