the binary contrast parameter(s) defining the spatial groups from which the distance will be computed. character vector. REQUIRED.
name_newparam
the name of the new distance parameters. character vector.
spatial_res
a dilatation factor for the coordinates. positive numeric vector of size 3.
numeric2logical
should mask be convert to logical ? logical.
Neighborhood
the type of neighbourhood. character.
verbose
should the execution of the function be traced ? logical.
update.object
should the resulting distance parameters be stored in object ? logical.
overwrite
if contrast parameters with the same names are already stored in object@data, can they be overwritten ? logical.
Details
This function requires to have installed the RANN package to work.
ARGUMENTS:
Information about the num argument can be found in the details section of initNum.
The Neighborhood argument 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 relies on the nn2 function of the RANN package.
Value
An data.frame containing in row the observations and in columns the distance parameters.
Examples
## load a MRIaggr object
data("MRIaggr.Pat1_red", package = "MRIaggr")
## compute distance to initial and final mask
res <- calcDistMask(MRIaggr.Pat1_red, mask = c("MASK_DWI_t0","MASK_T2_FLAIR_t2"),
update.object = TRUE, overwrite = TRUE)
multiplot(MRIaggr.Pat1_red, param = "dist_MASK_DWI_t0",
index1 = list(coords = "MASK_DWI_t0", outline = TRUE))
## compute distance to initial and final mask correcting anisotropy
res <- calcDistMask(MRIaggr.Pat1_red, mask = c("MASK_DWI_t0","MASK_T2_FLAIR_t2"),
spatial_res = c(1.875,1.875,6),
update.object = TRUE, overwrite = TRUE)
multiplot(MRIaggr.Pat1_red, param = "dist_MASK_DWI_t0",
index1 = list(coords = "MASK_DWI_t0", outline = TRUE))
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-calcDistMask.Rd_%03d_medium.png", width=480, height=480)
> ### Name: calcDistMask
> ### Title: Euclidean distance to a spatial group
> ### Aliases: calcDistMask calcDistMask,MRIaggr-method
> ### Keywords: methods
>
> ### ** Examples
>
> ## load a MRIaggr object
> data("MRIaggr.Pat1_red", package = "MRIaggr")
>
> ## compute distance to initial and final mask
> res <- calcDistMask(MRIaggr.Pat1_red, mask = c("MASK_DWI_t0","MASK_T2_FLAIR_t2"),
+ update.object = TRUE, overwrite = TRUE)
1 2
allocContrast[MRIaggr] : Cartographies "dist_MASK_DWI_t0" "dist_MASK_T2_FLAIR_t2"
have been allocated
>
> multiplot(MRIaggr.Pat1_red, param = "dist_MASK_DWI_t0",
+ index1 = list(coords = "MASK_DWI_t0", outline = TRUE))
>
> ## compute distance to initial and final mask correcting anisotropy
> res <- calcDistMask(MRIaggr.Pat1_red, mask = c("MASK_DWI_t0","MASK_T2_FLAIR_t2"),
+ spatial_res = c(1.875,1.875,6),
+ update.object = TRUE, overwrite = TRUE)
1 2
allocContrast[MRIaggr] : Cartographies "dist_MASK_DWI_t0" "dist_MASK_T2_FLAIR_t2"
have been updated
>
> multiplot(MRIaggr.Pat1_red, param = "dist_MASK_DWI_t0",
+ index1 = list(coords = "MASK_DWI_t0", outline = TRUE))
>
>
>
>
>
> dev.off()
null device
1
>