Learn R Programming

ANTsR (version 1.0)

plot.antsImage: Plotting an image slice or multi-slice with optional color overlay.

Description

This is a plotting utility for antsImage types with a background and color overlay option. Useful for displaying statistical results overlaid on a background image.

Usage

# S3 method for antsImage
plot(x, y, color.img = "white", color.overlay = c("jet",
  "red", "blue", "green", "yellow"), axis = 2, slices,
  colorbar = missing(y), title.colorbar, title.img, color.colorbar,
  window.img = quantile(x[x != 0], c(0.05, 0.95)), window.overlay,
  quality = 4, outname = NA, alpha = 0.5, newwindow = FALSE, ...)

Arguments

x

the reference image on which to overlay.

y

image or list of images to use as overlays.

color.img

color for main image.

color.overlay

the color for the overlay , e.g c('blue','red') length of this list should match the image list.

axis

the axis to slice (1 , 2 or 3)

slices

vector of slices to plot (e.g., c(10, 15, 20))

colorbar

make colorbar?

title.colorbar

title for colorbar

title.img

title for main image

color.colorbar

color scale to use for colorbar

window.img

lower and upper thresholds for display of main image

window.overlay

lower and upper thresholds for display of overlay

quality

integer quality magnification factor 1 => large (e.g. 10)

outname

name of output file if you want to write result to file, e.g. plot.jpg.

alpha

opacity

newwindow

boolean controlling if we open a new device for this plot

...

other parameters

Value

output is plot to standard R window

Examples

Run this code
# NOT RUN {
img <- makeImage(c(4,4), rnorm(4*4))
mask <- makeImage(c(4,4),
   as.matrix(c(0,0,0,0,
            0,1,1,0,
            0,1,1,0,
            0,0,0,0), nrow=4))
plot(img, list(mask))
# }
# NOT RUN {
  mnit<-getANTsRData('mni')
  mnit<-antsImageRead(mnit)
  mniafn<-getANTsRData('mnia')
  mnia<-antsImageRead(mniafn)
  mnia<-thresholdImage(mnia,22,25)
  mnia<-smoothImage(mnia,1.5)
  mnia2<-antsImageRead(mniafn)
  mnia2<-thresholdImage(mnia2,1,4)
  mnia2<-smoothImage(mnia2,1.5)
  ofn<-paste(tempfile(),'.png',sep='')
  # write directly to a file
  plot( mnit, list(mnia,mnia2), slices=seq(50, 140, by=5),
    window.overlay = c(0.25,1), axis=2,
    overlay.color=c('red','blue'), outname = ofn )
# }

Run the code above in your browser using DataLab