MRIaggr-calcW: Compute the neighbourhood matrix

Description Usage Arguments Details Value Examples

Description

Computate a neighbourhood matrix using spatial coordinates.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S4 method for signature 'data.frame'
calcW(object, range, method = "euclidean", upper = NULL,
          format = "dgCMatrix", row.norm = FALSE, spatial_res = rep(1,ncol(object)),
		  calcBlockW = FALSE)

## S4 method for signature 'MRIaggr'
calcW(object, range, spatial_res = c(1,1,1), num = NULL,
     hemisphere = "both", subset = NULL, upper = TRUE, format = "dgCMatrix", 
	 row.norm = FALSE, calcBlockW = FALSE,
	 verbose = optionsMRIaggr("verbose"), update.object = FALSE, overwrite = FALSE)

Arguments

object

a data.frame containing the coordinates of the observations or an object of class MRIaggr. REQUIRED.

range

only distances smaller than range are stored in W. postive numeric. REQUIRED.

method

the distance measure to be used. character. This must be one of "euclidean", "maximum", "minkowski" or "greatcircle".

spatial_res

a dilatation factor for the coordinates. positive numeric vector of size 3.

num

the slices to use. numeric vector or NULL.

hemisphere

the hemisphere to use. character.

subset

the subset of observations to use. positive integer vector or NULL leading to use all observations.

upper

should the entire matrix (NULL) or only the upper-triagonal (TRUE) or only the lower-triagonal (FALSE) values be calculated ?

format

the format of the output. Could be "spam" or "dgCMatrix".

row.norm

should the resulting matrix be row-normalized ? TRUE/FALSE.

calcBlockW

should the partition into disjoint spatial blocks of sites be computed ? logical.

verbose

should the execution of the function be traced ? logical.

update.object

should the resulting neighbourhood matrix be stored in object ? logical.

overwrite

if a neighbourhood matrix is already stored in object@ls_descStats, can it be overwritten ? logical.

Details

These functions require to have installed the Matrix and the spam package to work.

ARGUMENTS:
Information about the num argument can be found in the details section of initNum.

The range argument cooresponds to the delta argument of the nearest.dist function from the spam package.

Information about the hemisphere argument can be found in the details section of selectContrast.

The row.norm argument is ignored if format is set to "spam".

FUNCTION:
This function relies on the nearest.dist function of the spam package.

Each of the num, hemisphere and subset argument define a subset of the total set of observations. It is the intersection of all these three subsets that is extracted.

Value

Invisible. A list containing :

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## load a MRIaggr object
data("MRIaggr.Pat1_red", package = "MRIaggr")

#### 1- data.frame method ####
coords <- selectCoords(MRIaggr.Pat1_red, num = 1:3, hemisphere = "lesion")

## full W 
W <- calcW(object = coords, range = sqrt(2))$W
W[1:10,1:10]
table(spam::rowSums(W))

## full W normalized by row
W <- calcW(object = coords, range = sqrt(2), row.norm = TRUE)$W
W[1:10,1:10]
table(spam::rowSums(W))

## upper W 
W <- calcW(object = coords, range = sqrt(2), upper = TRUE)$W
W[1:10,1:10]

#### 2- MRIaggr method ####

## compute W (regular lattice)
W <- calcW(MRIaggr.Pat1_red, range = sqrt(2), upper = NULL, num = 1:3, hemisphere = "lesion")$W
table(spam::rowSums(W > 0))

## compute W (irregular lattice)
W <- calcW(MRIaggr.Pat1_red, range = sqrt(2 * 1.875^2), upper = NULL, num = 1:3, 
         hemisphere = "lesion", spatial_res=c(1.875, 1.875, 6))$W
table(spam::rowSums(W > 0))

bozenne/MRIaggr documentation built on May 13, 2019, 1:39 a.m.