R6 class for a single layer of a ggbrain panel
R6 class for a single layer of a ggbrain panel
Details
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().
Active bindings
name
the name of this layer, used for referencing in layer and panel modifications
all_na
whether all values for this layer are NA in the
data
fielddefinition
a character string specifying the image name or contrast that defines this layer
source
a 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
data
the data.frame containing relevant data for this layer.
show_legend
a logical indicating whether to show or hide the fill/color scale
unify_scales
a logical indicating whether to unify scale limits and levels when this layer is added across many panels
bisided
read-only access to whether this layer uses a bisided color scale
categorical_fill
read-only access to whether this layer has a categorical fill scale
fill_column
read-only access to layer fill column
fill_scale
a scale_fill_* object containing the ggplot2 fill scale for this layer
alpha
sets the alpha transparency of this layer.
blur_edge
controls the standard deviation (sigma) of a Gaussian blur applied to the layer at the edge
trim_threads
iteratively trim any pixels that have fewer than this number of neighboring pixels
fill_holes
controls the size of holes to be filled for display (in pixels)
remove_specks
controls the size of specks to be removed (in pixels)
Methods
Method new()
create a new ggbrain_layer object
Usage
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
)
Arguments
name
the name of this layer, used for referencing in layer and panel modifications
definition
an 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.
limits
if provided, sets the upper and lower bounds on the scale
breaks
if provided, a function to draw the breaks on the color scale
show_legend
if TRUE, show the scale on the plot legend
interpolate
passes to geom_raster and controls whether the fill is interpolated over continuous space
unify_scales
if TRUE, when this layer is reused across panels, unify the scales to match
alpha
fixed alpha transparency of this layer (use
mapping
for alpha mapping`)blur_edge
the 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_holes
the size of holes (in pixels) inside clusters to be filled by nearest neighbor imputation prior to display
remove_specks
the size of specks (in pixels) to be removed from each slice prior to display
trim_threads
the minimum number of neighboring pixels (including diagonals) that must be present to keep a pixel
data
the data.frame containing image data for this layer. Must contain "dim1", "dim2", and "value" as columns
Method set_pos_breaks()
set the breaks element of this layer's positive scale (only relevant to bisided)
Method set_neg_breaks()
set the breaks element of this layer's negative scale (only relevant to bisided)