Learn R Programming

MRIaggr (version 1.1.5)

calcSmoothMask: Spatial regularization

Description

Perform a spatial regularization of a binary mask.

Usage

"calcSmoothMask"(object, mask = "mask", numeric2logical = FALSE, size_2Dgroup = 50, Neighborhood_2D = "3D_N8", rm.2Dhole = FALSE, size_3Dgroup = "unique", Neighborhood_3D = "3D_N10", rm.3Dhole = TRUE, erosion.th = 0.75, Vmask_min = 0.25, Vbackground_max = 0.75, Neighborhood_V = "3D_N10", verbose = optionsMRIaggr("verbose"), update.object = FALSE, overwrite = FALSE)

Arguments

object
an object of class MRIaggr. REQUIRED.
mask
the binary contrast parameter that should be smoothed. character.
numeric2logical
should mask be convert to logical ? logical.
size_2Dgroup
the minimum size of the 2D groups. positive integer or "unique".
Neighborhood_2D
the type of 2D neighbourhood. character.
rm.2Dhole
should the 2D wholes inside the mask be removed ? logical.
size_3Dgroup
the minimum size of the 3D groups. positive integer or "unique".
Neighborhood_3D
the type of 3D neighbourhood. character.
rm.3Dhole
should the 3D wholes inside the mask be removed ? logical.
erosion.th
the threshold below which the observations will be removed by the erosion. numeric between 0 and 1.
Vmask_min
mask observations with a proportion of neighbors belonging to the mask lower than Vmask_min are attributed to the background. numeric between 0 and 1.
Vbackground_max
background observations with a proportion of neighbors belonging to the mask higher than Vbackground_max are attributed to the mask. numeric between 0 and 1.
Neighborhood_V
the type of neighbourhood to use for the spatial regularization. character.
verbose
should the execution of the function be traced ? logical.
update.object
should the resulting regularized mask be stored in object ? logical.
overwrite
if a mask is already stored in object@data, can it be overwritten ? logical.

Value

An data.frame containing the mask and the coordinates in columns.

Details

ARGUMENTS: the Neighborhood_2D or Neighborhood_3D arguments can be a matrix or an array defining directly the neighbourhood to use (i.e the weight of each neighbor) or a name indicating which type of neighbourhood should be used (see the details section of initNeighborhood).

FUNCTION: This function applies 6 smoothing steps :

  • exclusion of the small 2D groups from the mask (to skip set size_2Dgroup to FALSE). Note that size_2Dgroup = "unique" lead to keep the largest 2D group of each slice.
  • filling of the small 2D holes in the mask (to skip set rm.2Dhole to FALSE).
  • exclusion of the small 3D groups from the mask (to skip set size_3Dgroup to FALSE). Note that size_3Dgroup = "unique" lead to keep only the largest 3D group.
  • erosion that first temporarily remove observations from the mask that have less than erosion.th percent of their neighbourhood in the mask. Then it computes the new 3D groups and remove permanently all the new 3D groups from the mask. To skip set erosion.th to FALSE.
  • filling of the small 3D holes in the mask (to skip set rm.3Dhole to FALSE).
  • spatial regularization that homogenize the local neighbourhood (to skip set both Vmask_min and Vbackground_max to FALSE).

See Also

selectContrast to select the smoothed mask. calcBrainMask to compute an indicator of the brain observations.

Examples

Run this code
## load data and build MRIaggr
path.Pat1 <- system.file(file.path("nifti"), package = "MRIaggr")
ls.array <- list(readMRI(file.path(path.Pat1,"T2_GRE_t0"), format = "nifti"))
MRIaggr.Pat1 <- constMRIaggr(ls.array,identifier="Pat1", param = "T2_GRE_t0")

## create the cerebral mask
res <- calcBrainMask(MRIaggr.Pat1, param = "T2_GRE_t0", type = "kmeans",
                     kmeans.n_groups = 2:4,
                     update.object = TRUE, overwrite = TRUE)

## smooth the cerebral mask
res <- calcSmoothMask(MRIaggr.Pat1, update.object = TRUE, overwrite = TRUE)

## display
multiplot(MRIaggr.Pat1,param = "mask", legend = FALSE)

Run the code above in your browser using DataLab