Visualizing 3D Objects with RMINC

As of RMINC 1.3 we’ve begun to support visualizing 3D volumes with R. This document is designed to showcase a few of these features.

#Load in our libraries
library(RMINC)
library(rgl)

Lets pull in a demonstration object file. The file format currently supported by RMINC is the BIC-MNI text obj format, documented on their github. This file format is used by CIVET, amongst other tools, to store brain surfaces. The figures produced are interactive and can be rotated and magnified with the mouse.

mouse_cortex <- 
  read_obj("/axiom2/projects/software/cortical-thickness/MWM/c57bl6_laplacian_grid_full_surface_simplified.obj")

plot(mouse_cortex)

In addition to creating surfaces, it is possible to add thresholdable statistics maps with colour legends

demo_stats <- #Generate some random uniform vertex data
  runif(ncol(mouse_cortex$vertex_matrix))

plot(mouse_cortex, demo_stats, colour_range = c(.5,1))

It is also possible to identify vertices from a figure

selected_vertices <- vertexSelect(multiples = TRUE)

To disable the indicator spheres, simply run vertexSelect with indicate = FALSE. To remove the spheres after you’ve verified they are correct, run rgl::pop3d(), only do this if you have not added elements to the rgl scene after the spheres, otherwise you will need to look up their ids with rgl::ids(). See ?vertexSelect for details.

Once you’ve identified your vertices of interest, you can find those vertices within the statistic map

vertexLookup(mouse_cortex, selected_vertices, demo_stats)
## [1] 0.2747079 0.3866898 0.8426127