Learn R Programming

brainR (version 1.6.0)

scene4d: Wrapper to write a 4D scene

Description

This function takes in filenames, levels, and creates an output html file, with 4D elements. The html is based on XTK (https://github.com/xtk/X#readme)

Usage

scene4d(
  files,
  fnames = NULL,
  outfile = "index_4D_stl.html",
  levels = NULL,
  alpha = NULL,
  color = "white",
  useTemp = FALSE,
  MNITemp = c("1mm", "2mm"),
  objtype = "stl",
  ...
)

Arguments

files

(character) vector of filenames (first being a brain file if useTemp=FALSE)

fnames

(character) filenames for the 3D surfaces in the scene - needs to be the same length as files

outfile

(character) html filename

levels

(numeric/list) levels to make contours/surfaces for each file. Either a numeric vector may be passed, one level for each file. Or a list of numeric vectors of multiple levels for each file. Will be coerced to a list.

alpha

(numeric/list) alpha opacities for each contours/surface for each file. Will be coerced to list similarly as levels

color

(character/list) colors for each contours/surface for each file. Will be coerced to list similarly as levels

useTemp

(logical) whether to use template from brainR as the brain figure

MNITemp

(character) if (useTemp = TRUE) either "1mm" or "2mm" denoting the resolution of the template used

objtype

(character) object type to write the files to. Either "stl", "obj", or "ply" to write.

...

other options to be passed to write4D

Examples

Run this code
# NOT RUN {
### Faster - 8mm resampled but very coarse
imgs <- paste("Visit_", 1:5, "_8mm.nii.gz", sep="") 
ifiles <- sapply(imgs, system.file, package='brainR')
files = file.path(tempdir(), basename(ifiles))
file.copy(ifiles, files)
outfile <-  file.path(tempdir(), "index_4D_stl.html")
scene4d(files, levels=rep(0.99, length(files)), 
outfile = outfile, color= rep("blue", length(files)), useTemp=TRUE, 
MNITemp = "8mm", alpha = rep(1, length(files)), rescale=TRUE  )
# }
# NOT RUN {
imgs <- paste("Visit_", 1:5, ".nii.gz", sep="") 
ifiles <- sapply(imgs, system.file, package='brainR')
files = file.path(tempdir(), basename(ifiles))
file.copy(ifiles, files)
scene4d(files, levels=rep(0.99, length(files)), 
outfile = outfile,
color= rep("blue", length(files)), useTemp=TRUEge, 
MNITemp = "8mm", alpha = rep(1, length(files)), rescale=TRUE  )
# }

Run the code above in your browser using DataLab