-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodals.R
More file actions
234 lines (203 loc) · 9.5 KB
/
modals.R
File metadata and controls
234 lines (203 loc) · 9.5 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# Modal Dialogs
# Modal 1: Getting started and explain left panel
createGettingStartedModal <- function() {
bsModal(
id = "instructionsModal1", title = "Getting Started", trigger = NULL,
size = "large",
tags$div(
tags$p("Welcome to",tags$b("BrainEffeX!"),"Here's how to get started:"),
tags$p("To facilitate the estimation and exploration of effect sizes for fMRI, we conducted “typical” study designs with large (n > 500) datasets and created a web app to share this data."),
tags$p("Use",tags$b(tags$i("the menu to the left")),"to filter the available studies by:"),
tags$ul(
tags$li("Dataset"),
tags$li("Map type (FC or activation)"),
tags$li("Available Tasks"),
tags$li("Test type"),
tags$li("Measures (if applicable)"),
tags$li("Motion Method"),
tags$li("Pooling Method"),
),
tags$p("Refer to the",tags$b(tags$i("tips")),"next to each input for additional guidance!"),
tags$p("Find more details about each study, including task and measure details, on the ", tags$b(tags$i("Study Info")), " tab."),
tags$div(style = "text-align: center;",
actionButton("nextToPage2", "Next", style = "margin-top: 10px; background-color: #337ab7; color: white; border: none; padding: 10px 20px; font-size: 16px;")
)
)
)
}
# Modal 2: Understanding the Plots
createUnderstandingPlotsModal1 <- function() {
bsModal(
id = "instructionsModal2", title = "Understanding the Plots", trigger = NULL,
size = "large",
tags$div(
tags$p("Explore the expected effect sizes of the studies that match the provided filters."),
tags$p(tags$b(tags$i("The plots on the left ")),"visualize all edges or voxels in each study:"),
tags$ul(
tags$li("Simultaneous confidence intervals (95% CI across all edges/voxels)."),
tags$li(tags$i("Red")," indicates simultaneous CIs overlapping with 0,", tags$i("green"), "indicates no overlap."),
tags$li(tags$i("Multivariate Effect sizes")," are displayed under the plots."),
),
tags$div(style = "text-align: center;",
actionButton("prevToPage1", "Previous", style = "margin-top: 10px; background-color: #337ab7; color: white; border: none; padding: 10px 20px; font-size: 16px;"),
actionButton("nextToPage3", "Next", style = "margin-top: 10px; background-color: #337ab7; color: white; border: none; padding: 10px 20px; font-size: 16px;")
)
)
)
}
# Modal 3: Understanding the Plots
createUnderstandingPlotsModal2 <- function() {
bsModal(
id = "instructionsModal3", title = "Understanding the Plots", trigger = NULL,
size = "large",
tags$div(
tags$p("Explore the expected effect sizes of the studies that match the provided filters."),
tags$p(tags$b(tags$i("The plots on the right")),"show the effect maps spatially:"),
tags$ul(
tags$li("Effect size matrices show the effect sizes for each edge for functional connectivity studies. Networks are labelled on the axes."),
tags$li("Activation Maps help you visualize the effect maps from activation studies on the brain.")
),
tags$div(style = "text-align: center;",
actionButton("prevToPage2", "Previous", style = "margin-top: 10px; background-color: #337ab7; color: white; border: none; padding: 10px 20px; font-size: 16px;"),
actionButton("nextToPage4", "Next", style = "margin-top: 10px; background-color: #337ab7; color: white; border: none; padding: 10px 20px; font-size: 16px;")
)
)
)
}
createMetaAnalysisModal <- function() {
bsModal(
id = "instructionsModal4", title = "Meta Analysis", trigger = NULL,
size = "large",
tags$div(
tags$p("The", tags$b("Meta-Analysis"), "tab shows effect sizes from meta-analyses across study categories."),
tags$p("Meta-analyses were conducted for each category of studies using the rma.mv function in the R package metafor."),
tags$div(style = "text-align: center;",
actionButton("prevToPage3", "Previous", style = "margin-top: 10px; background-color: #337ab7; color: white; border: none; padding: 10px 20px; font-size: 16px;"),
actionButton("nextToPage5", "Next", style = "margin-top: 10px; background-color: #337ab7; color: white; border: none; padding: 10px 20px; font-size: 16px;")
)
)
)
}
createDownloadingEffectMapsModal <- function() {
bsModal(
id = "instructionsModal5", title = "Downloading Data", trigger = NULL,
size = "large",
tags$div(
tags$p("How to download data from BrainEffeX:"),
tags$ul(
tags$li("Click the", tags$b(tags$i("'Download Data'")), "button to access the effect data stored on OSF.")
),
tags$p("Use the", tags$b(tags$i("'How to Use This App'")), "button at any time to revisit these instructions."),
tags$div(style = "text-align: center;",
actionButton("prevToPage4", "Previous", style = "margin-top: 10px; background-color: #337ab7; color: white; border: none; padding: 10px 20px; font-size: 16px;"),
actionButton("closePage5", "Close", style = "margin-top: 10px; background-color: #337ab7; color: white; border: none; padding: 10px 20px; font-size: 16px;")
)
)
)
}
############################################
# # Function to create the dynamic panel content
createDynamicPanel <- function(input, study) {
# Combine the reactive expression to update when either the Apply Filters or Reset Filters button is clicked
renderUI({
#event <- eventReactive(
#list(input$apply_filters_btn, input$reset_btn), { # Trigger on either button click
messages <- c()
# Dataset message
if (is.null(input$dataset) || input$dataset == "*") {
messages$dataset <- "• All datasets."
} else {
messages$dataset <- paste("• The <b>", input$dataset, "</b> dataset(s).")
}
# Map type message
if (is.null(input$map_type) || input$map_type == "*") {
messages$map_type <- "• All map types."
} else {
messages$map_type <- paste("• <b>", input$map_type, "</b> map type.")
}
# Task message
if (is.null(input$task) || length(input$task) == 0) {
messages$task <- "• No specific tasks are selected."
} else if ("*" %in% input$task) {
messages$task <- "• All tasks."
} else {
messages$task <- paste("• The <b>", paste(input$task, collapse = ", "), "</b> task(s).")
}
# Test type message
if (is.null(input$test_type) || input$test_type == "*") {
messages$test_type <- "• All test types."
} else {
messages$test_type <- paste("• The <b>", input$test_type, "</b> test type(s).")
}
if (is.null(input$measure) || length(input$measure) == 0) {
messages$measure <- "• No specific measures are selected."
} else if (length(input$measure) == length(unique(study[["var2"]])) || "*" %in% input$measure) {
messages$measure <- "• All measures"
} else {
messages$measure <- paste("• The <b>", paste(input$measure, collapse = ", "), "</b> measures(s).")
}
# Group by message
if (!is.null(input$group_by) && input$group_by != "none") {
messages$group_by <- paste("• The results are grouped by <b>", input$group_by, "</b>.")
}
# Combine the messages into one text
message_text <- paste("<b>You are looking at:</b><br>", paste(messages, collapse = "<br>"))
tags$div(
style = "background-color: #f8f9fa; padding: 10px; margin-bottom: 20px; border-radius: 5px; text-align: center;",
tags$p(HTML(message_text))
)
}
)
# # Render the dynamic content based on the eventReactive output
# event()
}
# Modal event observers for navigation
createModalNavigationObservers <- function(input, session) {
observeEvent(input$showInstructions, {
toggleModal(session, "instructionsModal1", toggle = 'open')
})
# Page 1 -> Page 2
observeEvent(input$nextToPage2, {
toggleModal(session, "instructionsModal1", toggle = 'close')
toggleModal(session, "instructionsModal2", toggle = 'open')
})
# Page 2 -> Page 1
observeEvent(input$prevToPage1, {
toggleModal(session, "instructionsModal2", toggle = 'close')
toggleModal(session, "instructionsModal1", toggle = 'open')
})
# Page 2 -> Page 3
observeEvent(input$nextToPage3, {
toggleModal(session, "instructionsModal2", toggle = 'close')
toggleModal(session, "instructionsModal3", toggle = 'open')
})
# Page 3 -> Page 2
observeEvent(input$prevToPage2, {
toggleModal(session, "instructionsModal3", toggle = "close")
toggleModal(session, "instructionsModal2", toggle = "open")
})
# Page 3 -> Page 4 (Meta Analysis)
observeEvent(input$nextToPage4, {
toggleModal(session, "instructionsModal3", toggle = "close")
toggleModal(session, "instructionsModal4", toggle = "open")
})
# Page 4 -> Page 3
observeEvent(input$prevToPage3, {
toggleModal(session, "instructionsModal4", toggle = "close")
toggleModal(session, "instructionsModal3", toggle = "open")
})
# Page 4 -> Page 5 (Download Data)
observeEvent(input$nextToPage5, {
toggleModal(session, "instructionsModal4", toggle = "close")
toggleModal(session, "instructionsModal5", toggle = "open")
})
# Page 5 -> Page 4
observeEvent(input$prevToPage4, {
toggleModal(session, "instructionsModal5", toggle = "close")
toggleModal(session, "instructionsModal4", toggle = "open")
})
# Close from Page 5
observeEvent(input$closePage5, {
toggleModal(session, "instructionsModal5", toggle = "close")
})
}