Skip to content

Commit a65ab36

Browse files
committed
Allowed to set animation playback status
1 parent 5792051 commit a65ab36

File tree

4 files changed

+85
-13
lines changed

4 files changed

+85
-13
lines changed

adhoc/examples/03-animation.R

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#' @author Zhengjia Wang
2+
#' @date Sept. 18, 2022
3+
#' @license Do whatever you like with this file
4+
#'
5+
#' 3D brain with animation
6+
#'
7+
#'
8+
if(FALSE) {
9+
install.packages(
10+
"threeBrain",
11+
repos = c(
12+
ropensci = 'https://beauchamplab.r-universe.dev',
13+
CRAN = 'https://cloud.r-project.org'
14+
)
15+
)
16+
}
17+
18+
19+
20+
# --- Global settings ----------------------------------------------------------
21+
22+
#' @param subject_code required by 3D viewer to distinguish different subjects
23+
#' in the group analyses
24+
subject_code <- "DemoSubject"
25+
26+
#' @param fs_path brain FreeSurfer directory
27+
fs_path <- "~/rave_data/data_dir/demo/DemoSubject/fs/"
28+
29+
#' @param electrode_path electrode coordinate file in csv
30+
electrode_path <- "~/rave_data/data_dir/demo/DemoSubject/rave/meta/electrodes.csv"
31+
32+
# --- Example 1: Generate vanilla 3D viewers -----------------------------------
33+
34+
# Some example-based data
35+
#' @param electrode_values values for electrodes, you can store them in a csv
36+
#' file or in-memory as a data.frame
37+
time <- seq(-1, 2, length.out = 100)
38+
electrode_values <- data.frame(
39+
Subject = "DemoSubject",
40+
Electrode = c(rep(13, 100), rep(14, 100)),
41+
Time = c(time, time),
42+
Value = c(sin(time * 2 * pi), sin(time * 2 * pi + 1))
43+
)
44+
45+
# Create `brain` instance
46+
brain <- threeBrain::freesurfer_brain2(
47+
fs_subject_folder = fs_path,
48+
subject_name = subject_code
49+
)
50+
51+
# Load electrodes
52+
brain$set_electrodes(electrode_path)
53+
54+
# Set values
55+
brain$set_electrode_values(electrode_values)
56+
57+
brain$plot(
58+
side_display = FALSE,
59+
camera_pos = c(-500, 0, 0),
60+
controllers = list(
61+
# Set controller `Display Data` to display `PValues` column
62+
"Display Data" = "Value",
63+
"Speed" = "0.5",
64+
"Play/Pause" = TRUE
65+
)
66+
)
67+
68+

inst/htmlwidgets/lib/dipterixThreeBrain-1.0.1/main.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -61107,12 +61107,14 @@ class THREEBRAIN_CONTROL{
6110761107
remember( args ){
6110861108

6110961109
const keys = [
61110-
"Background Color", "Camera Position", "Display Coordinates", "Show Panels", "Coronal (P - A)",
61111-
"Axial (I - S)", "Sagittal (L - R)", "Overlay Coronal", "Overlay Axial", "Overlay Sagittal",
61112-
"Dist. Threshold", "Surface Type", "Surface Material", "Left Hemisphere", "Right Hemisphere",
61113-
"Left Opacity", "Right Opacity",
61114-
"Map Electrodes", "Surface Mapping", "Volume Mapping", "Visibility", "Display Data",
61115-
"Display Range", "Threshold Data", "Threshold Range", "Threshold Method", "Video Mode",
61110+
"Background Color", "Camera Position", "Display Coordinates", "Show Panels",
61111+
"Coronal (P - A)", "Axial (I - S)", "Sagittal (L - R)",
61112+
"Overlay Coronal", "Overlay Axial", "Overlay Sagittal",
61113+
"Dist. Threshold", "Surface Type", "Surface Material",
61114+
"Left Hemisphere", "Right Hemisphere", "Left Opacity", "Right Opacity",
61115+
"Map Electrodes", "Surface Mapping", "Volume Mapping", "Visibility",
61116+
"Display Data", "Display Range", "Threshold Data", "Threshold Range",
61117+
"Threshold Method", "Video Mode", "Speed", "Play/Pause",
6111661118
"Show Legend", "Show Time", "Highlight Box", "Info Text",
6111761119
"Voxel Type", "Voxel Display", "Voxel Label", "Voxel Opacity", 'Voxel Min', 'Voxel Max',
6111861120
'Surface Color', 'Blend Factor', 'Sigma', 'Decay', 'Range Limit',

inst/htmlwidgets/lib/dipterixThreeBrain-1.0.1/main.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/js_raws/src/js/core/gui_wrapper.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@ class THREEBRAIN_CONTROL{
6060
remember( args ){
6161

6262
const keys = [
63-
"Background Color", "Camera Position", "Display Coordinates", "Show Panels", "Coronal (P - A)",
64-
"Axial (I - S)", "Sagittal (L - R)", "Overlay Coronal", "Overlay Axial", "Overlay Sagittal",
65-
"Dist. Threshold", "Surface Type", "Surface Material", "Left Hemisphere", "Right Hemisphere",
66-
"Left Opacity", "Right Opacity",
67-
"Map Electrodes", "Surface Mapping", "Volume Mapping", "Visibility", "Display Data",
68-
"Display Range", "Threshold Data", "Threshold Range", "Threshold Method", "Video Mode",
63+
"Background Color", "Camera Position", "Display Coordinates", "Show Panels",
64+
"Coronal (P - A)", "Axial (I - S)", "Sagittal (L - R)",
65+
"Overlay Coronal", "Overlay Axial", "Overlay Sagittal",
66+
"Dist. Threshold", "Surface Type", "Surface Material",
67+
"Left Hemisphere", "Right Hemisphere", "Left Opacity", "Right Opacity",
68+
"Map Electrodes", "Surface Mapping", "Volume Mapping", "Visibility",
69+
"Display Data", "Display Range", "Threshold Data", "Threshold Range",
70+
"Threshold Method", "Video Mode", "Speed", "Play/Pause",
6971
"Show Legend", "Show Time", "Highlight Box", "Info Text",
7072
"Voxel Type", "Voxel Display", "Voxel Label", "Voxel Opacity", 'Voxel Min', 'Voxel Max',
7173
'Surface Color', 'Blend Factor', 'Sigma', 'Decay', 'Range Limit',

0 commit comments

Comments
 (0)