Learn R Programming

fslr (version 1.9.2.1)

multi_overlay: Create Multi-Image Plot with Overlays

Description

Creates a multi-row or multi-column plot with image slices and the potential for overlays as well.

Usage

multi_overlay(x, y = NULL, z = NULL, w = 1, mask = NULL, col.x = gray(0:64/64), col.y = hotmetal(), zlim.x = NULL, zlim.y = NULL, plane = c("axial", "coronal", "sagittal"), xlab = "", ylab = "", axes = FALSE, direction = c("horizontal", "vertical"), par.opts = list(oma = c(0, 0, 0, 0), mar = rep(0, 4), bg = "black"), text = NULL, text.x = NULL, text.y = NULL, text.cex = 1, text.col = "white", main = NULL, main.col = text.col, main.cex = text.cex, NA.x = TRUE, NA.y = TRUE, ...)

Arguments

x
List of images of class nifti or character vector of filenames
y
List of images of class nifti or character vector of filenames. Same length as x.
z
Slice to display.
w
3D volume to display if x has 4-D elements
mask
nifti image to drop empty image dimensions if wanted. Passed to dropEmptyImageDimensions
col.x
Color to display x images
col.y
Color to display y images
zlim.x
Limits for x to plot
zlim.y
Limits for y to plot
plane
the plane of acquisition to be displayed
xlab
Label for x-axis
ylab
Label for y-axis
axes
Should axes be displayed
direction
Should images be a row or column? Ignored if mfrow is in par.opts
par.opts
Options to pass to par
text
Text to be displayed
text.x
Location of text in x-domain
text.y
Location of text in y-domain
text.cex
Multiplier for text font
text.col
Color for text and main.
main
Title for each plot
main.col
Color for main. Will default to text.col
main.cex
Multiplier for text font. Will default to text.cex
NA.x
Should 0's in x be set to NA?
NA.y
Should 0's in y be set to NA?
...
Additional arguments to pass to image

Examples

Run this code
## Not run: 
# 
#  if (require(brainR)) {
#    visits = 1:3
#    y = paste0("Visit_", visits, ".nii.gz")
#    y = system.file(y, package = "brainR")
#    y = lapply(y, readnii)
# 
#    y = lapply(y, function(r){
#      pixdim(r) = c(0, rep(1, 3), rep(0, 4))
#      dropImageDimension(r)
#    })
# 
#    x = system.file("MNI152_T1_1mm_brain.nii.gz", 
#                  package = "brainR")
#    x = readnii(x)
#    mask = x >0
#    x = lapply(visits, function(tmp){
#        x
#    })
#    alpha = function(col, alpha = 1) {
#        cols = t(col2rgb(col, alpha = FALSE)/255)
#        rgb(cols, alpha = alpha)
#    }
#    multi_overlay(x, y, 
#          col.y = alpha(hotmetal(), 0.5),
#          mask = mask, 
#          main = paste0("\n", "Visit ", visits),
#          text = LETTERS[visits],
#          text.x = 0.9,
#          text.y = 0.1,
#          text.cex = 3)
#  }
# ## End(Not run)

Run the code above in your browser using DataLab