# requires N27 brain to be installed
# use `download_N27()` to download template Collins brain
# sample MNI coords
tbl <- read.csv(system.file(
'sample_data/example_cube.csv', package = 'threeBrain'
))
head(tbl)
# load colormap
cmap <- load_colormap(system.file(
'palettes/datacube2/Mixed.json', package = 'threeBrain'
))
x <- create_voxel_cube(
mni_ras = tbl[, c('x', 'y', 'z')],
keys = tbl$key,
dimension = c(128, 128, 128)
)
n27_path <- file.path(default_template_directory(), "N27")
if( interactive() && dir.exists(n27_path) ) {
brain <- merge_brain()
# or add_voxel_cube(brain, 'example', x$cube)
x$add_to_brain(brain, 'example')
brain$plot(controllers = list(
"Voxel Type" = 'example',
'Right Opacity' = 0.3,
'Left Opacity' = 0.3,
'Background Color' = '#000000'
), voxel_colormap = cmap)
}
Run the code above in your browser using DataLab