vignettes/displaying-surfaces.Rmd
displaying-surfaces.Rmd
The neurosurf
package includes some low density surfaces that are useful for testing and demonstrating package features. We first load left and right “inflated” and “smoothwm” surfaces that are included in the extdata
package folder.
It is is often useful to smooth a surface mesh for visualization and other purposes. neurosurf
uses the Rvcg
package to smooth surface meshes using various smoothing approaches. Below we show smoothed surfaces using the Taubin and HCLaplace methods.
white_surf <- read_surf(white_lh_asc)
#> loading /private/var/folders/qv/_kz9p3dd567bzlf63467hkwm0000gp/T/RtmpbjBSRH/temp_libpath5e0f24e1a20d/neurosurf/extdata/std.8_lh.smoothwm.asc
white_rh_surf <- read_surf(white_rh_asc)
#> loading /private/var/folders/qv/_kz9p3dd567bzlf63467hkwm0000gp/T/RtmpbjBSRH/temp_libpath5e0f24e1a20d/neurosurf/extdata/std.8_rh.smoothwm.asc
open3d()
#> glX
#> 1
layout3d(matrix(1:4, 2,2), heights=c(1,3))
t1 <- text3d(0,0,0,"Taubin smooth, lambda=.5"); next3d()
white_surf1 <- smooth(white_surf, type="taubin", lambda=.8)
p1 <- plot(white_surf1); next3d()
t2 <- text3d(0,0,0,"HCLaplace smooth, delta=.2, iteration=5"); next3d()
white_surf2 <- smooth(white_surf, type="HCLaplace", delta=.2, iteration=5)
p2 <- plot(white_surf2)
rglwidget()
Here we add a colors to the surface that are a function of each surface node’s x
coordinate. When then map these values to a rainbow
color map.
We will plot surface in a row of 3. We generate a set of random values and then smooth those values along the surface to approximate a realistic activation pattern.
In the first column we display all the values in the map. Next we threshold all values between (-2,2). In the last panel we additionally add a cluster size threshold of 30 nodes.
open3d()
#> glX
#> 4
mfrow3d(1, 3, byrow = TRUE)
vals <- rnorm(length(nodes(white_surf2)))
surf <- NeuroSurface(white_surf2, indices=1:length(vals), data=vals)
ssurf <- smooth(surf)
p <- plot(ssurf@geometry, vals=ssurf@data, cmap=rainbow(100), irange=c(-2,2))
next3d()
comp <- conn_comp(ssurf, threshold=c(-.2,.2))
p2 <- plot(ssurf@geometry, vals=ssurf@data, cmap=rainbow(100), irange=c(-2,2), thresh=c(-.2, .2))
next3d()
csurf <- cluster_threshold(ssurf, size=30, threshold=c(-.2,.2))
p2 <- plot(csurf, cmap=rainbow(100), irange=c(-2,2), thresh=c(-.2, .2))
rglwidget()
open3d()
#> glX
#> 6
curv_lh <- curvature(white_surf2)
white_rh_surf2 <- smooth(white_rh_surf, type="HCLaplace", delta=.2, iteration=5)
curv_rh <- curvature(white_rh_surf2)
p <- plot(white_surf2, bgcol=curv_cols(curv_lh), viewpoint="posterior")
p <- plot(white_rh_surf2,bgcol=curv_cols(curv_rh), viewpoint="posterior")
rglwidget()