Skip to content

Image plotting example with multiple overlays

stnava edited this page Jan 19, 2016 · 1 revision

plot.antsImage is the plotting function for antsImage objects.

  • read in some data
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)
  • plot multiple overlays in different colors.
plot( mnit, list(mnia,mnia2), slices=c(seq(100, 120, by=5),122),
      window.overlay = c(0.25,1), axis=1,
      color.overlay=c('red','blue') )
  • plot along different axes, with different slices
plot( mnit, list(mnia2), slices=c(72,85,100,103),
      window.overlay = c(0.1,1), axis=3 )
plot( mnit, list(mnia2), slices=c(72,85,100,103),
      window.overlay = c(0.1,1), axis=2 )

see ANTsR vignettes at the release page for more examples of visualization (RGB, tensor images, etc). Also see ?plot.antsImage for how to write directly to png.