-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path08-sacc_tDCS_supplement.Rmd
154 lines (130 loc) · 5.61 KB
/
08-sacc_tDCS_supplement.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
```{r setup, include=FALSE}
#Setup
library(kableExtra) # complex tables
library(tidyverse) # importing, transforming, and visualizing data frames
knitr::opts_chunk$set(results = 'hide', echo = FALSE, message = FALSE, warning = FALSE)
# create variable to resize figures/text depending on output
if (knitr::is_latex_output()) {
tbl_font_size <- 8
line_break <- function(...) {kableExtra::linebreak(...)}
} else {
tbl_font_size <- 12
# use html version of linebreak function
line_break <- function(x, ...) {
if (is.numeric(x) | is.logical(x)) return(x)
ifelse(stringr::str_detect(x, "\n"), stringr::str_replace_all(x, "\n", "<br />"), x)
}
}
```
# (APPENDIX) Appendix {-}
\cleardoublepage
\phantomsection
\addcontentsline{toc}{part}{Appendices}
\appendixpage*
\setlength\beforechapskip{-\baselineskip}
`r if (knitr::is_html_output()) '
# Supplement to Chapter 3 {#sacc-tDCS-supplement}
' else '
# Supplement to Chapter \\@ref(sacc-tDCS) {#sacc-tDCS-supplement}
'`
## tDCS adverse effects
```{r read data}
tDCS_AE <- read_csv2("sacc_tDCS_files/tdcs_sensations.csv", col_names = TRUE, progress = FALSE, col_types = cols(
session = readr::col_factor(c("first", "second")),
stimulation = readr::col_factor(c("anodal", "cathodal")))) %>%
filter(rowSums(is.na(.)) != ncol(.) - 3) # discard rows with all NAs (except 3 factor columns)
```
```{r}
# Make long form data frame of sensation intensity
intensity <- tDCS_AE %>%
select(everything(), -contains("conf"), -felt.more) %>% # drop other columns
gather(sensation, intensity, itching:nausea) # make long form
# Make long form data frame of sensation confidence
confidence <- tDCS_AE %>%
select(contains("conf"), subject, session, stimulation) %>%
gather(sensation, confidence, conf.itching:conf.nausea) %>%
# get rid of "conf." prefix so it matches the sensation intensity table
mutate(sensation = str_replace(sensation, "conf.", ""))
int_conf <- full_join(intensity,confidence) %>%
# gather confidence/intensity to make one plot for each
gather(measure, rating, intensity, confidence) %>%
mutate(measure = factor(measure, levels = c("intensity", "confidence")))
```
\begingroup
\renewcommand{\arraystretch}{1.25}
\setlength{\LTleft}{-20cm plus -1fill}
\setlength{\LTright}{\LTleft}
```{r tab-sacc-tDCS-AE, results='asis'}
if (knitr::is_latex_output() | knitr::is_html_output()) {
tbl_int_anodal <- intensity %>%
filter(stimulation == "anodal") %>%
count(sensation, intensity) %>%
spread(intensity, n) %>%
replace(is.na(.), 0) %>%
mutate_if(is.double, as.integer)
tbl_int_cathodal <- intensity %>%
filter(stimulation == "cathodal") %>%
count(sensation, intensity) %>%
spread(intensity, n) %>%
replace(is.na(.), 0) %>%
mutate_if(is.double, as.integer)
tbl_conf_anodal <- confidence %>%
filter(stimulation == "anodal") %>%
count(sensation, confidence) %>%
spread(confidence, n) %>%
replace(is.na(.), 0) %>%
mutate_if(is.double, as.integer)
tbl_conf_cathodal <- confidence %>%
filter(stimulation == "cathodal") %>%
count(sensation, confidence) %>%
spread(confidence, n) %>%
replace(is.na(.), 0) %>%
mutate_if(is.double, as.integer)
ae_colnames <- c(" ",
"none", "a\nlittle", "mode-\nrate", "strong", "very\nstrong",
"n/a", "un-\nlikely", "possi-\nbly", "likely", "very\nlikely")
bind_rows(full_join(tbl_int_anodal, tbl_conf_anodal, by = "sensation"),
full_join(tbl_int_cathodal, tbl_conf_cathodal, by = "sensation")) %>%
kable(col.names = line_break(ae_colnames, align = "c"),
booktabs = TRUE,
longtable = TRUE,
escape = FALSE,
caption = "Number of reports of tDCS adverse effects") %>%
kable_styling(bootstrap_options = "striped",
font_size = tbl_font_size) %>%
add_header_above(setNames(c(1,5,5), c(" ",
paste0("Intensity rating", footnote_marker_alphabet(1, double_escape = TRUE)),
paste0("Confidence rating", footnote_marker_alphabet(2, double_escape = TRUE)))),
escape = FALSE) %>%
pack_rows(index = c("anodal session" = 8, "cathodal session" = 8)) %>%
footnote(alphabet = c(
'"To which degree were the following sensations present during stimulation?"',
'"To which degree do you believe this was caused by the stimulation?"'))
}
```
\endgroup
\newpage
\pagestyle{empty}
\changetext{}{}{-25mm}{}{}
\blandscape
```{r fig-sacc-tDCS-AE, fig.cap='(ref:caption-fig-sacc-tDCS-AE)', results='show'}
knitr::include_graphics("sacc_tDCS_files/figures/figure_S1_AE.png", auto_pdf = TRUE)
```
(ref:caption-fig-sacc-tDCS-AE) __tDCS adverse effects in Chapter \@ref(sacc-tDCS)__. Number of reports out of 62 sessions (either anodal or cathodal tDCS). Top row shows intensity ratings [_little, moderate, strong, very strong_]; bottom row shows participant's confidence that event was related to tDCS [_unlikely, possibly, likely, very likely_]. Adverse effects are sorted in descending order of number of reports (for very rare events (five reports or fewer for a given polarity), some text counts have been removed to prevent overlap).
\newpage
\elandscape
\changetext{}{}{+25mm}{}{}
\pagestyle{\defstyle}
## MNI coordinates
```{r tab-sacc-tDCS-MNI, results='asis'}
read_csv("sacc_tDCS_files/FEF_coords_MNI_excl.csv") %>%
kable(col.names = c('participant','X','Y','Z','participant','X','Y','Z'),
align = c('crrrcrrr'),
linesep = "",
booktabs = TRUE,
caption = "Individual MNI coordinates of the right frontal eye field.") %>%
kable_styling(bootstrap_options = "striped",
latex_options = "hold_position",
font_size = tbl_font_size) %>%
column_spec(5, border_left = TRUE)
```