Description Usage Arguments Details Value Author(s) Examples
this converts a scalar image to a matrix with rows that contain neighbors around a center voxel
1 2 3 | getNeighborhoodInMask(image, mask, radius, physical.coordinates = FALSE,
boundary.condition = "NA", spatial.info = FALSE,
get.gradient = FALSE)
|
image |
image object of S4 class |
mask |
image object of S4 class |
radius |
array of values for neighborhood radius (in voxels) |
physical.coordinates |
logical indicating if voxel indices and offsets should be in voxel or physical coordinates |
boundary.condition |
string indicating how to handle voxels in a
neighborhood, but not in the mask. See |
spatial.info |
a boolean indicating of voxel locations and neighborhood offsets should be returned along with pixel values. |
get.gradient |
a boolean indicating if a matrix of gradients (at the center voxel) should be returned in addition to the value matrix (WIP) |
boundary.condition
should be one of:
NA
: Fill values with NA
.
image
: Use image value, even if not in mask.
mean
: Use man of all non-NA
values for that neighborhood.
if spatial.info
is false: a matrix of pixel values where the number of rows
is the size of the neighborhood and there is a column for each voxel
if spatial.info
is true, a list containing three matrices:
values: matrix of pixel values where the number of rows is the size of the neighborhood and there is a column for each voxel.
indices: matrix providing the center coordinates for each neighborhood
offsets: matrix providing the offsets from center for each voxel in a neighborhood
Duda JT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | r16 <- getANTsRData("r16")
r16 <- antsImageRead(r16,2)
mask <- getMask(r16,lowThresh=mean(r16),cleanup=1)
radius <- rep(2,2)
mat <- getNeighborhoodInMask(r16,mask,radius)
mat <- getNeighborhoodInMask(r16,mask,radius,
boundary.condition ="image")
mat <- getNeighborhoodInMask(r16,mask,radius,
boundary.condition ="mean")
randlist <- getNeighborhoodInMask(r16,mask,radius,
physical.coordinates = TRUE)
arr = as.array(r16)
testthat::expect_error(getNeighborhoodInMask(arr,mask,radius), "antsImage")
testthat::expect_error(getNeighborhoodInMask(r16,as.numeric(mask),radius),
"mask must be")
testthat::expect_error(getNeighborhoodInMask(r16,mask,as.character(radius)),
"radius must be")
# testthat::expect_error(getNeighborhoodInMask(r16,mask,c(radius, 3)),
# "Radius must")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.