R6 class for managing slice data for ggbrain plots
R6 class for managing slice data for ggbrain plots
Michael Hallquist
slice_index
read-only access to the slice_index containing the slice numbers
coord_input
the input string used to lookup the slices
coord_label
the calculated x, y, or z coordinate of the relevant slice
slice_number
the slice number along the relevant axis of the 3D image matrix
slice_data
a nested list of data.frames where each element contains all data relevant to that slice and the list elements within are each a given image
slice_matrix
the slice data in matrix form
slice_labels
a data.frame for each slice containing the coordinates of labels available to be drawn
layer_names
a character vector of layer names within each slice
new()
create a ggbrain_slices object based
ggbrain_slices$new(slice_df = NULL)
slice_df
a data.frame generated by ggbrain_images$get_slices()
If this becomes a user-facing/exported class, we may want a more friendly constructor
compute_contrasts()
computes contrasts of the sliced image data
ggbrain_slices$compute_contrasts(contrast_list = NULL)
contrast_list
a named list or character vector containing contrasts to be computed. The names of the list form the contrast names, while the values should be character strings that use standard R syntax for logical tests, subsetting, and arithmetic
as_tibble()
convert the slices object into a data.frame with list-columns for slice data elements
ggbrain_slices$as_tibble()
get_ranges()
calculates the numeric ranges of each image/contrast in this object, across all constituent slices. This is useful for setting scale limits that are shared across panels
ggbrain_slices$get_ranges(slice_indices = NULL)
slice_indices
an optional integer vector of slice indices to be used as a subset in the calculation
a tibble keyed by 'layer' with overall low and high values, as well as split by pos/neg
get_uvals()
returns a data.frame with the unique values for each label layer, across all constituent slices
ggbrain_slices$get_uvals(slice_indices = NULL, add_labels = NULL)
slice_indices
an optional integer vector of slice indices to be used as a subset in the calculation
add_labels
an optional named list indicating the label columns to add to a given layer. The names of the list specify the layer to which labels are added and the values should be character vectors specifying the names of columns that serve as labels for the layer. These are always added to any existing label columns for the layer.
add_labels
is provided here for any categorical columns that were specified inline in the
layer definition using factor or as.factor, such as aes(fill=factor(value)). Otherwise, it's best
to input data with labels in the first place so that labels are described in the data structure itself.
clone()
The objects of this class are cloneable with this method.
ggbrain_slices$clone(deep = FALSE)
deep
Whether to make a deep clone.