R6 class for a single layer of a ggbrain panel
R6 class for a single layer of a ggbrain panel
a ggbrain_layer R6 class containing fields related to a visual layer on the ggbrain plot
namethe name of this layer, used for referencing in layer and panel modifications
all_nawhether all values for this layer are NA in the data field
definitiona character string specifying the image name or contrast that defines this layer
sourcea character string specifying the layer source within a relevant ggbrain_slices object. This is used to lookup the right layer information when combining slices and layers together Note that multiple layers can potentially have the same source, which is why a 1:1 mapping to name does not work
datathe data.frame containing relevant data for this layer.
show_legenda logical indicating whether to show or hide the fill/color scale
unify_scalesa logical indicating whether to unify scale limits and levels when this layer is added across many panels
bisidedread-only access to whether this layer uses a bisided color scale
categorical_fillread-only access to whether this layer has a categorical fill scale
fill_columnread-only access to layer fill column
fill_scalea scale_fill_* object containing the ggplot2 fill scale for this layer
alphasets the alpha transparency of this layer.
blur_edgecontrols the standard deviation (sigma) of a Gaussian blur applied to the layer at the edge
trim_threadsiteratively trim any pixels that have fewer than this number of neighboring pixels
fill_holescontrols the size of holes to be filled for display (in pixels)
remove_speckscontrols the size of specks to be removed (in pixels)
new()create a new ggbrain_layer object
ggbrain_layer$new(
  name = NULL,
  definition = NULL,
  limits = NULL,
  breaks = integer_breaks(),
  show_legend = TRUE,
  interpolate = NULL,
  unify_scales = TRUE,
  alpha = NULL,
  blur_edge = NULL,
  fill_holes = NULL,
  remove_specks = NULL,
  trim_threads = NULL,
  data = NULL
)namethe name of this layer, used for referencing in layer and panel modifications
definitionan optional character string defining the image or contrast that should be used to lookup data from a ggbrain_slices object. This is mostly used internally by the ggbrain + syntax to allow layers to be defined without data in advance of the plot.
limitsif provided, sets the upper and lower bounds on the scale
breaksif provided, a function to draw the breaks on the color scale
show_legendif TRUE, show the scale on the plot legend
interpolatepasses to geom_raster and controls whether the fill is interpolated over continuous space
unify_scalesif TRUE, when this layer is reused across panels, unify the scales to match
alphafixed alpha transparency of this layer (use mapping for alpha mapping`)
blur_edgethe standard deviation (sigma) of a Gaussian kernel applied to the edge of this layer to smooth it. This makes the layer less jagged in appearance and is akin to antialiasing.
fill_holesthe size of holes (in pixels) inside clusters to be filled by nearest neighbor imputation prior to display
remove_specksthe size of specks (in pixels) to be removed from each slice prior to display
trim_threadsthe minimum number of neighboring pixels (including diagonals) that must be present to keep a pixel
datathe data.frame containing image data for this layer. Must contain "dim1", "dim2", and "value" as columns
set_limits()set the limits for this layer's scale
ggbrain_layer$set_limits(limits)limitsa 2-element numeric vector setting the lower and upper limits on the layer's scale
set_pos_limits()set the limits for this layer's positive scale (only relevant to bisided)
ggbrain_layer$set_pos_limits(limits)limitsa 2-element numeric vector setting the lower and upper limits on the layer's positive scale
set_neg_limits()set the limits for this layer's positive scale (only relevant to bisided)
ggbrain_layer$set_neg_limits(limits)limitsa 2-element numeric vector setting the lower and upper limits on the layer's positive scale
set_breaks()set the breaks element of this layer's scale
ggbrain_layer$set_breaks(breaks)breaksa function used to label the breaks
set_pos_breaks()set the breaks element of this layer's positive scale (only relevant to bisided)
ggbrain_layer$set_pos_breaks(breaks)breaksa function used to label the positive breaks
set_neg_breaks()set the breaks element of this layer's negative scale (only relevant to bisided)
ggbrain_layer$set_neg_breaks(breaks)breaksa function used to label the negative breaks
add_to_gg()method to add this layer to an existing ggplot object
ggbrain_layer$add_to_gg(base_gg)base_ggthe ggplot object to which we add the layer
get_data()return the data.frame associated with this layer
ggbrain_layer$get_data(add_layer_name = FALSE)add_layer_nameif TRUE, adds a layer_name column to the data.frame for record-keeping.
Default: FALSE.
is_empty()returns TRUE if all values are NA or if the data has 0 rows
ggbrain_layer$is_empty()
clone()The objects of this class are cloneable with this method.
ggbrain_layer$clone(deep = FALSE)deepWhether to make a deep clone.
Note that this class is exported only for power users and rarely needs to be called directly in typical use of the package. Instead, look at geom_brain() and geom_outline().