Learn R Programming

neuroim2 (version 0.8.5)

plot,NeuroSlice-method: Plot a NeuroSlice

Description

Plot a NeuroSlice

plot a NeuroVol

Usage

# S4 method for NeuroSlice
plot(
  x,
  cmap = gray(seq(0, 1, length.out = 255)),
  irange = range(x, na.rm = TRUE),
  legend = TRUE
)

# S4 method for NeuroVol plot( x, cmap = gray(seq(0, 1, length.out = 255)), zlevels = unique(round(seq(1, dim(x)[3], length.out = 6))), irange = range(x, na.rm = TRUE), thresh = c(0, 0), alpha = 1, bgvol = NULL, bgcmap = gray(seq(0, 1, length.out = 255)), legend = TRUE )

Value

a ggplot2 object

Arguments

x

the object to display

cmap

a color map consisting of a vector of colors in hex format (e.g. gray(n=255))

irange

the intensity range indicating the low and high values of the color scale.

legend

Logical indicating whether to display the color legend. Defaults to TRUE.

zlevels

the series of slice indices to display.

thresh

a 2-element vector indicating the lower and upper transparency thresholds.

alpha

the level of alpha transparency

bgvol

a background volume that serves as an image underlay (currently ignored).

bgcmap

a color map for backround layer consisting of a vector of colors in hex format (e.g. gray(n=255))

Details

The plot method uses ggplot2 to create a raster visualization of the slice data. The intensity values are mapped to colors using the specified colormap and range.

when `x` is a NeuroSlice object, the plot method returns a ggplot2 object containing the raster visualization of the slice data. The plot can be further customized using standard ggplot2 functions.

Examples

Run this code
# Create example slice
slice_space <- NeuroSpace(c(100, 100))
slice_data <- matrix(rnorm(100*100), 100, 100)
slice <- NeuroSlice(slice_data, slice_space)
# \donttest{
# Basic plot
plot(slice)
# }


dat <- matrix(rnorm(100*100), 100, 100)
slice <- NeuroSlice(dat, NeuroSpace(c(100,100)))
# \donttest{
plot(slice)
# }

Run the code above in your browser using DataLab