Skip to contents

Creates a Spherical ROI based on a centroid.

Usage

spherical_roi(
  bvol,
  centroid,
  radius,
  fill = NULL,
  nonzero = FALSE,
  use_cpp = TRUE
)

Arguments

bvol

an NeuroVol or NeuroSpace instance

centroid

the center of the sphere in positive-coordinate (i,j,k) voxel space.

radius

the radius in real units (e.g. millimeters) of the spherical ROI

fill

optional value(s) to store as data

nonzero

if TRUE, keep only nonzero elements from bvol

use_cpp

whether to use compiled c++ code

Value

an instance of class ROIVol

Examples

 sp1 <- NeuroSpace(c(10,10,10), c(1,2,3))
 # create an ROI centered around the integer-valued positive voxel coordinate: i=5, j=5, k=5
 cube <- spherical_roi(sp1, c(5,5,5), 3.5)
 vox <- coords(cube)
 cds <- coords(cube, real=TRUE)
 ## fill in ROI with value of 6
 cube1 <- spherical_roi(sp1, c(5,5,5), 3.5, fill=6)
 all(cube1 == 6)
#> [1] TRUE

 # create an ROI centered around the real-valued coordinates: x=5, y=5, z=5
 vox <- coord_to_grid(sp1, c(5, 5, 5))
 cube <- spherical_roi(sp1, vox, 3.5)