knitr::opts_chunk$set(collapse = T, comment = "#>") library(assertthat) library(purrr) library(neuroim2) options(mc.cores=1)
In neuroim2 there is basic support for creating regions of interest (ROI). To create a spherical ROI around a central point, we need an existing object of type NeuroVol
or NeuroSpace
.
To create a spherical region of interest with a 5mm radius around a central voxel at i=20, j=20, k=20, we first read in an image.
library(neuroim2) file_name <- system.file("extdata", "global_mask.nii", package="neuroim2") vol <- read_vol(file_name)
Next, we create a spherical ROI centered around voxel coordinates [20,20,20] with a 5mm radius, filling all values in the ROI with 100.
sphere <- spherical_roi(vol, c(20,20,20), radius=5, fill=100, use_cpp=FALSE)
sphere
To create a spherical ROI centered around a real coordinate in millimeters, we need to first convert the real-valued coordinates to a voxel-based coordinate. Suppose our real-world coordinate is at -50, -28, 10 in coordinate space.
rpoint <- c(-34,-28,10)
Because the function spherical_roi
takes a coordinate in voxel units, we need to convert the real-world coordinate (i.e. in millimeter units) to voxel coordinates.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.