library(xtable)
library(dplyr)
library(foreign)
library(dplyr)
library(kableExtra)

Particpants with VO2 Test Notes

ID FIT_TestEnd_notes
7097 Subject was beta blocked but achieved HR goal first
7057 Reached RPE goal of 15; subject was beta blocked
7081 unable to accurately monitor HR and near max values from participant

Extract Mean Times-Series & Z-Stat for every participant
Example: Significant Cluster Results Report:

featquery_BrainStem_meants<-read.delim("/Users/alyshagilmore/Downloads/restingstate_crew/fitness_hipptot.gfeat/cope1.feat/SIG_BRAIN_STEM/mean_mask_ts.txt" ,header = FALSE)
BrainSTEM_mts<-featquery_BrainStem_meants$V1
DATA<-cbind(DATA,BrainSTEM_mts)
DATA$BrainSTEM_mts<-as.numeric(DATA$BrainSTEM_mts)

featquery_BrainStem_Zstat<-read.delim("/Users/alyshagilmore/Downloads/restingstate_crew/fitness_hipptot.gfeat/cope1.feat/SIG_BRAIN_STEM/max_thresh_zstat2_ts.txt" ,header = FALSE)
BrainSTEM_Zstat<-featquery_BrainStem_Zstat$V1
DATA<-cbind(DATA,BrainSTEM_Zstat)
DATA$BrainSTEM_Zstat<-as.numeric(DATA$BrainSTEM_Zstat)

cor.test(DATA$CRFrel, DATA$BMI)
## 
##  Pearson's product-moment correlation
## 
## data:  DATA$CRFrel and DATA$BMI
## t = -3.5386, df = 32, p-value = 0.001255
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.7364227 -0.2341522
## sample estimates:
##        cor 
## -0.5303256
cor.test(DATA$BrainSTEM_Zstat, DATA$WEIGHT)
## 
##  Pearson's product-moment correlation
## 
## data:  DATA$BrainSTEM_Zstat and DATA$WEIGHT
## t = -1.014, df = 32, p-value = 0.3182
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.4856305  0.1719870
## sample estimates:
##        cor 
## -0.1764405
model1<-(lm(BrainSTEM_Zstat ~CRFrel* BMI, data=DATA))
visreg::visreg(model1,"CRFrel", by="BMI", overlay=TRUE )

featquery_Striatal_Limbic<-read.delim("/Users/alyshagilmore/Downloads/restingstate_crew/fitness_hipptot.gfeat/cope1.feat/MNI_STRIATAL_LIMBIC/mean_mask_ts.txt" ,header = FALSE)
Striatal_Limbic<-featquery_Striatal_Limbic$V1
DATA<-cbind(DATA,Striatal_Limbic)
DATA$Striatal_Limbic<-as.numeric(DATA$Striatal_Limbic)


