Returned by brain_proxy. Provides reactive active bindings
and setter methods for controlling a running three-brain viewer widget
from within a Shiny application.
Active bindings (reactive fields) reflect the viewer state and trigger Shiny reactivity when read inside a reactive context:
backgroundCurrent background color as a hex string.
text_decorationsList of current text decoration objects.
main_cameraNamed list with
position,up, andzoom.side_displayLogical indicating whether the side canvas is visible.
surface_typeCurrent surface type string (e.g.
"pial").display_variableName of the currently displayed data clip.
plane_positionNamed numeric vector
c(R, A, S)giving the slice cursor position in FreeSurfer surface coordinates.controllersFull controller state list.
current_subjectNamed list describing the currently active subject, including transform matrices.
Active bindings
backgroundCurrent viewer background color as a hex string (e.g.
"#FFFFFF"). Reactive.text_decorationsList of current text decoration parameter lists pushed from JavaScript. Each element has fields
id,text,position,color,font_size, andlayer. Reactive.main_cameraNamed list with elements
position(length-3 numeric),up(length-3 numeric), andzoom(positive numeric) describing the main camera state. Reactive.side_displayLogical indicating whether the side canvas panel is currently visible. Reactive.
surface_typeCurrent brain surface type string (e.g.
"pial","white"). Reactive.display_variableName of the data clip currently displayed in the viewer.
"[None]"when nothing is displayed. Reactive.plane_positionNamed numeric vector
c(R, A, S)giving the slice cursor position in FreeSurfer surface coordinates. Reactive.localization_tableData frame of localization electrode contacts parsed from the JSON pushed by the viewer, or
NULL. Reactive.localization_add_quaternionRotation data list pushed by the viewer when a localization point is added. Reactive.
mouse_event_double_clickNamed list describing the last double-click mouse event in the viewer. Reactive.
mouse_event_clickNamed list describing the last single-click mouse event in the viewer. Reactive.
controllersFull named list of the viewer's current controller (GUI panel) state. Reactive.
current_subjectNamed list describing the currently active subject. Includes
subject_code,Norig,Torig, andxfmtransform matrices. Reactive.syncSync token string pushed by the viewer on each render cycle; useful for triggering reactive updates. Reactive.
acpc_alignmentNamed list describing the AC-PC alignment in scanner RAS space. Includes
ac,pc,ras2acpc, and set-flags. Reactive.
Methods
ViewerProxy$new()
Create a new viewer proxy. Normally called via
brain_proxy rather than directly.
Usage
ViewerProxy$new(outputId, session = shiny::getDefaultReactiveDomain())Arguments
outputIdShiny output element ID of the three-brain widget.
sessionShiny reactive domain session. Defaults to the current session returned by
shiny::getDefaultReactiveDomain().
ViewerProxy$set_electrode_data()
Push a data frame of electrode values to the viewer.
Usage
ViewerProxy$set_electrode_data(
data,
palettes = NULL,
value_ranges = NULL,
clear_first = FALSE,
update_display = TRUE,
override = TRUE
)Arguments
dataData frame with at least columns
SubjectandElectrode.palettesOptional named list of color palette vectors.
value_rangesOptional named list of
c(min, max)ranges.clear_firstLogical; clear existing electrode data before applying. Default
FALSE.update_displayLogical; update the viewer display after the data is applied. Default
TRUE.overrideLogical; override existing data for the same clip. Default
TRUE.
ViewerProxy$set_incoming_localization_hemisphere()
Set which hemisphere is targeted for the next electrode localization click.
ViewerProxy$set_values()
Add an animation clip of scalar or categorical values to a named geometry object in the viewer.
Arguments
nameCharacter clip name used as the display variable label.
target_objectName of the geometry object to animate.
data_typeEither
"continuous"or"discrete".valueNumeric or character vector of values.
paletteColor palette: a vector of R colors. Default
rainbow(64).symmetricLogical; whether the color scale is symmetric around zero. Default
FALSE.timeNumeric vector of time points matching
value. Defaults to0for a single value.value_rangeNumeric vector of length 2 overriding the data range.
NULLuses the natural range.time_rangeNumeric vector of length 2 overriding the time range.
NULLuses the natural range.value_namesOptional character vector of level labels for discrete data.
switch_displayLogical; switch the viewer display to this clip after upload. Default
FALSE.
ViewerProxy$get_text_decorations()
Get the current text decorations from the viewer.
Returns a list of named lists, each with fields id,
text, position, color, font_size, and
layer. Returns an empty list when no decorations exist.
ViewerProxy$set_text_decoration()
Create or update a text decoration in the viewer.
ViewerProxy$get_crosshair_position()
Get the current slice cursor position in a requested coordinate space.
Usage
ViewerProxy$get_crosshair_position(
space = c("tkrRAS", "MNI305", "MNI152", "scanner", "CRS")
)ViewerProxy$set_crosshair_position()
Move the slice cursor to a given position in a requested coordinate space.
Usage
ViewerProxy$set_crosshair_position(
position,
space = c("tkrRAS", "MNI305", "MNI152", "scanner", "CRS")
)