View source: R/n4BiasFieldCorrection.R
n4BiasFieldCorrection | R Documentation |
Perform N4 bias field correction on the given image
n4BiasFieldCorrection(
img,
mask,
rescaleIntensities = FALSE,
shrinkFactor = 4,
convergence = list(iters = c(50, 50, 50, 50), tol = 0.0000001),
splineParam = 200,
returnBiasField = FALSE,
verbose = FALSE,
weightMask = NULL
)
img |
input antsImage |
mask |
input mask, if one is not passed one will be made |
rescaleIntensities |
At each iteration, a new intensity mapping is calculated and applied but there is nothing which constrains the new intensity range to be within certain values. The result is that the range can "drift" from the original at each iteration. This option rescales to the [min,max] range of the original image intensities within the user-specified mask. A mask is required to perform rescaling. Default is FALSE in ANTsR/ANTsPy but TRUE in ANTs. |
shrinkFactor |
Shrink factor for multi-resolution correction, typically integer less than 4. |
convergence |
List of: |
splineParam |
Parameter controlling number of control points in spline. Either single value, indicating how many control points, or vector with one entry per dimension of image, indicating the spacing in each direction. Default in ANTsR/ANTsPy is 200 mm per mesh element in each dimension. The ANTs default is a mesh size of 1 per dimension. |
returnBiasField |
bool, return the field instead of the corrected image. |
verbose |
enables verbose output. |
weightMask |
antsImage of weight mask |
bias corrected image or bias field
BB Avants
dims <- c(50, 50)
img <- makeImage(imagesize = dims, rnorm(prod(dims)))
n4img <- n4BiasFieldCorrection(img)
n4img <- n4BiasFieldCorrection(img, mask = img > 0)
testthat::expect_error(n4BiasFieldCorrection(img, weightMask = "somepath"))
testthat::expect_error(n4BiasFieldCorrection(img, splineParam = rep(200, 3)))
n4img <- n4BiasFieldCorrection(img, splineParam = c(200, 20))
rm(img)
gc()
rm(n4img)
gc()
fname <- getANTsRData("r16")
in_img <- antsImageRead(fname)
n4 <- n4BiasFieldCorrection(in_img)
rm(n4)
gc()
mask <- in_img > 0
mask2 <- antsImageClone(mask, out_pixeltype = "float")
# fails
mask
sum(mask)
## Not run:
n4 <- n4BiasFieldCorrection(in_img, mask = mask, verbose = TRUE)
# fails
n4 <- n4BiasFieldCorrection(in_img, mask = mask2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.