write.csv(DATA, "Bilat_Hipp_CRFrel_ROI_TS.csv")
#cor.test(DATA$BrainSTEM_Zstat,DATA$HR_DIFFERENCE)
#cor.test(DATA$BrainSTEM_Zstat,DATA$PEAK_HR)
#cor.test(DATA$BrainSTEM_Zstat,DATA$PEAK)
cor.test(DATA$BrainSTEM_Zstat,DATA$PEAK_RER)
## 
##  Pearson's product-moment correlation
## 
## data:  DATA$BrainSTEM_Zstat and DATA$PEAK_RER
## t = 1.6172, df = 32, p-value = 0.1156
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06977465  0.56090431
## sample estimates:
##       cor 
## 0.2748769
cor.test(DATA$BrainSTEM_Zstat,DATA$PEAK_METS)
## 
##  Pearson's product-moment correlation
## 
## data:  DATA$BrainSTEM_Zstat and DATA$PEAK_METS
## t = 4.1765, df = 32, p-value = 0.0002128
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.3200874 0.7762179
## sample estimates:
##       cor 
## 0.5939612
cor.test(DATA$BrainSTEM_Zstat,DATA$PEAK_VE)
## 
##  Pearson's product-moment correlation
## 
## data:  DATA$BrainSTEM_Zstat and DATA$PEAK_VE
## t = 1.604, df = 32, p-value = 0.1185
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.07202045  0.55935534
## sample estimates:
##      cor 
## 0.272789
cor.test(DATA$BrainSTEM_Zstat,DATA$PEAK_VT)
## 
##  Pearson's product-moment correlation
## 
## data:  DATA$BrainSTEM_Zstat and DATA$PEAK_VT
## t = 1.2833, df = 32, p-value = 0.2086
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1263863  0.5204626
## sample estimates:
##       cor 
## 0.2212348
summary(lm(BrainSTEM_Zstat~ WEIGHT, data = DATA))
## 
## Call:
## lm(formula = BrainSTEM_Zstat ~ WEIGHT, data = DATA)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -53.87  -7.23   1.95  16.04  32.95 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  14.0048    18.3123   0.765    0.450
## WEIGHT       -0.2156     0.2126  -1.014    0.318
## 
## Residual standard error: 20.8 on 32 degrees of freedom
## Multiple R-squared:  0.03113,    Adjusted R-squared:  0.0008541 
## F-statistic: 1.028 on 1 and 32 DF,  p-value: 0.3182
summary(lm(BrainSTEM_Zstat~ BMI, data = DATA))
## 
## Call:
## lm(formula = BrainSTEM_Zstat ~ BMI, data = DATA)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -53.288  -7.519   1.528  16.910  34.154 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  20.1958    17.5037   1.154    0.257
## BMI          -0.7667     0.5387  -1.423    0.164
## 
## Residual standard error: 20.49 on 32 degrees of freedom
## Multiple R-squared:  0.05953,    Adjusted R-squared:  0.03014 
## F-statistic: 2.026 on 1 and 32 DF,  p-value: 0.1644
summary(lm(BrainSTEM_Zstat~ BMI+WEIGHT, data = DATA))
## 
## Call:
## lm(formula = BrainSTEM_Zstat ~ BMI + WEIGHT, data = DATA)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -53.831  -4.224   2.780  15.521  31.320 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  16.1518    18.1893   0.888    0.381
## BMI          -2.0122     1.5423  -1.305    0.202
## WEIGHT        0.5171     0.5997   0.862    0.395
## 
## Residual standard error: 20.57 on 31 degrees of freedom
## Multiple R-squared:  0.08156,    Adjusted R-squared:  0.0223 
## F-statistic: 1.376 on 2 and 31 DF,  p-value: 0.2675
#cor.test(DATA$Left_Pallidum,DATA$WEIGHT)
#cor.test(DATA$Left_Pallidum,DATA$BMI)
#NO OTHER ROIS SIG WITH BMI WEIGHT
#cor.test(DATA$PEAK_VT, DATA$Left_Pallidum)
cor.test(DATA$Lpallidum_Zstat,DATA$PEAK_RER)
## 
##  Pearson's product-moment correlation
## 
## data:  DATA$Lpallidum_Zstat and DATA$PEAK_RER
## t = 3.0041, df = 32, p-value = 0.00514
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1555283 0.6966906
## sample estimates:
##       cor 
## 0.4690259
cor.test(DATA$Lpallidum_Zstat,DATA$PEAK_RPE)
## 
##  Pearson's product-moment correlation
## 
## data:  DATA$Lpallidum_Zstat and DATA$PEAK_RPE
## t = 3.1032, df = 32, p-value = 0.003984
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1705316 0.7045377
## sample estimates:
##       cor 
## 0.4809613
cor.test(DATA$Lpallidum_Zstat,DATA$PEAK_METS)
## 
##  Pearson's product-moment correlation
## 
## data:  DATA$Lpallidum_Zstat and DATA$PEAK_METS
## t = 3.0151, df = 32, p-value = 0.004998
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1571933 0.6975678
## sample estimates:
##       cor 
## 0.4703561