Last data update: 2014.03.03

R: Spatial regularization
calcSmoothMaskR Documentation

Spatial regularization

Description

Perform a spatial regularization of a binary mask.

Usage

## S4 method for signature 'MRIaggr'
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.

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).

Value

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

See Also

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

Examples

## 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)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MRIaggr)
Loading required package: Rcpp
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MRIaggr/MRIaggr-calcSmoothMask.Rd_%03d_medium.png", width=480, height=480)
> ### Name: calcSmoothMask
> ### Title: Spatial regularization
> ### Aliases: calcSmoothMask calcSmoothMask,MRIaggr-method
> ### Keywords: methods
> 
> ### ** Examples
> 
> ## 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")
Merging : (1) 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)
1 brain groups : G2.=.2 
2 brain groups : G3.=.2 G3.=.3 G3.>=.2 
3 brain groups : G4.=.2 G4.=.3 G4.=.4 G4.>=.3 G4.<=.3 
allocContrast[MRIaggr] : Cartography "mask" 
                         has been allocated 
> 
> ## smooth the cerebral mask
> res <- calcSmoothMask(MRIaggr.Pat1, update.object = TRUE, overwrite = TRUE)
rm small2D :  14 vx ; 14 groups 
rm small3D :  0 vx ; 0 groups 
erosion :  0 vx ; 0 groups 
add hole3D :  3 vx ; 3 groups 
smoothing (add / rm) : (1) 0/1  (2) 0/1  (3) 0/0  
allocContrast[MRIaggr] : Cartography "mask" 
                         has been updated 
> 
> ## display
> multiplot(MRIaggr.Pat1,param = "mask", legend = FALSE)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>