Learn R Programming

MRIaggr (version 1.1.5)

selectW: Extract a neighbourhood matrix

Description

Extract elements in the W slot of a MRIaggr object.

Usage

"selectW"(object, type = "Wmatrix", subset_W = NULL, hemisphere = "both", num = NULL, slice_var = "k", upper = NULL)

Arguments

object
an object of class MRIaggr. REQUIRED.
type
the type of the element to select. Can be "Wmatrix", "Wblocks" or "upper".
subset_W
the subset of observations to select. integer vector or NULL leading to select all the observations.
hemisphere
the hemisphere to use. character.
num
the slices to use. numeric vector or NULL.
slice_var
the type of slice to extract. "i" for sagittal, "j" for coronal and "k" for transverse. character.
upper
the format of the matrix to extract. Can be the full matrix (upper=NULL) or upper- or lower-triangular matrix (upper=TRUE or upper=FALSE).

Details

This function requires to have installed the Matrix and the spam package to work when argument name is set to "W_euclidean".

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

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

FUNCTION: If subset_W is not NULL then arguments hemisphere and num are ignored. 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 is extracted.

See Also

calcW to compute the neighboring matrix. calcBlockW to decompose the neighboring matrix in independant blocks.

Examples

Run this code
## load a MRIaggr object
data("MRIaggr.Pat1_red", package = "MRIaggr")

## compute and allocate a neighbourhood matrix
calcW(object=MRIaggr.Pat1_red, range = sqrt(2), update.object = TRUE)

## select the neighbourhood matrix
selectW(MRIaggr.Pat1_red)[1:10,1:10]
selectW(MRIaggr.Pat1_red, upper = TRUE)[1:10,1:10]
# selectW(MRIaggr.Pat1_red, upper = FALSE)[1:10,1:10] # will not work

Run the code above in your browser using DataLab