SOCR ≫ | TCIU Website ≫ | TCIU GitHub ≫ |
# To Render the rgl/contour3d window in the DOCX/HTML output via knitter, we can use the following protocol:
library(misc3d)
library(rgl)
library(DT)
## [1] 64 64 180
## [1] 64 64 91
# 1. download the 4D fMRI data
fMRIURL <- "http://socr.umich.edu/HTML5/BrainViewer/data/fMRI_FilteredData_4D.nii.gz"
fMRIFile <- file.path(tempdir(), "fMRI_FilteredData_4D.nii.gz")
(fMRIVolume <- readNIfTI(fMRIFile, reorient=FALSE))
# 2. extract the time-corse of 2D mid-axial slice (3D) hypervolume
fMRI_2D_z11 <- fMRIVolume[ , , 11, ]
X1 = fft(fMRI_2D_z11)
# Opening rgl window to display in html page
invisible(open3d(useNULL = T, windowRect = c(0,0,800,800), zoom = 1))
display1 <-
contour3d(img1, level = c(7, 12), alpha = c(0.3, 0.5), add = TRUE,
color=c("yellow", "red"), perspective=T, distance=0.8)
# Aspect ratio and axes
aspect3d(1.0, 1.0, 1.0)
axes3d()
# Display scene
rglwidget(width = 800, height = 600, elementId = "model1") %>%
toggleWidget(ids = display1, label = "Show")