voxel_cube | R Documentation |
Generate volume data from 'MNI' coordinates
add_voxel_cube(
brain,
name,
cube,
size = c(256, 256, 256),
trans_mat = NULL,
trans_space_from = c("model", "scannerRAS"),
color_format = c("RGBAFormat", "RedFormat")
)
add_nifti(
brain,
name,
path,
trans_mat = NULL,
color_format = c("RGBAFormat", "RedFormat"),
trans_space_from = c("model", "scannerRAS")
)
create_voxel_cube(
mni_ras,
value,
colormap,
keys = colormap$get_key(value),
dimension = c(256, 256, 256)
)
brain |
a 'threeBrain' brain object generated from |
name |
the name of voxel cube, only letters, digits and |
cube |
a 3-mode array; see the following example |
size |
the actual size of the volume, usually dot multiplication of the dimension and voxel size |
trans_mat |
the transform matrix of the volume. For |
trans_space_from |
where does |
color_format |
color format for the internal texture. Default is 4-channel |
path |
'Nifti' data path |
mni_ras |
'MNI' 'RAS' coordinates, should be a |
value |
data values (length |
colormap |
a color map generated from |
keys |
integer color-keys generated from a color map with length of |
dimension |
volume dimension; default is a |
create_voxel_cube
returns a list of cube data and other informations;
add_voxel_cube
returns the brain
object
# 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.