Commit 56ed4e8d authored by Florian Lance's avatar Florian Lance
Browse files

* init repo

parents
*.wav filter=lfs diff=lfs merge=lfs -text
---
title: "Increased functional connectivity of the intraparietal sulcus underlies the attenuation of numerosity estimations for self-generated words"
output:
html_document:
theme: united
toc: yes
toc_float: yes
pdf_document:
toc: yes
---
**Main analysis performed for behavioral data**
SECTIONS:
- Libraries
- Parameters
- Data loading
- Demographics
- Numerosity performance (pI)
- Linear relationship between numerosity estimations and words generated/heard
- Performance monitoring (pII)
- Control checks
Each section contains the code for performed statistics and plots
~~~~~~~~~~~~~~~~~~NOTES~~~~~~~~~~~~~~~~~~
Conditions:
1: Active
2: Passive
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
### Clear workspace
```{r, clear workspace, echo=F}
rm(list=ls(all=T));
```
### Libraries
```{r setup, warning=F, message=F, include=FALSE}
library(afex)
library(Matrix)
library(lme4)
library(lmerTest)
library (ggplot2)
library(dplyr)
library(tidyverse)
library(pastecs)
library(Hmisc)
library(ggsci)
library(Rmisc)
library(sjPlot)
library(jtools)
library(interactions)
library(ggstance)
```
### Parameters
```{r, parameters, echo=F}
#color palette for plots
palette = c("#FB6467FF", "#197EC0FF") ##FED439FF
u = 'cm'
w = 11
h = 15
dp = 300
```
### Prepare and load data
```{r, load & preproc data, , echo=F,warning=F,message=F}
#MRI STUDY DATA
a<-read.csv(file='/Your_path/Data_MRI_study.csv',header=TRUE,sep=',')
d<-read.csv(file='/Your_path/Demographics_mri.csv',header=TRUE,sep=',')
#MOCK SCANNER PILOT DATA
#a<-read.csv(file='/Your_path/Data_pilot_study.csv',header=TRUE,sep=',')
#d<-read.csv(file='/Your_path/Demographics_pilot.csv',header=TRUE,sep=',')
#MRI STUDY DATA: vrbal fluency performance (control check for overt and covert generation)
f<-read.csv(file='/Your_path/Verbal_fluency_over_covert.csv',header=TRUE,sep=',')
#not include NAN values into variables
a=a[!is.na(a$NumerosityJudgement),]
a=a[!is.na(a$ErrorJudgement),]
#choose word generation limit
a=a[a$Words>5,]
#Define factors
a$Subject = as.factor(a$Subject)
#Conditions 1:Active, 2:Passive
a$Conditions = as.factor(a$Conditions)
a$Runs = as.factor(a$Runs)
d$Subject = as.factor(d$Subject)
#Gender 0:Male, 1:Female
d$Gender = as.factor(d$Gender)
#Numerosity performace (pI)
a$pI = (a$NumerosityJudgement - a$Words)/(a$NumerosityJudgement + a$Words)
#Performance monitoring (pII)
a$pII = ( abs(a$ErrorJudgement - abs(a$NumerosityJudgement-a$Words)))/(a$NumerosityJudgement + a$Words)
#Calculate means per Subject & Condition
means = aggregate(cbind(Words,NumerosityJudgement,ErrorJudgement,WordGenerationTime,RTNumerosity,RTError,pI,pII) ~ Conditions + Subject,a,mean)
```
#RESULTS
## Demographics
**Descriptive statistics are displayed**
Age (years)
```{r, age, echo=F}
stat.desc(d$Age)
CI(d$Age)
```
Gender
0: Male 1: Female
```{r, gender, echo=F}
summary(d$Gender)
```
Education (years)
```{r, education, echo=F}
stat.desc(d$Education)
CI(d$Education)
```
Handedness (laterality quotient)
```{r, lq, echo=F}
stat.desc(d$LQ)
```
## Numerosity performance
Main finding: bigger underestimation of self generated words
Linear mixed models
```{r, first order performance, echo=F,warning=F,message=F}
mpI=lmer((pI) ~ Conditions + (1 |Subject) , data=a)
mpIb=lmer((pI) ~ Conditions + (Conditions|Subject) , data=a)
mpIc=lmer((pI) ~ Conditions + RTNumerosity + (Conditions|Subject) , data=a)
mpId=lmer((pI) ~ Conditions + RTNumerosity + (1 |Subject) , data=a)
anova(mpI,mpIb,mpIc, mpId)
anova(mpIb)
summary(mpIb)
```
Means and standard deviations
```{r}
by(a$pI,a$Conditions,stat.desc)
```
*Confidence interval*
Active + Passive conditions
```{r}
CI(a$pI, ci=0.95)
```
Active condition
```{r}
CI(a$pI[a$Conditions==1], ci=0.95)
```
Passive condition
```{r}
CI(a$pI[a$Conditions==2], ci=0.95)
```
**Bar plot of mean numerosity performance**
```{r}
## NF edits
BPpI <- ggplot(means,aes(x = Conditions,y=pI, color= Conditions)) +
geom_boxplot(size=1.5,width = 0.5) +
geom_hline(yintercept=0, size=1.5, color='grey30', linetype = 2) +
geom_dotplot(aes(fill=Conditions, color=Conditions), binaxis='y', stackdir='center', dotsize =.8,alpha=0.6) +
# stat_summary(fun.y = mean, geom="point",colour="darkred", size=6, shape=18) +
geom_line(aes(group=Subject), linetype = 7, alpha = 0.1, colour="grey29", size=1)
BPpI <- BPpI +
scale_color_manual(values =palette) +
scale_fill_manual(values =palette) +
theme_classic(base_size = 18) +
scale_x_discrete(breaks=c("1", "2"), labels=c("Active", "Passive")) +
theme(legend.position = 'none',axis.line = element_line(size = 1.5),
axis.text = element_text(size = 17,color='black', face = 'bold'),
axis.text.y=element_text(angle=90, hjust=0, vjust=-.5), axis.title.y = element_text(face='bold'),
axis.ticks = element_blank()
) +
ylab("Mean numerosity performance") +xlab("")
BPpI
ggsave(plot = BPpI,units = u, height = h, width= w, dpi = dp, filename = "./mean_numerosity_performance.png")
```
## Linear relationship between numerosity estimation and words generated/heard
Main finding: better tracking of the changing number of words during the active condition (for self-generated words)
```{r, with mixed models linear relationship, echo=T,warning=F,message=F}
m = lmer(NumerosityJudgement~Words*Conditions + (Conditions|Subject),a)
anova(m)
summary(m)
```
```{r, slopes}
#To extract slope coefficient for each condition
sl = sim_slopes(m, pred = Words, modx = Conditions, cond.int = TRUE, jnplot = TRUE )
sl
plot(sl)
interact_plot(m, pred = Words, modx = Conditions, interval = TRUE,plot.points = TRUE)
#Plot slope coefficient
t<-sl$slopes
#Build new data frame based on the previous data frame 't' specifically to the plotting
d=data.frame(Condition=c("Active","Passive"), Slope=c(0.6218, 0.5486), lower = c(0.5717773, 0.4994483), upper=c(0.6718906, 0.5977638))
sl1 <- ggplot() +
geom_pointrange(data=d, mapping=aes(x=Condition, y=Slope, ymin=upper, ymax=lower),
width=1, size=1.5,shape=16, fill=palette, color=palette, alpha = 0.7) +
theme_classic() +
ylab("Mean slope coefficient") +
xlab("") +
theme(text = element_text(size=18), legend.position = 'none',axis.line = element_line(size = 1.5),
axis.text = element_text(size = 17,color='black', face = 'bold'),
axis.text.y=element_text(angle=90, hjust=0, vjust=-.5), axis.title.y = element_text(face='bold'),
axis.title.x = element_text(face='bold'),
axis.ticks = element_blank())
sl1
ggsave(plot = sl1,units = u, height = h, width= w, dpi = dp, filename = "mean_slope_coefficient.png")
```
**Plot linear relationship of all subjects/condition and mean for both conditions separately**
```{r, echo=F}
LR = plot_model(m,type='pred',terms=c('Words','Conditions'), size=1.5, alpha=0.3,
title = "",
line.size = 1.5) +
geom_abline(slope=1,linetype='dashed', size=1) +
geom_smooth(data=a,aes(x=Words,y=NumerosityJudgement,
color=factor(Conditions),
fill=factor(Conditions),
group=interaction(Subject,Conditions)),
size=.1,alpha=0,method='lm',inherit.aes = F) +
scale_color_manual(values =palette) +
scale_fill_manual(values =palette) +
theme_classic() +
ylab("Numerosity estimation") +
xlab("Words generated/heard") +
theme(text = element_text(size=18), legend.position = 'none',axis.line = element_line(size = 1.5),
axis.text = element_text(size = 17,color='black', face = 'bold'),
axis.text.y=element_text(angle=90, hjust=0, vjust=-.5), axis.title.y = element_text(face='bold'),
axis.title.x = element_text(face='bold'),
axis.ticks = element_blank()) +
scale_y_continuous(breaks=seq(5,20,5)) +
scale_x_continuous(breaks=seq(5,20,5))
LR
ggsave(plot = LR, units = u, height = h, width= w, dpi = dp, filename = "./linear_relationship.png")
```
## Performance monitoring
Main finding: no difference between condition during performance monitoring
```{r, performance monitoring, echo=F,warning=F,message=F}
mpII=lmer(pII ~ Conditions + (1 |Subject) , data=a)
mpII2=lmer(pII ~ Conditions + (Conditions |Subject) , data=a)
anova(mpII2)
summary(mpII)
```
Means and standard deviations
```{r, echo=F}
by(a$pII,a$Conditions,stat.desc)
```
*Confidence interval*
Active condition
```{r, echo=F}
CI(a$pII[a$Conditions==1], ci=0.95)
```
Passive condition
```{r, echo=F}
CI(a$pII[a$Conditions==2], ci=0.95)
```
**Bar plot of mean performance monitoring**
```{r, echo=F}
BPpII <- ggplot(means,aes(x = Conditions,y=pII, color= Conditions)) +
geom_boxplot(size=1.5,width = 0.5) +
geom_dotplot(aes(fill=Conditions, color=Conditions), binaxis='y', stackdir='center', dotsize =.8,alpha=0.6) +
geom_line(aes(group=Subject), linetype = 7, alpha = 0.1, colour="grey29", size=1)
BPpII <- BPpII +
scale_color_manual(values =palette) +
scale_fill_manual(values =palette) +
theme_classic(base_size = 18) +
scale_x_discrete(breaks=c("1", "2"), labels=c("Active", "Passive")) +
theme(legend.position = 'none',axis.line = element_line(size = 1.5),
axis.text = element_text(size = 17,color='black', face = 'bold'),
axis.text.y=element_text(angle=90, hjust=0, vjust=-.5), axis.title.y = element_text(face='bold'),
axis.ticks = element_blank()
) +
ylab("Mean performance monitoring") +xlab("")
BPpII
ggsave(plot = BPpII,units = u, height = h, width= w, dpi = dp, filename = "mean_performance_monitoring.png")
```
## Control checks
Main finding: conditions were mathced for stimulus time; number of words generated/heard
###Word generated/listening time
```{r, generation time, echo=F,warning=F,message=F}
mtime=lmer(WordGenerationTime ~ Conditions + (Conditions |Subject) , data=a)
mtimeb=lmer(WordGenerationTime ~ Conditions + (1 |Subject) , data=a)
anova(mtime,mtimeb)
anova(mtime)
```
Means and standard deviations:
```{r, echo=F}
by(a$WordGenerationTime,a$Conditions,stat.desc)
```
*Confidence interval*
Active condition
```{r, echo=F}
CI(a$WordGenerationTime[a$Conditions==1], ci=0.95)
```
Passive condition
```{r, echo=F}
CI(a$WordGenerationTime[a$Conditions==2], ci=0.95)
```
##Actual number of words generated/heard
```{r, actual number, echo=F,warning=F,message=F}
mw=lmer(Words ~ Conditions + (1 |Subject) , data=a)
mwb=lmer(Words ~ Conditions + (Conditions |Subject) , data=a)
anova(mw, mwb)
anova(mwb)
```
Means and standard deviations
```{r, echo=F}
by(a$Words,a$Conditions,stat.desc)
```
*Confidence interval*
Active condition
```{r, echo=F}
CI(a$Words[a$Conditions==1], ci=0.95)
```
Passive condition
```{r, echo=F}
CI(a$Words[a$Conditions==2], ci=0.95)
```
###Reaction time of numerosity estimations
```{r, RT numerosity, echo=F,warning=F,message=F}
mRTNum=lmer(RTNumerosity ~ Conditions + (Conditions |Subject) , data=a)
anova(mRTNum)
```
Means and standard deviations
```{r, echo=F}
by(a$RTNumerosity,a$Conditions,stat.desc)
```
*Confidence interval*
Active condition
```{r, echo=F}
CI(a$RTNumerosity[a$Conditions==1], ci=0.95)
```
Passive condition
```{r, echo=F}
CI(a$RTNumerosity[a$Conditions==2], ci=0.95)
```
###Reaction time of error estimation
```{r, RT error, echo=F,warning=F,message=F}
mRTErr=lmer(RTError ~ Conditions + (1 |Subject) , data=a)
anova(mRTErr)
```
Means and standard deviations
```{r, echo=F}
by(a$RTError,a$Conditions,stat.desc)
```
*Confidence interval*
Active condition
```{r, echo=F}
CI(a$RTError[a$Conditions==1], ci=0.95)
```
Passive condition
```{r, echo=F}
CI(a$RTError[a$Conditions==2], ci=0.95)
```
###Over and covert number of words generated: letter'p'
```{r, words overt covert, echo=F,warning=F,message=F}
t.test(f$W_MRI,f$W_overt,paired=T)
```
Means and standard deviations
```{r, echo=F}
stat.desc(f$W_MRI)
stat.desc(f$W_overt)
```
*Confidence interval*
Overt
```{r, echo=F}
CI(f$W_overt, ci=0.95)
```
Covert
```{r, echo=F}
CI(f$W_MRI, ci=0.95)
```
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
Subject,Age ,Gender,Education,LQ
1,18,1,14,0.75
2,26,1,22,1
3,20,1,15,0.83
4,20,0,15,0.67
6,22,0,18,0.83
7,22,1,17,0.75
8,26,1,21,0.58
9,28,1,21,0.83
10,23,1,14,0.83
12,29,1,17,0.91
13,22,0,17,0.83
14,25,0,21,1
15,24,1,20,0.83
16,21,0,14,0.42
18,26,0,12,0.75
19,23,0,18,0.33
20,21,0,15,0.58
22,21,0,14,0.83
23,34,1,20,1
24,23,1,18,0.58
25,20,1,17,0.67
26,18,1,16,0.5
27,21,1,15,0.5
28,28,0,22,0.42
29,37,0,18,0.5
Subject,Age ,Gender,Education
1,21,0,15
2,25,1,20
3,27,1,19
4,24,0,18
5,25,0,20
6,21,0,14
7,20,1,15
8,28,0,21
9,28,0,20
10,26,1,18
11,22,0,18
12,18,0,13
13,20,0,14
14,20,0,16
15,20,0,16
16,22,1,18
17,21,1,18
Subject,ID,Time,W_MRI,W_overt
1,TA_S01,25,18,15
2,TA_S02,35,17,16
3,TA_S03,35,9,10
4,TA_S05,20,6,8
5,TA_S06,20,9,7
6,TA_S07,30,12,9
7,TA_S08,30,12,19
8,TA_S09,30,12,12
9,TA_S10,30,13,14
10,TA_S12,25,9,5
11,TA_S13,30,11,9
12,TA_S14,25,10,10
13,TA_S15,30,18,14
14,TA_S16,30,9,15
15,TA_S18,25,7,16
16,TA_S19,30,19,16
17,TA_S20,35,19,22
18,TA_S22,35,19,15
19,TA_S23,25,11,13
20,TA_S24,25,8,11
21,TA_S25,25,12,13
22,TA_S26,20,11,11
23,TA_S27,20,13,12
24,TA_S28,20,9,11
25,TA_S29,30,14,11
Letters
ee- removed
j - removed (not enough cue words without starting from the cue letter) old file folde contains it
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment