Regions of interest
Creating a spherical ROI
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)
#>
#>
#> ROIVol
#> Size: 11
#> Parent Dim: 64 64 25
#> Num Data Cols: 1
#> Voxel Cen. Mass: 20 20 20
Creating a Spherical ROI around a real-valued coordinate
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.